Skip to content
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
91 changes: 66 additions & 25 deletions ansible/roles/network-nmstate/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,31 +132,72 @@

# TODO(gkoper): replace temporary nmcli profile zone sync with native
# zone handling in the nmstate filter/module path.
- name: Gather NetworkManager connection firewalld zones for nmstate interfaces
command:
argv:
- nmcli
- -g
- connection.zone
- connection
- show
- "{{ item.interface }}"
changed_when: false
loop: "{{ network_nmstate_zone_items }}"
register: network_nmstate_nm_zone_result

- name: Ensure NetworkManager connection firewalld zones are set for nmstate interfaces
command:
argv:
- nmcli
- connection
- modify
- "{{ item.item.interface }}"
- connection.zone
- "{{ item.item.zone }}"
loop: "{{ network_nmstate_nm_zone_result.results }}"
when:
- (item.stdout | default('') | trim) != item.item.zone
- name: Sync NetworkManager connection firewalld zones for nmstate interfaces
block:
# Cloud-init can create a profile whose ID is prefixed with
# "cloud-init", while its active device is still the nmstate interface.
# `nmcli connection show` accepts a profile UUID, so get the active
# profile UUID from the device before reading or updating its zone.
- name: Gather NetworkManager connection profiles for nmstate interfaces
command:
argv:
- nmcli
- -g
- GENERAL.CON-UUID
- device
- show
- "{{ zone_item.interface }}"
changed_when: false
loop: "{{ network_nmstate_zone_items }}"
loop_control:
loop_var: zone_item
label: "{{ zone_item.interface }}"
register: network_nmstate_nm_connection_result

- name: Validate NetworkManager connections for nmstate interfaces
ansible.builtin.assert:
that:
- (connection_item.stdout | trim) not in ['', '--']
fail_msg: >-
No active NetworkManager connection found for nmstate interface
{{ connection_item.zone_item.interface }}
loop: "{{ network_nmstate_nm_connection_result.results }}"
loop_control:
loop_var: connection_item
label: "{{ connection_item.zone_item.interface }}"

- name: Gather NetworkManager connection firewalld zones for nmstate interfaces
command:
argv:
- nmcli
- -g
- connection.zone
- connection
- show
- "{{ connection_item.stdout | trim }}"
changed_when: false
loop: "{{ network_nmstate_nm_connection_result.results }}"
loop_control:
loop_var: connection_item
label: "{{ connection_item.zone_item.interface }}"
register: network_nmstate_nm_zone_result

- name: Ensure NetworkManager connection firewalld zones are set for nmstate interfaces
command:
argv:
- nmcli
- connection
- modify
- "{{ zone_result.connection_item.stdout | trim }}"
- connection.zone
- "{{ zone_result.connection_item.zone_item.zone }}"
loop: "{{ network_nmstate_nm_zone_result.results }}"
loop_control:
loop_var: zone_result
label: "{{ zone_result.connection_item.zone_item.interface }}"
when:
- (zone_result.stdout | default('') | trim) != zone_result.connection_item.zone_item.zone
when: not ansible_check_mode

# Keep permanent firewalld configuration in sync first. Runtime state is
# refreshed separately below from permanent config.
Expand Down
2 changes: 1 addition & 1 deletion playbooks/kayobe-infra-vm-base/overrides.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ infra_vm_memory_mb: "{{ 1 * 1024 }}"
{% if infra_vm_use_cirros | default(true) %}
# Use cirros rather than distribution cloud image for the VM.
infra_vm_bootstrap_user: cirros
infra_vm_root_image: /opt/cache/files/cirros-0.5.3-x86_64-disk.img
infra_vm_root_image: https://download.cirros-cloud.net/0.5.3/cirros-0.5.3-x86_64-disk.img

# Cirros doesn't load cdom drivers by default.
vm_configdrive_device: disk
Expand Down
2 changes: 1 addition & 1 deletion playbooks/kayobe-seed-vm-base/overrides.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ seed_vm_memory_mb: "{{ 1 * 1024 }}"
{% if seed_vm_use_cirros | default(true) %}
# Use cirros rather than distribution cloud image for the VM.
seed_bootstrap_user: cirros
seed_vm_root_image: /opt/cache/files/cirros-0.5.3-x86_64-disk.img
seed_vm_root_image: https://download.cirros-cloud.net/0.5.3/cirros-0.5.3-x86_64-disk.img

# Cirros doesn't load cdom drivers by default.
seed_vm_configdrive_device: disk
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
fixes:
- |
Fixes the nmstate network engine when cloud-init creates a
NetworkManager connection whose profile ID differs from the interface
name (`LP#2165006 <https://bugs.launchpad.net/kayobe/+bug/2165006>`__).
Firewalld zone synchronisation now resolves the active profile from the
interface before reading or updating its connection zone.