diff options
Diffstat (limited to 'tests/integration/targets/vyos_l3_interfaces')
11 files changed, 157 insertions, 137 deletions
diff --git a/tests/integration/targets/vyos_l3_interfaces/defaults/main.yaml b/tests/integration/targets/vyos_l3_interfaces/defaults/main.yaml index 164afea..852a6be 100644 --- a/tests/integration/targets/vyos_l3_interfaces/defaults/main.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/defaults/main.yaml @@ -1,3 +1,3 @@ --- -testcase: "[^_].*" +testcase: '[^_].*' test_items: [] diff --git a/tests/integration/targets/vyos_l3_interfaces/tasks/cli.yaml b/tests/integration/targets/vyos_l3_interfaces/tasks/cli.yaml index 337e341..f622cf9 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tasks/cli.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tasks/cli.yaml @@ -1,8 +1,8 @@ --- - name: Collect all cli test cases find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' use_regex: true register: test_cases delegate_to: localhost @@ -11,10 +11,10 @@ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" delegate_to: localhost -- name: Run test case (connection=network_cli) - include: "{{ test_case_to_run }}" +- name: Run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }}' vars: - ansible_connection: network_cli - with_items: "{{ test_items }}" + ansible_connection: ansible.netcommon.network_cli + with_items: '{{ test_items }}' loop_control: loop_var: test_case_to_run diff --git a/tests/integration/targets/vyos_l3_interfaces/tasks/main.yaml b/tests/integration/targets/vyos_l3_interfaces/tasks/main.yaml index d4cf26f..a3db933 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tasks/main.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tasks/main.yaml @@ -1,2 +1,4 @@ --- -- {include: cli.yaml, tags: ['cli']} +- include: cli.yaml + tags: + - cli diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml index d598c42..563b1d7 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml @@ -1,11 +1,9 @@ --- - name: Setup - network.cli.cli_config: - config: "{{ lines }}" vars: - lines: | - set interfaces ethernet eth1 address '192.0.2.14/24' - set interfaces ethernet eth2 address '192.0.2.10/24' - set interfaces ethernet eth2 address '192.0.2.11/24' - set interfaces ethernet eth2 address '2001:db8::10/32' - set interfaces ethernet eth2 address '2001:db8::12/32' + lines: "set interfaces ethernet eth1 address '192.0.2.14/24'\nset interfaces\ + \ ethernet eth2 address '192.0.2.10/24'\nset interfaces ethernet eth2 address\ + \ '192.0.2.11/24'\nset interfaces ethernet eth2 address '2001:db8::10/32'\n\ + set interfaces ethernet eth2 address '2001:db8::12/32'\n" + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml index 95b2b8c..1fb0dd3 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml @@ -1,13 +1,12 @@ --- - name: Remove Config - network.cli.cli_config: - config: "{{ lines }}" vars: - lines: | - delete interfaces ethernet "{{ intf }}" address - delete interfaces ethernet "{{ intf }}" vif + lines: "delete interfaces ethernet \"{{ intf }}\" address\ndelete interfaces\ + \ ethernet \"{{ intf }}\" vif\n" loop: - eth1 - eth2 loop_control: loop_var: intf + ansible.netcommon.cli_config: + config: '{{ lines }}' diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml index b95bcdb..ff4aabf 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml @@ -1,19 +1,23 @@ --- - debug: - msg: "Start vyos_interfaces deleted integration tests ansible_connection={{ ansible_connection }}" + msg: Start vyos_interfaces deleted integration tests ansible_connection={{ ansible_connection + }} - include_tasks: _remove_config.yaml - block: + - include_tasks: _populate.yaml - name: Delete attributes of given interfaces - vyos.vyos.vyos_l3_interfaces: &deleted + register: result + vyos.vyos.vyos_l3_interfaces: &id001 config: + - name: eth1 + - name: eth2 state: deleted - register: result - name: Assert that the before dicts were correctly generated assert: @@ -23,26 +27,29 @@ - name: Assert that the correct set of commands were generated assert: that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" + - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" - name: Assert that the after dicts were correctly generated assert: that: - - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}" + - "{{ deleted['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" - name: Delete attributes of given interfaces (IDEMPOTENT) - vyos.vyos.vyos_l3_interfaces: *deleted register: result + vyos.vyos.vyos_l3_interfaces: *id001 - name: Assert that the previous task was idempotent assert: that: - - "result.changed == false" + - result.changed == false - name: Assert that the before dicts were correctly generated assert: that: - - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}" - + - "{{ deleted['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml index 7b1f100..96d4cda 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml @@ -1,35 +1,36 @@ --- - debug: - msg: "START vyos_l3_interfaces empty_config integration tests on connection={{ ansible_connection }}" + msg: START vyos_l3_interfaces empty_config integration tests on connection={{ + ansible_connection }} - name: Merged with empty config should give appropriate error message + register: result + ignore_errors: true vyos.vyos.vyos_l3_interfaces: config: state: merged - register: result - ignore_errors: true - assert: that: - result.msg == 'value of config parameter must not be empty for state merged' - name: Replaced with empty config should give appropriate error message + register: result + ignore_errors: true vyos.vyos.vyos_l3_interfaces: config: state: replaced - register: result - ignore_errors: true - assert: that: - result.msg == 'value of config parameter must not be empty for state replaced' - name: Overridden with empty config should give appropriate error message + register: result + ignore_errors: true vyos.vyos.vyos_l3_interfaces: config: state: overridden - register: result - ignore_errors: true - assert: that: diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml index 1b3b9ea..99fb552 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml @@ -1,58 +1,72 @@ --- - debug: - msg: "START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection }}" + msg: START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection + }} - include_tasks: _remove_config.yaml - block: + - name: Merge the provided configuration with the exisiting running configuration - vyos.vyos.vyos_l3_interfaces: &merged + register: result + vyos.vyos.vyos_l3_interfaces: &id001 config: + - name: eth1 ipv4: + - address: 192.0.2.10/24 ipv6: + - address: 2001:db8::10/32 - name: eth2 ipv4: + - address: 198.51.100.10/24 vifs: + - vlan_id: 101 ipv4: + - address: 198.51.100.130/25 ipv6: + - address: 2001:db8::20/32 state: merged - register: result - name: Assert that before dicts were correctly generated assert: - that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" + that: "{{ merged['before'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" - name: Assert that correct set of commands were generated assert: that: - - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" + - "{{ merged['commands'] | symmetric_difference(result['commands']) |length\ + \ == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" + - "{{ merged['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" - - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) - vyos.vyos.vyos_l3_interfaces: *merged + - name: Merge the provided configuration with the existing running configuration + (IDEMPOTENT) register: result + vyos.vyos.vyos_l3_interfaces: *id001 - name: Assert that the previous task was idempotent assert: that: - - "result['changed'] == false" + - result['changed'] == false - name: Assert that before dicts were correctly generated assert: that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" - + - "{{ merged['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml index 06d6fc7..644fe08 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/overridden.yaml @@ -1,23 +1,29 @@ --- - debug: - msg: "START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection }}" + msg: START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection + }} - include_tasks: _remove_config.yaml - block: + - include_tasks: _populate.yaml - name: Overrides all device configuration with provided configuration - vyos.vyos.vyos_l3_interfaces: &overridden + register: result + vyos.vyos.vyos_l3_interfaces: &id001 config: + - name: eth0 ipv4: + - address: dhcp + - name: eth1 ipv4: - - address: "192.0.2.15/24" + + - address: 192.0.2.15/24 state: overridden - register: result - name: Assert that before dicts were correctly generated assert: @@ -27,26 +33,29 @@ - name: Assert that correct commands were generated assert: that: - - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" + - "{{ overridden['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" - name: Assert that after dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['after']) |length == 0 }}" + - "{{ overridden['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" - name: Overrides all device configuration with provided configurations (IDEMPOTENT) - vyos.vyos.vyos_l3_interfaces: *overridden register: result + vyos.vyos.vyos_l3_interfaces: *id001 - name: Assert that the previous task was idempotent assert: that: - - "result['changed'] == false" + - result['changed'] == false - name: Assert that before dicts were correctly generated assert: that: - - "{{ overridden['after'] | symmetric_difference(result['before']) |length == 0 }}" - + - "{{ overridden['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml index 6f1228a..2c664bb 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/replaced.yaml @@ -1,28 +1,35 @@ --- - debug: - msg: "START vyos_l3_interfaces replaced integration tests on connection={{ ansible_connection }}" + msg: START vyos_l3_interfaces replaced integration tests on connection={{ ansible_connection + }} - include_tasks: _remove_config.yaml - block: + - include_tasks: _populate.yaml - name: Replace device configurations of listed interfaces with provided configurations - vyos.vyos.vyos_l3_interfaces: &replaced + register: result + vyos.vyos.vyos_l3_interfaces: &id001 config: + - name: eth1 ipv4: + - address: 192.0.2.19/24 + - name: eth2 ipv6: + - address: 2001:db8::11/32 state: replaced - register: result - name: Assert that correct set of commands were generated assert: that: - - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" + - "{{ replaced['commands'] | symmetric_difference(result['commands'])\ + \ |length == 0 }}" - name: Assert that before dicts are correctly generated assert: @@ -32,21 +39,24 @@ - name: Assert that after dict is correctly generated assert: that: - - "{{ replaced['after'] | symmetric_difference(result['after']) |length == 0 }}" + - "{{ replaced['after'] | symmetric_difference(result['after']) |length\ + \ == 0 }}" - - name: Replace device configurations of listed interfaces with provided configurarions (IDEMPOTENT) - vyos.vyos.vyos_l3_interfaces: *replaced + - name: Replace device configurations of listed interfaces with provided configurarions + (IDEMPOTENT) register: result + vyos.vyos.vyos_l3_interfaces: *id001 - name: Assert that task was idempotent assert: that: - - "result['changed'] == false" + - result['changed'] == false - name: Assert that before dict is correctly generated assert: that: - - "{{ replaced['after'] | symmetric_difference(result['before']) |length == 0 }}" - + - "{{ replaced['after'] | symmetric_difference(result['before']) |length\ + \ == 0 }}" always: + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml b/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml index 1241763..ee329d3 100644 --- a/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml @@ -1,82 +1,68 @@ --- merged: before: - - name: "eth0" + - name: eth0 ipv4: - - address: "dhcp" - - - name: "eth1" - - - name: "eth2" - + - address: dhcp + - name: eth1 + - name: eth2 commands: - - "set interfaces ethernet eth1 address '192.0.2.10/24'" - - "set interfaces ethernet eth1 address '2001:db8::10/32'" - - "set interfaces ethernet eth2 address '198.51.100.10/24'" - - "set interfaces ethernet eth2 vif 101 address '198.51.100.130/25'" - - "set interfaces ethernet eth2 vif 101 address '2001:db8::20/32'" - + - set interfaces ethernet eth1 address '192.0.2.10/24' + - set interfaces ethernet eth1 address '2001:db8::10/32' + - set interfaces ethernet eth2 address '198.51.100.10/24' + - set interfaces ethernet eth2 vif 101 address '198.51.100.130/25' + - set interfaces ethernet eth2 vif 101 address '2001:db8::20/32' after: - - name: "eth0" + - name: eth0 ipv4: - - address: "dhcp" - - - name: "eth1" + - address: dhcp + - name: eth1 ipv4: - - address: "192.0.2.10/24" + - address: 192.0.2.10/24 ipv6: - - address: "2001:db8::10/32" - - - name: "eth2" + - address: 2001:db8::10/32 + - name: eth2 ipv4: - - address: "198.51.100.10/24" + - address: 198.51.100.10/24 vifs: - vlan_id: 101 ipv4: - - address: "198.51.100.130/25" + - address: 198.51.100.130/25 ipv6: - - address: "2001:db8::20/32" - + - address: 2001:db8::20/32 populate: - - name: "eth1" + - name: eth1 ipv4: - - address: "192.0.2.14/24" - - - name: "eth2" + - address: 192.0.2.14/24 + - name: eth2 ipv4: - - address: "192.0.2.10/24" - - address: "192.0.2.11/24" + - address: 192.0.2.10/24 + - address: 192.0.2.11/24 ipv6: - - address: "2001:db8::10/32" - - address: "2001:db8::12/32" - - - name: "eth0" + - address: 2001:db8::10/32 + - address: 2001:db8::12/32 + - name: eth0 ipv4: - - address: "dhcp" - + - address: dhcp replaced: commands: - - "delete interfaces ethernet eth2 address '192.0.2.10/24'" - - "delete interfaces ethernet eth2 address '192.0.2.11/24'" - - "delete interfaces ethernet eth2 address '2001:db8::10/32'" - - "delete interfaces ethernet eth2 address '2001:db8::12/32'" - - "set interfaces ethernet eth2 address '2001:db8::11/32'" - - "delete interfaces ethernet eth1 address '192.0.2.14/24'" - - "set interfaces ethernet eth1 address '192.0.2.19/24'" - + - delete interfaces ethernet eth2 address '192.0.2.10/24' + - delete interfaces ethernet eth2 address '192.0.2.11/24' + - delete interfaces ethernet eth2 address '2001:db8::10/32' + - delete interfaces ethernet eth2 address '2001:db8::12/32' + - set interfaces ethernet eth2 address '2001:db8::11/32' + - delete interfaces ethernet eth1 address '192.0.2.14/24' + - set interfaces ethernet eth1 address '192.0.2.19/24' after: - - name: "eth2" + - name: eth2 ipv6: - - address: "2001:db8::11/32" - - - name: "eth1" + - address: 2001:db8::11/32 + - name: eth1 ipv4: - - address: "192.0.2.19/24" - - - name: "eth0" + - address: 192.0.2.19/24 + - name: eth0 ipv4: - - address: "dhcp" - + - address: dhcp overridden: commands: - delete interfaces ethernet eth1 address '192.0.2.14/24' @@ -85,18 +71,14 @@ overridden: - delete interfaces ethernet eth2 address '192.0.2.11/24' - delete interfaces ethernet eth2 address '2001:db8::10/32' - delete interfaces ethernet eth2 address '2001:db8::12/32' - after: - - name: "eth0" + - name: eth0 ipv4: - - address: "dhcp" - - - name: "eth1" + - address: dhcp + - name: eth1 ipv4: - - address: "192.0.2.15/24" - - - name: "eth2" - + - address: 192.0.2.15/24 + - name: eth2 deleted: commands: - delete interfaces ethernet eth1 address '192.0.2.14/24' @@ -105,10 +87,8 @@ deleted: - delete interfaces ethernet eth2 address '2001:db8::10/32' - delete interfaces ethernet eth2 address '2001:db8::12/32' after: - - name: "eth0" + - name: eth0 ipv4: - - address: "dhcp" - - - name: "eth1" - - - name: "eth2" + - address: dhcp + - name: eth1 + - name: eth2 |