|
47 | 47 | - name: Include the task 'assert_output_in_stderr_without_warnings.yml' |
48 | 48 | include_tasks: tasks/assert_output_in_stderr_without_warnings.yml |
49 | 49 |
|
50 | | -# FIXME: assert profile present |
51 | | -# FIXME: assert profile/device up + IP address |
| 50 | + - name: Get NM connection file |
| 51 | + slurp: |
| 52 | + src: "/etc/NetworkManager/system-connections/{{ interface }}.nmconnection" |
| 53 | + register: nm_connection_file |
| 54 | + when: |
| 55 | + - network_provider == 'nm' |
| 56 | + # RHEL up to 8 uses initscripts backend |
| 57 | + - ansible_distribution_major_version | int >= 9 |
| 58 | + |
| 59 | + - name: Assert settings in NM connection file |
| 60 | + assert: |
| 61 | + that: |
| 62 | + - "('interface-name=' + interface) in nm_connection_file.content | b64decode" |
| 63 | + - "'type=ethernet' in nm_connection_file.content | b64decode" |
| 64 | + - "'address1=192.0.2.1/24' in nm_connection_file.content | b64decode" |
| 65 | + - "'method=manual' in nm_connection_file.content | b64decode" |
| 66 | + when: |
| 67 | + - network_provider == 'nm' |
| 68 | + # RHEL up to 8 uses initscripts backend |
| 69 | + - ansible_distribution_major_version | int >= 9 |
| 70 | + |
| 71 | + - name: Get NM connection status |
| 72 | + command: "nmcli connection show {{ interface }}" |
| 73 | + changed_when: false |
| 74 | + register: nm_connection_status |
| 75 | + when: network_provider == 'nm' |
| 76 | + |
| 77 | + - name: Assert NM connection status |
| 78 | + assert: |
| 79 | + that: |
| 80 | + - nm_connection_status.stdout | regex_search("ipv4.addresses:\s+192.0.2.1/24") |
| 81 | + when: network_provider == 'nm' |
| 82 | + |
| 83 | + - name: Get initscripts connection file |
| 84 | + slurp: |
| 85 | + src: "/etc/sysconfig/network-scripts/ifcfg-{{ interface }}" |
| 86 | + register: initscripts_connection_file |
| 87 | + when: network_provider == 'initscripts' or ansible_distribution_major_version | int < 9 |
| 88 | + |
| 89 | + - name: Assert settings in initscripts connection file |
| 90 | + assert: |
| 91 | + that: |
| 92 | + - "'TYPE=Ethernet' in initscripts_connection_file.content | b64decode" |
| 93 | + - "'DEVICE={{ interface }}' in initscripts_connection_file.content | b64decode" |
| 94 | + - "'IPADDR=192.0.2.1' in initscripts_connection_file.content | b64decode" |
| 95 | + - "'PREFIX=24' in initscripts_connection_file.content | b64decode" |
| 96 | + when: network_provider == 'initscripts' or ansible_distribution_major_version | int < 9 |
| 97 | + |
52 | 98 | - name: Import the playbook 'down_profile+delete_interface.yml' |
53 | 99 | import_playbook: down_profile+delete_interface.yml |
54 | 100 | vars: |
|
0 commit comments