Skip to content

Commit

Permalink
Make edpm_network_config role compliant with ansible-lint `producti…
Browse files Browse the repository at this point in the history
…on` profile

- Fixed spacing in jinja templating
- Added missing FQCN
- Replaced `'` with `"` in `mode` parameter to be compliant with other roles
- Added a couple of "when: $foo.changed" conditions in whitelist, since we can't create handlers and flush them because the role is executed in a playbook that contains a lot of roles.

Signed-off-by: Roberto Alfieri <[email protected]>
  • Loading branch information
rebtoor committed Oct 9, 2023
1 parent b78d104 commit 49b3d35
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
8 changes: 3 additions & 5 deletions roles/edpm_network_config/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
ansible.builtin.set_fact:
systemrolename:
"{%- if ansible_facts['distribution'] == 'RedHat' -%}
redhat.rhel
{%- else -%}
fedora.linux
{%- endif -%}
redhat.rhel{%- else -%}
fedora.linux{%- endif -%}
_system_roles.network"
delegate_to: localhost
- name: Install OVS NetworkManager plugin [nmstate]
Expand All @@ -39,7 +37,7 @@
ansible.builtin.systemd:
name: NetworkManager
state: restarted
when: nm_ovs_status.changed
when: nm_ovs_status.changed # noqa: no-handler
- name: Load system-roles.network tasks [nmstate]
ansible.builtin.include_role:
name: "{{ systemrolename }}"
Expand Down
16 changes: 8 additions & 8 deletions roles/edpm_network_config/tasks/network_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
become: true
when:
- ansible_facts.selinux.status == "enabled"
sefcontext:
community.general.sefcontext:
target: "/var/lib/edpm-config(/.*)?"
setype: container_file_t
selevel: s0
Expand Down Expand Up @@ -55,7 +55,7 @@
state: directory
setype: container_file_t
selevel: s0
mode: '0750'
mode: "0750"

- name: Check for previous run of NetworkConfig
become: true
Expand Down Expand Up @@ -97,21 +97,21 @@
ansible.builtin.file:
path: /etc/os-net-config
state: directory
mode: '0755'
mode: "0755"

- name: Create os-net-config mappings from lookup data
edpm_os_net_config_mappings:
net_config_data_lookup:
"{{ edpm_network_config_os_net_config_mappings }}"
when: not ansible_check_mode|bool
when: not ansible_check_mode | bool
register: os_net_config_mappings_result

- name: Write os-net-config mappings file /etc/os-net-config/mapping.yaml
ansible.builtin.copy:
content: "{{ os_net_config_mappings_result.mapping | to_nice_yaml }}"
dest: /etc/os-net-config/mapping.yaml
mode: '0644'
when: os_net_config_mappings_result.changed|bool
mode: "0644"
when: os_net_config_mappings_result.changed | bool # noqa: no-handler

- name: Manage NetworkConfig with edpm_os_net_config module
block:
Expand All @@ -127,7 +127,7 @@
ansible.builtin.copy:
content: "{{ network_config_result.rc }}"
dest: /var/lib/edpm-config/os-net-config.returncode
mode: '0644'
mode: "0644"
when:
- network_config_result.rc is defined

Expand All @@ -138,7 +138,7 @@
network:
config: disabled
dest: /etc/cloud/cloud.cfg.d/99-edpm-disable-network-config.cfg
mode: '0644'
mode: "0644"
when:
- network_config_result.rc is defined
- network_config_result.rc == 0
Expand Down

0 comments on commit 49b3d35

Please sign in to comment.