Skip to content

Commit

Permalink
Empty commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
aybarsm committed Jun 27, 2024
1 parent 8af7f13 commit c05f4b3
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
4 changes: 2 additions & 2 deletions roles/grub/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Apply linux_grub changes
ansible.builtin.import_tasks:
file: "{{ linux_grub_change_strategy }}.yml"
file: command.yml
listen: "linux_grub_apply_changes"
when: linux_grub_change_strategy | default('') == 'command'
when: (linux_grub_change_strategy | default('') == 'command')
9 changes: 6 additions & 3 deletions roles/network_interfaces/handlers/command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
- name: Apply command(s) for linux_network_interfaces changes
become: true
ansible.builtin.command:
argv: "{{ item.argv | default(omit) }}"
# argv: "{{ item.argv | default(omit) }}"
chdir: "{{ item.chdir | default(omit) }}"
cmd: "{{ item.cmd }}"
creates: "{{ item.creates | default(omit) }}"
expand_argument_vars: "{{ item.expand_argument_vars | default(omit) }}"
free_form: "{{ item.free_form | default(omit) }}"
# expand_argument_vars: "{{ item.expand_argument_vars | default(omit) }}"
# free_form: "{{ item.free_form | default(omit) }}"
removes: "{{ item.removes | default(omit) }}"
stdin: "{{ item.stdin | default(omit) }}"
stdin_add_newline: "{{ item.stdin_add_newline | default(omit) }}"
strip_empty_ends: "{{ item.strip_empty_ends | default(omit) }}"
changed_when: true
loop: "{{ linux_network_interfaces_change | selectattr('cmd', 'defined') }}"
register: linux_network_interfaces_apply_changes_command
listen: "linux_network_interfaces_apply_changes_by_command"
when:
- linux_network_interfaces_change_strategy | default('') == 'command'
- linux_network_interfaces_change | type_debug == 'list'
- linux_network_interfaces_change | selectattr('cmd', 'defined') | length > 0
2 changes: 1 addition & 1 deletion roles/network_interfaces/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Apply linux_network_interfaces changes
ansible.builtin.import_tasks:
file: "{{ linux_network_interfaces_change_strategy }}.yml"
file: command.yml
listen: "linux_network_interfaces_apply_changes"
when: linux_network_interfaces_change_strategy | default('') | in ['command', 'service']
2 changes: 2 additions & 0 deletions roles/network_interfaces/handlers/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use: "{{ item.use | default(omit) }}"
loop: "{{ linux_network_interfaces_change | selectattr('name', 'defined') }}"
register: linux_network_interfaces_apply_changes_service
listen: "linux_network_interfaces_apply_changes_by_service"
when:
- linux_network_interfaces_change_strategy | default('') == 'service'
- linux_network_interfaces_change | type_debug == 'list'
- linux_network_interfaces_change | selectattr('name', 'defined') | length > 0
35 changes: 35 additions & 0 deletions roles/systemd/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
---
# Ensures system manager is systemd - ansible_service_mgr == "systemd"
linux_systemd_ensure_service_manager: true
linux_manage_systemd_network: false

linux_systemd_network_apply_changes: false

linux_systemd_network_backup: true
linux_systemd_network_cleanup: false
linux_systemd_network_cleanup_patterns_use_regex: true

# Consult: https://manpages.debian.org/bookworm/systemd/systemd.net-naming-scheme.7.en.html
linux_systemd_network_naming_scheme: "v252"

linux_systemd_network_dir: /etc/systemd/network
linux_systemd_network_template: network.j2

linux_systemd_network_default: []
linux_systemd_network_group: []
linux_systemd_network_host: []
# The combination strategy below is highly nested hierarchy compliant and recommended
# linux_systemd_network_host > linux_systemd_network_group > linux_systemd_network_default
linux_systemd_network_all: "{{ (linux_systemd_network_host + linux_systemd_network_group + linux_systemd_network_default) |
selectattr('name', 'defined') | selectattr('name', 'search', '\\.(network|link|netdev)$') |
selectattr('config', 'defined') | unique(attribute='name') }}"

linux_systemd_network_names: "{{ linux_systemd_network_all | map(attribute='name') }}"
# Escape file names defined in linux_systemd_network_all
linux_systemd_network_cleanup_regex:
- "^({{ linux_systemd_network_names | select('match', '.*\\.link$') | map('replace', '.link', '') | join('|') }})\\.link$"
- "^({{ linux_systemd_network_names | select('match', '.*\\.netdev$') | map('replace', '.netdev', '') | join('|') }})\\.netdev$"
- "^({{ linux_systemd_network_names | select('match', '.*\\.network$') | map('replace', '.network', '') | join('|') }})\\.network$"
# Escape backup files:
- "^.*\\.\\d+\\.\\d{4}-\\d{2}-\\d{2}@\\d{2}:\\d{2}:\\d{2}~$"

# Join regex expressions
linux_systemd_network_cleanup_patterns: ["(?!{{ linux_systemd_network_cleanup_regex | join('|') }})"]

0 comments on commit c05f4b3

Please sign in to comment.