Skip to content

Commit

Permalink
Add templating support for nmstate defined networking configuration
Browse files Browse the repository at this point in the history
* Fixed `nmstate` molecule scenario for `edpm_network_config` role

Signed-off-by: Roberto Alfieri <[email protected]>
  • Loading branch information
rebtoor committed Oct 27, 2023
1 parent d21f24d commit d81a86b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions roles/edpm_network_config/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ edpm_network_config_manage_service: true
edpm_network_config_nmstate: false
edpm_network_config_os_net_config_mappings: {}
edpm_network_config_safe_defaults: true
edpm_network_config_with_ansible: true
edpm_network_config_template: ""
edpm_bond_interface_ovs_options: "bond_mode=active-backup"
6 changes: 4 additions & 2 deletions roles/edpm_network_config/molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# under the License.
- name: Prepare test_deps
hosts: all
become: true
roles:
- role: ../../../../molecule/common/test_deps
test_deps_setup_edpm: true
Expand All @@ -27,12 +28,13 @@

tasks:
- name: Ensure legacy scripts installed
become: true
ansible.builtin.package:
name: network-scripts
state: present
when:
- ansible_facts['distribution_major_version'] is version('8', '==')
- name: Create a dummy network interface
become: true
ansible.builtin.command: "ip link add dummy0 type dummy"
register: ip_command_output
changed_when: ip_command_output.rc == 0
failed_when: ip_command_output.rc != 0
15 changes: 7 additions & 8 deletions roles/edpm_network_config/molecule/nmstate/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
hosts: all
vars:
edpm_network_config_tool: nmstate
network_provider: nm
network_state:
edpm_network_config_template: |
interfaces:
- name: dummy0
type: dummy
state: down
ipv4:
enabled: false
- name: dummy0
type: dummy
state: up
ipv4:
enabled: false
roles:
- role: "osp.edpm.edpm_network_config"
- role: osp.edpm.edpm_network_config
3 changes: 3 additions & 0 deletions roles/edpm_network_config/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
name: NetworkManager
state: restarted
when: nm_ovs_status.changed # noqa: no-handler
- name: Render network_config variable
ansible.builtin.set_fact:
network_state: "{{ edpm_network_config_template | from_yaml }}"
- name: Load system-roles.network tasks [nmstate]
ansible.builtin.include_role:
name: "{{ systemrolename }}"
Expand Down

0 comments on commit d81a86b

Please sign in to comment.