diff --git a/changelogs/fragments/tests_become.yaml b/changelogs/fragments/tests_become.yaml new file mode 100644 index 0000000..cc5f2bb --- /dev/null +++ b/changelogs/fragments/tests_become.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Remove ansible_become usage from integration testing. diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/deleted.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/deleted.yaml index 7fb8e10..3519172 100644 --- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/deleted.yaml @@ -1,49 +1,48 @@ --- - debug: msg: START vyos_bgp_address_family deleted integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: - name: Delete the provided configuration register: result vyos.vyos.vyos_bgp_address_family: &id001 config: as_number: "65536" address_family: - afi: "ipv6" neighbors: - neighbor_address: "203.0.113.5" - neighbor_address: "192.0.2.25" address_family: - afi: "ipv6" state: deleted - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: bgp_address_family - assert: that: - result.commands|length == 3 - result.changed == true - result.commands|symmetric_difference(deleted.commands) == [] - result.after == ansible_facts['network_resources']['bgp_address_family'] - name: Delete the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_bgp_address_family: *id001 - name: Assert that the previous task was idempotent assert: that: - result['changed'] == false always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/gathered.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/gathered.yaml index 7176a48..07c9ac3 100644 --- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/gathered.yaml @@ -1,24 +1,23 @@ --- - debug: msg: START vyos_bgp_address_family gathered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: - name: Gather config from the device in structured format. register: result vyos.vyos.vyos_bgp_address_family: state: gathered - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: bgp_address_family - assert: that: - result.changed == false - result.gathered == ansible_facts['network_resources']['bgp_address_family'] diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/merged.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/merged.yaml index f10b196..cf0f821 100644 --- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/merged.yaml @@ -1,69 +1,68 @@ --- - debug: msg: START vyos_bgp_address_family merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _preconfig.yaml - block: - name: Merge the provided configuration with the existing running configuration register: result vyos.vyos.vyos_bgp_address_family: &id001 config: as_number: "65536" address_family: - afi: "ipv6" redistribute: - protocol: "static" metric: 50 neighbors: - neighbor_address: "203.0.113.5" address_family: - afi: "ipv6" allowas_in: 4 attribute_unchanged: med: true default_originate: "map01" distribute_list: - action: "export" acl: 10 - neighbor_address: "192.0.2.25" address_family: - afi: "ipv6" maximum_prefix: 45 nexthop_self: true route_map: - action: "export" route_map: "map01" - action: "import" route_map: "map01" state: merged - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: bgp_address_family - assert: that: - result.commands|length == 9 - result.changed == true - result.commands|symmetric_difference(merged.commands) == [] - result.after == ansible_facts['network_resources']['bgp_address_family'] - result.before == {} - result.after == merged.after - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_bgp_address_family: *id001 - name: Assert that the previous task was idempotent assert: that: - result['changed'] == false always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/overridden.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/overridden.yaml index 77ba5b4..68dd47b 100644 --- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/overridden.yaml @@ -1,58 +1,57 @@ --- - debug: msg: START vyos_bgp_address_family overridden integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: - name: Replace the existing configuration with the provided running configuration register: result vyos.vyos.vyos_bgp_address_family: &id001 config: as_number: "65536" address_family: - afi: "ipv6" redistribute: - protocol: "static" metric: 50 neighbors: - neighbor_address: "203.0.113.5" address_family: - afi: "ipv6" allowas_in: 4 attribute_unchanged: med: true default_originate: "map01" distribute_list: - action: "export" acl: 10 state: overridden - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: bgp_address_family - assert: that: - result.commands|length == 10 - result.changed == true - result.commands|symmetric_difference(overridden.commands) == [] - result.after == ansible_facts['network_resources']['bgp_address_family'] - name: Replace the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_bgp_address_family: *id001 - name: Assert that the previous task was idempotent assert: that: - result['changed'] == false always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/parsed.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/parsed.yaml index d20684f..3176797 100644 --- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/parsed.yaml @@ -1,16 +1,15 @@ --- - debug: msg: START vyos_bgp_address_family parsed integration tests on connection={{ ansible_connection }} - name: Provide the running configuration for parsing (config to be parsed) - become: true register: result vyos.vyos.vyos_bgp_address_family: running_config: "{{ lookup('file', '_parsed_config.cfg') }}" state: parsed - assert: that: - result.changed == false - result.parsed == populate.config diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/replaced.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/replaced.yaml index 001c997..b4fe3db 100644 --- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/replaced.yaml @@ -1,58 +1,57 @@ --- - debug: msg: START vyos_bgp_address_family replaced integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: - name: Replace the existing configuration with the provided running configuration register: result vyos.vyos.vyos_bgp_address_family: &id001 config: as_number: "65536" address_family: - afi: "ipv6" redistribute: - protocol: "static" metric: 50 neighbors: - neighbor_address: "203.0.113.5" address_family: - afi: "ipv6" allowas_in: 4 attribute_unchanged: med: true default_originate: "map01" distribute_list: - action: "export" acl: 10 state: replaced - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: bgp_address_family - assert: that: - result.commands|length == 9 - result.changed == true - result.commands|symmetric_difference(replaced.commands) == [] - result.after == ansible_facts['network_resources']['bgp_address_family'] - name: Replace the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_bgp_address_family: *id001 - name: Assert that the previous task was idempotent assert: that: - result['changed'] == false always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/rtt.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/rtt.yaml index bb5aea1..e0c4131 100644 --- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/rtt.yaml @@ -1,87 +1,84 @@ --- - debug: msg: START vyos_bgp_address_family rtt integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _preconfig.yaml - block: - name: Merge the provided configuration with the existing running configuration register: baseconfig vyos.vyos.vyos_bgp_address_family: config: as_number: "65536" address_family: - afi: "ipv6" redistribute: - protocol: "static" metric: 50 neighbors: - neighbor_address: "203.0.113.5" address_family: - afi: "ipv6" allowas_in: 4 attribute_unchanged: med: true default_originate: "map01" distribute_list: - action: "export" acl: 10 - neighbor_address: "192.0.2.25" address_family: - afi: "ipv6" maximum_prefix: 45 nexthop_self: true route_map: - action: "export" route_map: "map01" - action: "import" route_map: "map01" state: merged - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: bgp_address_family - assert: that: - baseconfig.commands|length == 9 - baseconfig.changed == true - baseconfig.commands|symmetric_difference(merged.commands) == [] - baseconfig.after == ansible_facts['network_resources']['bgp_address_family'] - name: Apply the provided configuration (config to be reverted) - become: true register: result vyos.vyos.vyos_bgp_address_family: config: as_number: "65536" address_family: - afi: "ipv6" aggregate_address: - summary_only: true prefix: "21e0:1:1::/64" networks: - prefix: "21e0:1:1::/64" route_map: "map01" neighbors: - address_family: - afi: "ipv6" remove_private_as: true neighbor_address: "203.0.113.5" - name: Revert back to base config using facts round trip - become: true register: revert vyos.vyos.vyos_bgp_address_family: config: "{{ ansible_facts['network_resources']['bgp_address_family'] }}" state: overridden - name: Assert that config was reverted assert: that: baseconfig.after == revert.after always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/deleted.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/deleted.yaml index e1a7754..9c7400e 100644 --- a/tests/integration/targets/vyos_bgp_global/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_bgp_global/tests/cli/deleted.yaml @@ -1,42 +1,41 @@ --- - debug: msg: START vyos_bgp_global deleted integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: - name: Delete the provided configuration register: result vyos.vyos.vyos_bgp_global: &id001 config: as_number: "65536" state: deleted - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: bgp_global - assert: that: - result.commands|length == 9 - result.changed == true - result.commands|symmetric_difference(deleted.commands) == [] - result.after == ansible_facts['network_resources']['bgp_global'] - name: Delete the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_bgp_global: *id001 - name: Assert that the previous task was idempotent assert: that: - result['changed'] == false always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/gathered.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/gathered.yaml index 7ec1da8..2022533 100644 --- a/tests/integration/targets/vyos_bgp_global/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_bgp_global/tests/cli/gathered.yaml @@ -1,24 +1,23 @@ --- - debug: msg: START vyos_bgp_global gathered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: - name: Gather config from the device in structured format. register: result vyos.vyos.vyos_bgp_global: state: gathered - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: bgp_global - assert: that: - result.changed == false - result.gathered == ansible_facts['network_resources']['bgp_global'] diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/merged.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/merged.yaml index a398b7e..ce332a0 100644 --- a/tests/integration/targets/vyos_bgp_global/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_bgp_global/tests/cli/merged.yaml @@ -1,70 +1,69 @@ --- - debug: msg: START vyos_bgp_global merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _preconfig.yaml - block: - name: Merge the provided configuration with the existing running configuration register: result vyos.vyos.vyos_bgp_global: &id001 config: as_number: "65536" aggregate_address: - prefix: "203.0.113.0/24" as_set: true - prefix: "192.0.2.0/24" summary_only: true network: - address: "192.1.13.0/24" backdoor: true redistribute: - protocol: "kernel" metric: 45 - protocol: "connected" route_map: "map01" maximum_paths: - path: "ebgp" count: 20 - path: "ibgp" count: 55 timers: keepalive: 35 bgp_params: bestpath: as_path: "confed" compare_routerid: true default: no_ipv4_unicast: true router_id: "192.1.2.9" state: merged - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: bgp_global - assert: that: - result.commands|length == 12 - result.changed == true - result.commands|symmetric_difference(merged.commands) == [] - result.after == ansible_facts['network_resources']['bgp_global'] - result.before == {} - result.after == merged.after - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_bgp_global: *id001 - name: Assert that the previous task was idempotent assert: that: - result['changed'] == false always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/parsed.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/parsed.yaml index 419df6a..7c1665f 100644 --- a/tests/integration/targets/vyos_bgp_global/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_bgp_global/tests/cli/parsed.yaml @@ -1,16 +1,15 @@ --- - debug: msg: START vyos_bgp_global parsed integration tests on connection={{ ansible_connection }} - name: Provide the running configuration for parsing (config to be parsed) - become: true register: result vyos.vyos.vyos_bgp_global: running_config: "{{ lookup('file', '_parsed_config.cfg') }}" state: parsed - assert: that: - result.changed == false - result.parsed == populate.global diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/purged.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/purged.yaml index 9588e80..46346c2 100644 --- a/tests/integration/targets/vyos_bgp_global/tests/cli/purged.yaml +++ b/tests/integration/targets/vyos_bgp_global/tests/cli/purged.yaml @@ -1,32 +1,31 @@ --- - debug: msg: START vyos_bgp_global purged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: - name: Purge the provided configuration register: result vyos.vyos.vyos_bgp_global: &id001 config: as_number: "65536" state: purged - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: bgp_global - assert: that: - result.commands|length == 1 - result.changed == true - "'delete protocols bgp 65536' in result.commands" - ansible_facts.network_resources.bgp_global == [] always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/replaced.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/replaced.yaml index 2a8b407..f1b79b2 100644 --- a/tests/integration/targets/vyos_bgp_global/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_bgp_global/tests/cli/replaced.yaml @@ -1,72 +1,71 @@ --- - debug: msg: START vyos_bgp_global replaced integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: - name: Replace the existing configuration with the provided running configuration register: result vyos.vyos.vyos_bgp_global: &id001 config: as_number: "65536" network: - address: "203.0.113.0/24" route_map: map01 redistribute: - protocol: "static" route_map: "map01" bgp_params: always_compare_med: true dampening: start_suppress_time: 5 max_suppress_time: 20 half_life: 33 re_use: 60 bestpath: as_path: "confed" compare_routerid: true default: no_ipv4_unicast: true neighbor: - address: "192.0.2.43" disable_connected_check: true advertisement_interval: 72 capability: dynamic: true timers: holdtime: 30 keepalive: 10 - address: "203.0.113.0" capability: orf: "receive" state: replaced - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: bgp_global - assert: that: - result.commands|length == 24 - result.changed == true - result.commands|symmetric_difference(replaced.commands) == [] - result.after == ansible_facts['network_resources']['bgp_global'] - name: Replace the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_bgp_global: *id001 - name: Assert that the previous task was idempotent assert: that: - result['changed'] == false always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_config/tests/cli/backup.yaml b/tests/integration/targets/vyos_config/tests/cli/backup.yaml index ae59a0d..95fdd98 100644 --- a/tests/integration/targets/vyos_config/tests/cli/backup.yaml +++ b/tests/integration/targets/vyos_config/tests/cli/backup.yaml @@ -1,113 +1,110 @@ --- - debug: msg="START vyos/backup.yaml on connection={{ ansible_connection }}" - name: collect any backup files find: paths: '{{ role_path }}/backup' pattern: '{{ inventory_hostname_short }}_config*' register: backup_files connection: local - name: delete backup files file: path: '{{ item.path }}' state: absent with_items: '{{backup_files.files|default([])}}' - name: take configure backup register: result vyos.vyos.vyos_config: backup: true - assert: that: - result.changed == true - name: collect any backup files find: paths: '{{ role_path }}/backup' pattern: '{{ inventory_hostname_short }}_config*' register: backup_files connection: local - assert: that: - backup_files.files is defined - name: delete configurable backup file path file: path: '{{ item }}' state: absent with_items: - '{{ role_path }}/backup_test_dir/' - '{{ role_path }}/backup/backup.cfg' - name: take configuration backup in custom filename and directory path - become: true register: result vyos.vyos.vyos_config: backup: true backup_options: filename: backup.cfg dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' - assert: that: - result.changed == true - name: check if the backup file-1 exist find: paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg' register: backup_file connection: local - assert: that: - backup_file.files is defined - name: take configuration backup in custom filename - become: true register: result vyos.vyos.vyos_config: backup: true backup_options: filename: backup.cfg - assert: that: - result.changed == true - name: check if the backup file-2 exist find: paths: '{{ role_path }}/backup/backup.cfg' register: backup_file connection: local - assert: that: - backup_file.files is defined - name: take configuration backup in custom path and default filename - become: true register: result vyos.vyos.vyos_config: backup: true backup_options: dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' - assert: that: - result.changed == true - name: check if the backup file-3 exist find: paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' pattern: '{{ inventory_hostname_short }}_config*' register: backup_file connection: local - assert: that: - backup_file.files is defined - debug: msg="END vyos/backup.yaml on connection={{ ansible_connection }}" diff --git a/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml b/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml index 3880a04..516b835 100644 --- a/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml +++ b/tests/integration/targets/vyos_config/tests/cli_config/cli_backup.yaml @@ -1,114 +1,110 @@ --- - debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}" - name: delete configurable backup file path file: path: '{{ item }}' state: absent with_items: - '{{ role_path }}/backup_test_dir/' - '{{ role_path }}/backup/backup.cfg' - name: collect any backup files find: paths: '{{ role_path }}/backup' pattern: '{{ inventory_hostname_short }}_config*' register: backup_files connection: local - name: delete backup files file: path: '{{ item.path }}' state: absent with_items: '{{backup_files.files|default([])}}' - name: take config backup - become: true register: result ansible.netcommon.cli_config: backup: true - assert: that: - result.changed == true - name: collect any backup files find: paths: '{{ role_path }}/backup' pattern: '{{ inventory_hostname_short }}_config*' register: backup_files connection: local - assert: that: - backup_files.files is defined - name: take configuration backup in custom filename and directory path - become: true register: result ansible.netcommon.cli_config: backup: true backup_options: filename: backup.cfg dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' - assert: that: - result.changed == true - name: check if the backup file-1 exist find: paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}/backup.cfg' register: backup_file connection: local - assert: that: - backup_file.files is defined - name: take configuration backup in custom filename - become: true register: result ansible.netcommon.cli_config: backup: true backup_options: filename: backup.cfg - assert: that: - result.changed == true - name: check if the backup file-2 exist find: paths: '{{ role_path }}/backup/backup.cfg' register: backup_file connection: local - assert: that: - backup_file.files is defined - name: take configuration backup in custom path and default filename - become: true register: result ansible.netcommon.cli_config: backup: true backup_options: dir_path: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' - assert: that: - result.changed == true - name: check if the backup file-3 exist find: paths: '{{ role_path }}/backup_test_dir/{{ inventory_hostname_short }}' pattern: '{{ inventory_hostname_short }}_config*' register: backup_file connection: local - assert: that: - backup_file.files is defined - debug: msg="END cli_config/backup.yaml on connection={{ ansible_connection }}" diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml index 573e611..58cd9ff 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/deleted.yaml @@ -1,42 +1,41 @@ --- - debug: msg: START vyos_ospf_interfaces deleted integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: - name: Delete the provided configuration register: result vyos.vyos.vyos_ospf_interfaces: &id001 config: - name: "bond2" state: deleted - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: ospf_interfaces - assert: that: - result.commands|length == 2 - result.changed == true - result.commands|symmetric_difference(deleted.commands) == [] - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] - name: Delete the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_ospf_interfaces: *id001 - name: Assert that the previous task was idempotent assert: that: - result['changed'] == false always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/gathered.yaml index ec320c3..85a7cf2 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/gathered.yaml @@ -1,24 +1,23 @@ --- - debug: msg: START vyos_ospf_interfaces gathered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: - name: Gather config from the device in structured format. register: result vyos.vyos.vyos_ospf_interfaces: state: gathered - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: ospf_interfaces - assert: that: - result.changed == false - result.gathered|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml index fd88780..1dcbac6 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/merged.yaml @@ -1,52 +1,51 @@ --- - debug: msg: START vyos_ospf_interfaces merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - block: - name: Merge the provided configuration with the existing running configuration register: result vyos.vyos.vyos_ospf_interfaces: &id001 config: - name: "eth0" address_family: - afi: "ipv4" cost: 50 priority: 26 - afi: "ipv6" mtu_ignore: true instance: 33 - name: "bond2" address_family: - afi: "ipv4" transmit_delay: 45 - afi: "ipv6" passive: true state: merged - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: ospf_interfaces - assert: that: - result.commands|length == 6 - result.changed == true - result.commands|symmetric_difference(merged.commands) == [] - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_ospf_interfaces: *id001 - name: Assert that the previous task was idempotent assert: that: - result['changed'] == false always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml index 67bbca1..0db10d2 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/overridden.yaml @@ -1,49 +1,48 @@ --- - debug: msg: START vyos_ospf_interfaces overridden integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: - name: Override the existing configuration with the provided running configuration register: result vyos.vyos.vyos_ospf_interfaces: &id001 config: - name: "eth0" address_family: - afi: "ipv4" transmit_delay: 50 priority: 26 network: "point-to-point" - afi: "ipv6" dead_interval: 39 state: overridden - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: ospf_interfaces - assert: that: - result.commands|length == 8 - result.changed == true - result.commands|symmetric_difference(overridden.commands) == [] - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] - name: Override the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_ospf_interfaces: *id001 - name: Assert that the previous task was idempotent assert: that: - result['changed'] == false always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml index a065a00..4e327e1 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/parsed.yaml @@ -1,16 +1,15 @@ --- - debug: msg: START vyos_ospfv3_interfaces parsed integration tests on connection={{ ansible_connection }} - name: Provide the running configuration for parsing (config to be parsed) - become: true register: result vyos.vyos.vyos_ospf_interfaces: running_config: "{{ lookup('file', '_parsed.cfg') }}" state: parsed - assert: that: - result.changed == false - result.parsed|symmetric_difference(merged.after) == [] diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml index ff32012..a98b616 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/replaced.yaml @@ -1,60 +1,59 @@ --- - debug: msg: START vyos_ospf_interfaces replaced integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: - name: Replace the existing configuration with the provided running configuration register: result vyos.vyos.vyos_ospf_interfaces: &id001 config: - name: "eth0" address_family: - afi: "ipv4" transmit_delay: 50 priority: 26 network: "point-to-point" - afi: "ipv6" dead_interval: 39 - name: "bond2" address_family: - afi: "ipv4" transmit_delay: 45 bandwidth: 70 authentication: md5_key: key_id: 10 key: "1111111111232345" - afi: "ipv6" passive: true state: replaced - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: ospf_interfaces - assert: that: - result.commands|length == 8 - result.changed == true - result.commands|symmetric_difference(replaced.commands) == [] - result.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] - name: Replace the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_ospf_interfaces: *id001 - name: Assert that the previous task was idempotent assert: that: - result['changed'] == false always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml index 039d9f6..5f6374d 100644 --- a/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_ospf_interfaces/tests/cli/rtt.yaml @@ -1,66 +1,63 @@ --- - debug: msg: START vyos_ospf_interfaces rtt integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - block: - name: Merge the provided configuration with the existing running configuration register: baseconfig vyos.vyos.vyos_ospf_interfaces: &id001 config: - name: "eth0" address_family: - afi: "ipv4" cost: 50 priority: 26 - afi: "ipv6" mtu_ignore: true instance: 33 - name: "bond2" address_family: - afi: "ipv4" transmit_delay: 45 - afi: "ipv6" passive: true state: merged - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: ospf_interfaces - assert: that: - baseconfig.commands|length == 6 - baseconfig.changed == true - baseconfig.commands|symmetric_difference(merged.commands) == [] - baseconfig.after|symmetric_difference(ansible_facts['network_resources']['ospf_interfaces']) == [] - name: Apply the provided configuration (config to be reverted) - become: true register: result vyos.vyos.vyos_ospf_interfaces: config: - name: "eth0" address_family: - afi: "ipv4" transmit_delay: 50 priority: 26 network: "point-to-point" - afi: "ipv6" dead_interval: 39 - name: Revert back to base config using facts round trip - become: true register: revert vyos.vyos.vyos_ospf_interfaces: config: "{{ ansible_facts['network_resources']['ospf_interfaces'] }}" state: overridden - name: Assert that config was reverted assert: that: baseconfig.after == revert.after always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_route_maps/tests/cli/gathered.yaml b/tests/integration/targets/vyos_route_maps/tests/cli/gathered.yaml index b73fe23..356e975 100644 --- a/tests/integration/targets/vyos_route_maps/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_route_maps/tests/cli/gathered.yaml @@ -1,24 +1,23 @@ --- - debug: msg: START vyos_route_maps gathered integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: - name: Gather config from the device in structured format. register: result vyos.vyos.vyos_route_maps: state: gathered - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: route_maps - assert: that: - result.changed == false - result.gathered|symmetric_difference(ansible_facts['network_resources']['route_maps']) == [] diff --git a/tests/integration/targets/vyos_route_maps/tests/cli/merged.yaml b/tests/integration/targets/vyos_route_maps/tests/cli/merged.yaml index 4b5ad4c..d679800 100644 --- a/tests/integration/targets/vyos_route_maps/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_route_maps/tests/cli/merged.yaml @@ -1,65 +1,64 @@ --- - debug: msg: START vyos_route_maps merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - block: - name: Merge the provided configuration with the existing running configuration register: result vyos.vyos.vyos_route_maps: &id001 config: - route_map: test1 entries: - sequence: 1 description: "test" action: permit continue_sequence: 2 - route_map: test3 entries: - sequence: 1 action: permit match: metric: 1 peer: 192.0.2.32 set: local_preference: 4 metric: 5 metric_type: "type-1" origin: egp originator_id: 192.0.2.34 tag: 5 weight: 4 state: merged - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: route_maps - assert: that: - result.commands|length == 13 - result.changed == true - result.commands|symmetric_difference(merged.commands) == [] - result.after|symmetric_difference(ansible_facts['network_resources']['route_maps']) == [] - name: Assert that before dicts were correctly generated assert: that: - "{{ merged['before'] | symmetric_difference(result['before']) |length\ \ == 0 }}" - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_route_maps: *id001 - name: Assert that the previous task was idempotent assert: that: - result['changed'] == false always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_route_maps/tests/cli/overridden.yaml b/tests/integration/targets/vyos_route_maps/tests/cli/overridden.yaml index f014cf1..76971d6 100644 --- a/tests/integration/targets/vyos_route_maps/tests/cli/overridden.yaml +++ b/tests/integration/targets/vyos_route_maps/tests/cli/overridden.yaml @@ -1,56 +1,55 @@ --- - debug: msg: START vyos_route_maps overridden integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: - name: Override the existing configuration with the provided running configuration register: result vyos.vyos.vyos_route_maps: &id001 config: - route_map: test3 entries: - sequence: 1 action: permit match: metric: 3 peer: 192.0.2.35 set: local_preference: 6 metric: 4 metric_type: "type-1" origin: egp originator_id: 192.0.2.34 tag: 4 weight: 4 state: overridden - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: route_maps - assert: that: - result.commands|length == 8 - result.changed == true - result.commands|symmetric_difference(overridden.commands) == [] - result.after|symmetric_difference(ansible_facts['network_resources']['route_maps']) == [] - name: Override the existing configuration with the provided running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_route_maps: *id001 - name: Assert that the previous task was idempotent assert: that: - result['changed'] == false always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_route_maps/tests/cli/parsed.yaml b/tests/integration/targets/vyos_route_maps/tests/cli/parsed.yaml index 47cb4cc..ee76852 100644 --- a/tests/integration/targets/vyos_route_maps/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_route_maps/tests/cli/parsed.yaml @@ -1,16 +1,15 @@ --- - debug: msg: START vyos_route_maps parsed integration tests on connection={{ ansible_connection }} - name: Provide the running configuration for parsing (config to be parsed) - become: true register: result vyos.vyos.vyos_route_maps: running_config: "{{ lookup('file', '_parsed.cfg') }}" state: parsed - assert: that: - result.changed == false - result.parsed|symmetric_difference(merged.after) == [] diff --git a/tests/integration/targets/vyos_route_maps/tests/cli/replaced.yaml b/tests/integration/targets/vyos_route_maps/tests/cli/replaced.yaml index 893f563..fa0380b 100644 --- a/tests/integration/targets/vyos_route_maps/tests/cli/replaced.yaml +++ b/tests/integration/targets/vyos_route_maps/tests/cli/replaced.yaml @@ -1,55 +1,54 @@ --- - debug: msg: START vyos_route_maps replaced integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - include_tasks: _populate.yaml - block: - name: Replace the provided configuration with the existing running configuration register: result vyos.vyos.vyos_route_maps: &id001 config: - route_map: test3 entries: - sequence: 1 action: permit match: metric: 3 peer: 192.0.2.35 set: local_preference: 6 metric: 4 metric_type: "type-1" origin: egp originator_id: 192.0.2.34 tag: 4 weight: 4 state: replaced - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: route_maps - assert: that: - result.commands|length == 7 - result.changed == true - result.commands|symmetric_difference(replaced.commands) == [] - result.after|symmetric_difference(ansible_facts['network_resources']['route_maps']) == [] - name: Replace the provided configuration with the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_route_maps: *id001 - name: Assert that the previous task was idempotent assert: that: - result['changed'] == false always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_route_maps/tests/cli/rtt.yaml b/tests/integration/targets/vyos_route_maps/tests/cli/rtt.yaml index 5c54c23..6b1616b 100644 --- a/tests/integration/targets/vyos_route_maps/tests/cli/rtt.yaml +++ b/tests/integration/targets/vyos_route_maps/tests/cli/rtt.yaml @@ -1,79 +1,77 @@ --- - debug: msg: START vyos_route_maps merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - block: - name: Merge the provided configuration with the existing running configuration register: baseconfig vyos.vyos.vyos_route_maps: config: - route_map: test1 entries: - sequence: 1 description: "test" action: permit continue_sequence: 2 - route_map: test3 entries: - sequence: 1 action: permit match: metric: 1 peer: 192.0.2.32 set: local_preference: 4 metric: 5 metric_type: "type-1" origin: egp originator_id: 192.0.2.34 tag: 5 weight: 4 state: merged - - become: true - vyos.vyos.vyos_facts: + - vyos.vyos.vyos_facts: gather_network_resources: route_maps - assert: that: - baseconfig.commands|length == 13 - baseconfig.changed == true - baseconfig.commands|symmetric_difference(merged.commands) == [] - baseconfig.after|symmetric_difference(ansible_facts['network_resources']['route_maps']) == [] - name: Merge the existing configuration with the provided running configuration register: result vyos.vyos.vyos_route_maps: config: - route_map: test2 entries: - sequence: 1 action: permit match: metric: 3 peer: 192.0.2.35 set: local_preference: 6 metric: 4 metric_type: "type-1" origin: egp originator_id: 192.0.2.34 tag: 4 weight: 4 - name: Revert back to base config using facts round trip - become: true register: revert vyos.vyos.vyos_route_maps: config: "{{ ansible_facts['network_resources']['route_maps'] }}" state: overridden - name: Assert that config was reverted assert: that: baseconfig.after == revert.after always: - include_tasks: _remove_config.yaml