Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add templating support for nmstate defined networking configuration #249

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
23 changes: 14 additions & 9 deletions roles/edpm_network_config/molecule/nmstate/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@
- name: Converge
hosts: all
vars:
edpm_network_config_tool: nmstate
network_provider: nm
network_state:
# edpm_network_config - nmstate
edpm_network_config_tool: 'nmstate'
edpm_network_config_template: |
---
interfaces:
- name: dummy0
type: dummy
state: down
ipv4:
enabled: false
- name: dummy0
type: dummy
state: up
ipv4:
address:
- ip: 192.168.180.2
prefix-length: 24
dhcp: false
enabled: true
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_state 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