Skip to content

Commit ff9ce50

Browse files
committed
Pre chaging simulation approach
1 parent 87f5b80 commit ff9ce50

File tree

16 files changed

+73
-90
lines changed

16 files changed

+73
-90
lines changed

roles/grub/templates/grub.cfg.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{% else %}
1313
{% set paramValPrefix = '' %}
1414
{% endif %}
15-
{{ paramName }}="{{ paramValPrefix }}{{ param.value | aybarsm.helper.flatten_query('name', 'value', '=', ' ') }}"
15+
{{ paramName }}="{{ paramValPrefix }}{{ param.value | aybarsm.helper.to_querystring('name', 'value', '=', ' ') }}"
1616
{% else %}
1717
{{ paramName }}="{{ param.value }}"
1818
{% endif %}

roles/network_interfaces/templates/network_interfaces.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ iface lo inet loopback
3636
{% endif %}
3737
iface {{ iface.name }} {{ addr_family }} {{ ifaceMethod }}
3838
{% if ifaceParams | length > 0 %}
39-
{{ ifaceParams | aybarsm.helper.flatten_query('name', 'value', ' ', '\n') | indent(4, true) }}
39+
{{ ifaceParams | aybarsm.helper.to_querystring('name', 'value', ' ', '\n') | indent(4, true) }}
4040
{% endif %}
4141
{% endif %}
4242

roles/package_manager/defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ linux_role_package_manager_enabled: false
55
# Available options: specific, common
66
linux_package_manager_package_strategy: specific
77

8+
linux_package_manager_package_simulation: true
9+
810
linux_package_manager_default: []
911
linux_package_manager_group: []
1012
linux_package_manager_host: []

roles/package_manager/tasks/common.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
- name: Manage system packages with common package manager
3+
ansible.builtin.package:
4+
name: "{{ item.name }}"
5+
state: "{{ item.state | default(omit) }}"
6+
use: "{{ item.use | default(omit) }}"
7+
register: linux_package_manager_common_packages_apply
8+
when:
9+
- linux_packages_all | type_debug == 'list'
10+
- linux_packages_all | length > 0
11+
loop: "{{ linux_packages_all }}"

roles/package_manager/tasks/deb_packages.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
- name: Manage DEB packages via APT
33
become: true
44
ansible.builtin.apt:
5-
name: "{{ package_name }}"
5+
name: "{{ item.name }}"
66
allow_change_held_packages: "{{ item.allow_change_held_packages | default(omit) | bool }}"
77
allow_downgrade: "{{ item.allow_downgrade | default(omit) | bool }}"
88
allow_unauthenticated: "{{ item.allow_unauthenticated | default(omit) | bool }}"
@@ -26,10 +26,11 @@
2626
update_cache_retries: "{{ item.update_cache_retries | default(omit) }}"
2727
update_cache_retry_max_delay: "{{ item.update_cache_retry_max_delay | default(omit) }}"
2828
upgrade: "{{ item.upgrade | default(omit) }}"
29-
vars:
30-
package_name: "{{ item.name + '=' + item.version if 'version' in item else item.name }}"
3129
loop: "{{ linux_package_manager_packages_all }}"
32-
register: linux_package_manager_deb_packages_apply
30+
vars:
31+
__is_simulation: "{{ __linux_package_manager_simulate_packages | default(false) | bool }}"
32+
register: "{{ 'linux_package_manager_deb_packages_' + ('simulate' if __is_simulation else 'simulate') }}"
33+
check_mode: "{{ __is_simulation }}"
3334
when:
3435
- linux_package_manager_packages_all | type_debug == 'list'
3536
- linux_package_manager_packages_all | length > 0
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: Simulate DEB package install via APT
3+
ansible.builtin.command:
4+
cmd: "apt --simulate install {{ packages | join(' ') }}"
5+
register: linux_package_manager_deb_packages_simulate_install
6+
changed_when: false
7+
8+
- name: Simulate DEB package remove via APT
9+
ansible.builtin.command:
10+
cmd: "apt --simulate remove {{ packages | join(' ') }}"
11+
register: linux_package_manager_deb_packages_simulate_remove
12+
changed_when: false

roles/package_manager/tasks/main.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
- linux_role_package_manager_enabled | default(false) | bool
1313
- ansible_os_family | lower == 'debian'
1414

15+
- name: Simulate DEB package tasks (APT)
16+
ansible.builtin.import_tasks:
17+
file: deb_packages.yml
18+
vars:
19+
__linux_package_manager_simulate_packages: true
20+
when:
21+
- linux_role_package_manager_enabled | default(false) | bool
22+
- linux_package_manager_package_strategy | lower == 'specific'
23+
- ansible_os_family | lower == 'debian'
24+
- linux_package_manager_package_simulation | default(true) | bool
25+
- not ansible_check_mode
26+
1527
- name: Import DEB package tasks (APT)
1628
ansible.builtin.import_tasks:
1729
file: deb_packages.yml
@@ -22,7 +34,7 @@
2234

2335
- name: Import common package manager tasks
2436
ansible.builtin.import_tasks:
25-
file: common.yml
37+
file: common_packages.yml
2638
when:
2739
- linux_role_package_manager_enabled | default(false) | bool
2840
- linux_package_manager_package_strategy | lower == 'common'

roles/package_manager/vars/debian.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ __linux_package_manager_package_config:
1010
- ['type', 'equalto', 'package']
1111
- when: "{{ __linux_package_manager_uniques_package | product(['defined']) | list }}"
1212
logic: or
13+
replace_keys:
14+
- before: package
15+
after: name
16+
- before: pkg
17+
after: name
1318
setattr:
1419
- attribute: name
1520
value: package
@@ -25,13 +30,9 @@ __linux_package_manager_package_config:
2530
- ['name', 'undefined']
2631
- ['pkg', 'defined']
2732
- attribute: state
28-
value: absent
29-
else: present
30-
overwrite: true
33+
value: present
3134
when:
32-
- ['autoremove', 'defined']
33-
- ['autoremove', 'true']
34-
logic: and
35+
- ['state', 'undefined']
3536
splitattr:
3637
- srcAttr: name
3738
dstAttr: version

roles/posix/defaults/sysctl.yml renamed to roles/posix/defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ linux_role_posix_sysctl_enabled: false
33
linux_posix_sysctl_default: []
44
linux_posix_sysctl_group: []
55
linux_posix_sysctl_host: []
6-
# The combination strategy below is highly nested hierarchy compliant and recommended (Example provided below)
6+
# The combination strategy below is highly nested hierarchy compliant and recommended.
77
# linux_posix_sysctl_host > linux_posix_sysctl_group > linux_posix_sysctl_default
88
linux_posix_sysctl_all: "{{ (linux_posix_sysctl_host + linux_posix_sysctl_group + linux_posix_sysctl_default) | unique(attribute='name') }}"

roles/posix/tasks/sysctl.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
# TODO: Implement handlers for sysctl
23
- name: Deploy posix sysctl settings
34
ansible.posix.sysctl:
45
name: "{{ item.name }}"
@@ -8,7 +9,8 @@
89
state: "{{ item.state | default(omit) }}"
910
sysctl_file: "{{ item.sysctl_file | default(omit) }}"
1011
sysctl_set: "{{ item.sysctl_set | default(omit) | bool }}"
12+
loop: "{{ linux_posix_sysctl_all }}"
13+
register: linux_posix_sysctl_deploy
1114
when:
12-
- linux_posix_sysctl_all | linux_type_debug == 'list'
15+
- linux_posix_sysctl_all | type_debug == 'list'
1316
- linux_posix_sysctl_all | length > 0
14-
loop: "{{ linux_posix_sysctl_all }}"

roles/proxmox/defaults/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
linux_role_proxmox_enabled: false
22

3-
linux_proxmox_default: []
4-
linux_proxmox_group: []
5-
linux_proxmox_host: []
3+
linux_proxmox_default: {}
4+
linux_proxmox_group: {}
5+
linux_proxmox_host: {}
66

7-
linux_proxmox_all: "{{ linux_proxmox_default + linux_proxmox_group + linux_proxmox_host }}"
7+
linux_proxmox_all: "{{ linux_proxmox_default | combine(linux_proxmox_group, linux_proxmox_host) }}"

roles/proxmox/tasks/debug.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: Debug
3+
ansible.builtin.debug:
4+
msg:
5+
linux_proxmox_role_repos: "{{ linux_proxmox_role_repos }}"
6+
linux_proxmox_all: "{{ linux_proxmox_all }}"
7+
delegate_to: localhost

roles/proxmox/tasks/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
- name: Include Debug Tasks
3+
ansible.builtin.import_tasks:
4+
file: debug.yml

roles/proxmox/vars/main.yml

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,4 @@ linux_proxmox_role_repos:
3131
filename: ceph
3232
ceph_reef_no_subscription:
3333
repo: "deb {{ linux_proxmox_repo_url_no_subscription }}/ceph-reef {{ ansible_distribution_release }} no-subscription"
34-
filename: ceph
35-
36-
# '<role_name> <repo_prefix> <filename>'
37-
# if <repo_prefix> is empty, there won't be any prefix at the end of the repo line
38-
# (i.e. /pve bookworm pve-enterprise vs /ceph-pacific bookworm enterprise)
39-
# if <filename> is empty, it will be the same as <repo_prefix>-<subscription_type>
40-
# (i.e. pve-no-subscription vs ceph)
41-
# linux_proxmox_role_repos:
42-
# - ['pve', 'pve-']
43-
# - ['pbs', 'pbs-']
44-
# - ['pmg', 'pmg-']
45-
# - ['ceph-reef', '', 'ceph']
46-
# - ['ceph-quincy', '', 'ceph']
47-
# - ['ceph-pacific', '', 'ceph']
48-
49-
# linux_proxmox_role_repos:
50-
# pve: ['pve-']
51-
# pbs: ['pbs-']
52-
# pmg: ['pmg-']
53-
# ceph_reef: ['ceph-reef', '', 'ceph']
54-
# ceph_quincy: ['ceph-quincy', '', 'ceph']
55-
# ceph_pacific: ['ceph-pacific', '', 'ceph']
34+
filename: ceph

roles/systemd/defaults/network.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)