Skip to content

Commit 65e7456

Browse files
committed
refactor: support Ansible 2.19
The big problem was trying to use `vars` with `import_playbook`. We do not need to use `import_playbook` when `include_tasks` will work. Perhaps the original author of these tests thought that the play `roles` keyword was the only way to invoke roles, so that had to be "called" using an `import_playbook`? Use `include_tasks` instead of `import_playbook`, and move some of those "tasks" playbooks to be tasks files in tests/tasks. Use `include_role` instead of `import_role`. Do not set variables using `set_fact` if they have already been set at the appropriate scope using `vars`. "Modernize" the code somewhat. Improve formatting. Work around an Ansible bug ansible/ansible#85394 Fix ansible-lint and ansible-test issues related newer versions of those tools. Signed-off-by: Rich Megginson <[email protected]>
1 parent 14f9044 commit 65e7456

32 files changed

+285
-337
lines changed

.sanity-ansible-ignore-2.18.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugins/modules/network_connections.py validate-modules:missing-gplv3-license
2+
plugins/modules/network_state.py validate-modules:missing-gplv3-license
3+
tests/network/ensure_provider_tests.py shebang!skip

.sanity-ansible-ignore-2.19.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
plugins/modules/network_connections.py validate-modules:missing-gplv3-license
2+
plugins/modules/network_state.py validate-modules:missing-gplv3-license
3+
tests/network/ensure_provider_tests.py shebang!skip

examples/down_profile.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/network_state_example.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@
176176
network_state:
177177
routes:
178178
config:
179-
- destination: ::/0
180-
next-hop-interface: eth1
181-
next-hop-address: fe80::1
179+
- destination: ::/0
180+
next-hop-interface: eth1
181+
next-hop-address: fe80::1
182182
ansible.builtin.include_role:
183183
name: linux-system-roles.network
184184

185-
- name: Configure the ethernet device eth1 with dhcp4 configured
185+
- name: Configure the ethernet device eth1 with dhcp4 configured again
186186
vars:
187187
network_state:
188188
interfaces:

examples/remove+down_profile.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/remove_profile.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/get_coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
hidden: true
4646
register: files_to_delete
4747

48-
- name: Remove old data
48+
- name: Remove old data from files_to_delete
4949
file:
5050
path: "{{ item.path }}"
5151
state: absent

tests/playbooks/down_profile+delete_interface.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/playbooks/remove_profile.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/playbooks/tests_auto_gateway.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
# not take precedence over other routes or not ignore other
4040
# routes
4141
route_metric4: 65535
42-
- name: Include the task 'assert_device_present.yml'
42+
- name: Include the task 'assert_device_present.yml' again
4343
include_tasks: tasks/assert_device_present.yml
4444
- name: Include the task 'assert_profile_present.yml'
4545
include_tasks: tasks/assert_profile_present.yml
@@ -67,7 +67,7 @@
6767
- name: "TEARDOWN: remove profiles."
6868
debug:
6969
msg: "##################################################"
70-
- name: Import network role
70+
- name: Import network role to remove interface
7171
import_role:
7272
name: linux-system-roles.network
7373
vars:
@@ -76,19 +76,19 @@
7676
persistent_state: absent
7777
state: down
7878
ignore_errors: true # noqa ignore-errors
79-
- name: Include the task 'manage_test_interface.yml'
79+
- name: Include the task 'manage_test_interface.yml' to remove interface
8080
include_tasks: tasks/manage_test_interface.yml
8181
vars:
8282
state: absent
8383
- name: >-
8484
TEST: I can configure an interface with auto_gateway disabled
8585
debug:
8686
msg: "##################################################"
87-
- name: Include the task 'manage_test_interface.yml'
87+
- name: Include the task 'manage_test_interface.yml' to disable auto_gateway
8888
include_tasks: tasks/manage_test_interface.yml
8989
vars:
9090
state: present
91-
- name: Import network role
91+
- name: Import network role to disable auto_gateway
9292
import_role:
9393
name: linux-system-roles.network
9494
vars:
@@ -105,13 +105,13 @@
105105
- "203.0.113.2/24"
106106
gateway6: "2001:db8::1"
107107
gateway4: "203.0.113.1"
108-
- name: Include the task 'assert_device_present.yml'
108+
- name: Include the task 'assert_device_present.yml' - 3
109109
include_tasks: tasks/assert_device_present.yml
110-
- name: Include the task 'assert_profile_present.yml'
110+
- name: Include the task 'assert_profile_present.yml' again
111111
include_tasks: tasks/assert_profile_present.yml
112112
vars:
113113
profile: "{{ interface }}"
114-
- name: "Show ipv4 routes"
114+
- name: "Show ipv4 routes again"
115115
command: "ip route"
116116
register: ipv4_routes
117117
changed_when: false
@@ -120,7 +120,7 @@
120120
that: __test_str not in ipv4_routes.stdout
121121
vars:
122122
__test_str: default via 203.0.113.1 dev {{ interface }}
123-
- name: "Get ipv6 routes"
123+
- name: "Get ipv6 routes again"
124124
command: "ip -6 route"
125125
register: ipv6_route
126126
changed_when: false
@@ -130,10 +130,10 @@
130130
vars:
131131
__test_str: default via 2001:db8::1 dev {{ interface }}
132132
when: network_provider == "nm"
133-
- name: "TEARDOWN: remove profiles."
133+
- name: "TEARDOWN: remove profiles. again"
134134
debug:
135135
msg: "##################################################"
136-
- name: Import network role
136+
- name: Import network role to remove interface again
137137
import_role:
138138
name: linux-system-roles.network
139139
vars:
@@ -142,7 +142,7 @@
142142
persistent_state: absent
143143
state: down
144144
ignore_errors: true # noqa ignore-errors
145-
- name: Include the task 'manage_test_interface.yml'
145+
- name: Include the task 'manage_test_interface.yml' to remove interface again
146146
include_tasks: tasks/manage_test_interface.yml
147147
vars:
148148
state: absent

0 commit comments

Comments
 (0)