From ae8561de2a03ff05a6f543925fb3829c590e6260 Mon Sep 17 00:00:00 2001 From: "ansible-code-bot[bot]" <145416087+ansible-code-bot[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2024 06:07:55 +0000 Subject: [PATCH] Fix ansible-lint rule violations --- .config/ansible-lint.yml | 2 +- galaxy.yml | 6 +- roles/run/tasks/includes/configure.yaml | 2 +- roles/run/tasks/includes/deploy.yaml | 2 +- roles/run/tasks/includes/detect.yaml | 4 +- roles/run/tasks/includes/gather.yaml | 2 +- roles/run/tasks/includes/health_check.yaml | 4 +- .../run/tasks/includes/health_checks/eos.yaml | 2 +- .../run/tasks/includes/health_checks/ios.yaml | 2 +- .../tasks/includes/health_checks/iosxr.yaml | 2 +- .../tasks/includes/health_checks/junos.yaml | 3 +- .../tasks/includes/health_checks/nxos.yaml | 2 +- .../tasks/includes/health_checks/vyos.yaml | 2 +- roles/run/tasks/includes/list.yaml | 2 +- roles/run/tasks/includes/persist.yaml | 2 +- roles/run/tasks/includes/remediate.yaml | 4 +- roles/run/tasks/includes/resources.yaml | 10 +-- tests/bgp/roles/tests/tasks/health_check.yml | 21 +++--- .../bgp_deploy/includes/assertions.yaml | 2 - .../targets/bgp_deploy/tasks/_cleanup.yaml | 2 +- .../targets/bgp_deploy/tasks/main.yaml | 58 +++++++++++++++-- .../bgp_detect/includes/assertions.yaml | 2 - .../targets/bgp_detect/tasks/_cleanup.yaml | 2 +- .../targets/bgp_detect/tasks/main.yaml | 58 +++++++++++++++-- .../targets/bgp_gather/tasks/main.yaml | 4 +- .../bgp_health/includes/assertions.yaml | 2 - .../targets/bgp_health/tasks/_cleanup.yaml | 2 +- .../targets/bgp_health/tasks/main.yaml | 4 +- .../bgp_persist/includes/assertions.yaml | 2 - .../targets/bgp_persist/tasks/_cleanup.yaml | 2 +- .../targets/bgp_persist/tasks/main.yaml | 64 +++++++++++++++++-- .../bgp_remediate/includes/assertions.yaml | 2 - .../targets/bgp_remediate/tasks/_cleanup.yaml | 2 +- .../targets/bgp_remediate/tasks/main.yaml | 64 +++++++++++++++++-- 34 files changed, 269 insertions(+), 77 deletions(-) diff --git a/.config/ansible-lint.yml b/.config/ansible-lint.yml index ccb44f5..2bf59df 100644 --- a/.config/ansible-lint.yml +++ b/.config/ansible-lint.yml @@ -1,3 +1,3 @@ --- skip_list: - - var-naming[no-role-prefix] # this rule error out correct vars names for network validated content. + - var-naming[no-role-prefix] # this rule error out correct vars names for network validated content. diff --git a/galaxy.yml b/galaxy.yml index f924af0..57eed65 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -2,9 +2,9 @@ authors: - Rohit Thakur (rohitthakur2590) dependencies: - "ansible.netcommon": ">=6.0.0" - "ansible.utils": ">=3.0.0" - "ansible.scm": ">=2.0.0" + ansible.netcommon: ">=6.0.0" + ansible.utils: ">=3.0.0" + ansible.scm: ">=2.0.0" license_file: LICENSE name: bgp description: Ansible Network BGP enables users to manage the BGP resources independently of platforms and perform BGP health checks. diff --git a/roles/run/tasks/includes/configure.yaml b/roles/run/tasks/includes/configure.yaml index 5ed5f8d..a3464f9 100644 --- a/roles/run/tasks/includes/configure.yaml +++ b/roles/run/tasks/includes/configure.yaml @@ -3,4 +3,4 @@ ansible.builtin.include_role: name: network.base.resource_manager vars: - operation: 'configure' + operation: configure diff --git a/roles/run/tasks/includes/deploy.yaml b/roles/run/tasks/includes/deploy.yaml index 19beb88..4b5f82b 100644 --- a/roles/run/tasks/includes/deploy.yaml +++ b/roles/run/tasks/includes/deploy.yaml @@ -6,5 +6,5 @@ ansible.builtin.include_role: name: network.base.resource_manager vars: - operation: 'deploy' + operation: deploy resources: "{{ bgp_resources }}" diff --git a/roles/run/tasks/includes/detect.yaml b/roles/run/tasks/includes/detect.yaml index f87154a..4259211 100644 --- a/roles/run/tasks/includes/detect.yaml +++ b/roles/run/tasks/includes/detect.yaml @@ -6,6 +6,6 @@ ansible.builtin.include_role: name: network.base.resource_manager vars: - operation: 'detect' - state: 'replaced' + operation: detect + state: replaced resources: "{{ bgp_resources }}" diff --git a/roles/run/tasks/includes/gather.yaml b/roles/run/tasks/includes/gather.yaml index c441774..2549529 100644 --- a/roles/run/tasks/includes/gather.yaml +++ b/roles/run/tasks/includes/gather.yaml @@ -6,5 +6,5 @@ ansible.builtin.include_role: name: network.base.resource_manager vars: - operation: 'gather' + operation: gather resources: "{{ bgp_resources }}" diff --git a/roles/run/tasks/includes/health_check.yaml b/roles/run/tasks/includes/health_check.yaml index 77f1ce8..04cc16f 100644 --- a/roles/run/tasks/includes/health_check.yaml +++ b/roles/run/tasks/includes/health_check.yaml @@ -4,9 +4,9 @@ - name: Set health checks fact ansible.builtin.set_fact: - health_checks: "{{ bgp_health | network.bgp.health_check_view(operation) }}" + health_checks: "{{ bgp_health | network.bgp.health_check_view(operation) }}" - name: BGP health checks ansible.builtin.debug: - var: health_checks + var: health_checks failed_when: "'unsuccessful' == health_checks.status" diff --git a/roles/run/tasks/includes/health_checks/eos.yaml b/roles/run/tasks/includes/health_checks/eos.yaml index b71a087..0336c8d 100644 --- a/roles/run/tasks/includes/health_checks/eos.yaml +++ b/roles/run/tasks/includes/health_checks/eos.yaml @@ -1,7 +1,7 @@ --- - name: Parse bgp summary ansible.utils.cli_parse: - command: "show ip bgp summary" + command: show ip bgp summary parser: name: ansible.netcommon.content_templates set_fact: bgp_health diff --git a/roles/run/tasks/includes/health_checks/ios.yaml b/roles/run/tasks/includes/health_checks/ios.yaml index d2e66f2..3b3b27e 100644 --- a/roles/run/tasks/includes/health_checks/ios.yaml +++ b/roles/run/tasks/includes/health_checks/ios.yaml @@ -1,7 +1,7 @@ --- - name: Parse bgp summary ansible.utils.cli_parse: - command: "show bgp summary" + command: show bgp summary parser: name: ansible.netcommon.content_templates set_fact: bgp_health diff --git a/roles/run/tasks/includes/health_checks/iosxr.yaml b/roles/run/tasks/includes/health_checks/iosxr.yaml index d2e66f2..3b3b27e 100644 --- a/roles/run/tasks/includes/health_checks/iosxr.yaml +++ b/roles/run/tasks/includes/health_checks/iosxr.yaml @@ -1,7 +1,7 @@ --- - name: Parse bgp summary ansible.utils.cli_parse: - command: "show bgp summary" + command: show bgp summary parser: name: ansible.netcommon.content_templates set_fact: bgp_health diff --git a/roles/run/tasks/includes/health_checks/junos.yaml b/roles/run/tasks/includes/health_checks/junos.yaml index bf80e6c..42251a2 100644 --- a/roles/run/tasks/includes/health_checks/junos.yaml +++ b/roles/run/tasks/includes/health_checks/junos.yaml @@ -1,12 +1,11 @@ --- - name: Parse bgp summary ansible.utils.cli_parse: - command: "show bgp summary" + command: show bgp summary parser: name: ansible.netcommon.content_templates set_fact: bgp_health - - name: Show Summary facts ansible.builtin.debug: msg: "{{ bgp_health }}" diff --git a/roles/run/tasks/includes/health_checks/nxos.yaml b/roles/run/tasks/includes/health_checks/nxos.yaml index b71a087..0336c8d 100644 --- a/roles/run/tasks/includes/health_checks/nxos.yaml +++ b/roles/run/tasks/includes/health_checks/nxos.yaml @@ -1,7 +1,7 @@ --- - name: Parse bgp summary ansible.utils.cli_parse: - command: "show ip bgp summary" + command: show ip bgp summary parser: name: ansible.netcommon.content_templates set_fact: bgp_health diff --git a/roles/run/tasks/includes/health_checks/vyos.yaml b/roles/run/tasks/includes/health_checks/vyos.yaml index b71a087..0336c8d 100644 --- a/roles/run/tasks/includes/health_checks/vyos.yaml +++ b/roles/run/tasks/includes/health_checks/vyos.yaml @@ -1,7 +1,7 @@ --- - name: Parse bgp summary ansible.utils.cli_parse: - command: "show ip bgp summary" + command: show ip bgp summary parser: name: ansible.netcommon.content_templates set_fact: bgp_health diff --git a/roles/run/tasks/includes/list.yaml b/roles/run/tasks/includes/list.yaml index 03d5bd3..c794b39 100644 --- a/roles/run/tasks/includes/list.yaml +++ b/roles/run/tasks/includes/list.yaml @@ -3,4 +3,4 @@ ansible.builtin.include_role: name: network.base.resource_manager vars: - operation: 'list' + operation: list diff --git a/roles/run/tasks/includes/persist.yaml b/roles/run/tasks/includes/persist.yaml index c27e14f..a44eb28 100644 --- a/roles/run/tasks/includes/persist.yaml +++ b/roles/run/tasks/includes/persist.yaml @@ -6,6 +6,6 @@ ansible.builtin.include_role: name: network.base.resource_manager vars: - operation: 'persist' + operation: persist resources: "{{ bgp_resources }}" ignore_empty: "{{ persist_empty | default(true) }}" diff --git a/roles/run/tasks/includes/remediate.yaml b/roles/run/tasks/includes/remediate.yaml index 63a7aa2..406b0cc 100644 --- a/roles/run/tasks/includes/remediate.yaml +++ b/roles/run/tasks/includes/remediate.yaml @@ -6,6 +6,6 @@ ansible.builtin.include_role: name: network.base.resource_manager vars: - operation: 'remediate' - state: 'replaced' + operation: remediate + state: replaced resources: "{{ bgp_resources }}" diff --git a/roles/run/tasks/includes/resources.yaml b/roles/run/tasks/includes/resources.yaml index b0332cf..0dfda14 100644 --- a/roles/run/tasks/includes/resources.yaml +++ b/roles/run/tasks/includes/resources.yaml @@ -2,14 +2,14 @@ - name: Set resources ansible.builtin.set_fact: bgp_resources: - - 'bgp_global' - - 'bgp_address_family' - - 'bgp_neighbor_address_family' + - bgp_global + - bgp_address_family + - bgp_neighbor_address_family when: ansible_network_os == 'cisco.nxos.nxos' - name: Set resources ansible.builtin.set_fact: bgp_resources: - - 'bgp_global' - - 'bgp_address_family' + - bgp_global + - bgp_address_family when: ansible_network_os != 'cisco.nxos.nxos' diff --git a/tests/bgp/roles/tests/tasks/health_check.yml b/tests/bgp/roles/tests/tasks/health_check.yml index bd82c3c..67095fd 100644 --- a/tests/bgp/roles/tests/tasks/health_check.yml +++ b/tests/bgp/roles/tests/tasks/health_check.yml @@ -10,10 +10,10 @@ msg_rcvd: 73271 msg_sent: 73233 output_queue: 0 - peer: "12.0.0.1" + peer: 12.0.0.1 peer_as: 500 peer_state: 1 - uptime: "6w4d" + uptime: 6w4d version: 4 - bgp_table_version: 1 @@ -21,34 +21,33 @@ msg_rcvd: 0 msg_sent: 0 output_queue: 0 - peer: "23.0.0.1" + peer: 23.0.0.1 peer_as: 500 - peer_state: "Idle" - uptime: "never" + peer_state: Idle + uptime: never version: 4 path: memory_usage: 288 total_entries: 2 route_table_version: 3 - router_id: "22.0.0.1" + router_id: 22.0.0.1 - name: Vars ansible.builtin.set_fact: tests_item: - name: "health_check" + name: health_check vars: checks: - - name: "all_neighbors_up" - - name: "all_neighbors_down" - - name: "min_neighbors_up" + - name: all_neighbors_up + - name: all_neighbors_down + - name: min_neighbors_up min_count: 1 - name: Set BGP health facts ansible.builtin.set_fact: tests_health_checks: "{{ bgp_health | ansible.utils.health_check_view(tests_item) }}" - - name: Check for accurate facts ansible.builtin.assert: that: "{{ tests_health_checks == tests_expected_health_checks }}" diff --git a/tests/integration/targets/bgp_deploy/includes/assertions.yaml b/tests/integration/targets/bgp_deploy/includes/assertions.yaml index 17a82e7..7fc70ea 100644 --- a/tests/integration/targets/bgp_deploy/includes/assertions.yaml +++ b/tests/integration/targets/bgp_deploy/includes/assertions.yaml @@ -2,9 +2,7 @@ - name: Task name ansible.builtin.stat: path: "{{ test_data_store['local'] }}/host_vars/{{ inventory_hostname }}/{{ filename }}.yaml" - register: result - name: Assert that gather result ansible.builtin.assert: that: - - result.stat.exists == true diff --git a/tests/integration/targets/bgp_deploy/tasks/_cleanup.yaml b/tests/integration/targets/bgp_deploy/tasks/_cleanup.yaml index 1157d8f..eef7864 100644 --- a/tests/integration/targets/bgp_deploy/tasks/_cleanup.yaml +++ b/tests/integration/targets/bgp_deploy/tasks/_cleanup.yaml @@ -1,5 +1,5 @@ --- - name: Clean persist operation output ansible.builtin.file: - path: "~/test_backup" + path: ~/test_backup state: absent diff --git a/tests/integration/targets/bgp_deploy/tasks/main.yaml b/tests/integration/targets/bgp_deploy/tasks/main.yaml index 876dbe4..256b957 100644 --- a/tests/integration/targets/bgp_deploy/tasks/main.yaml +++ b/tests/integration/targets/bgp_deploy/tasks/main.yaml @@ -1,23 +1,71 @@ --- - name: Debug ansible.builtin.debug: - msg: "START network.bgp deploy opeartion integration tests on connection={{ ansible_connection }}" + msg: START network.bgp deploy opeartion integration tests on connection={{ ansible_connection }} - name: Cleanup, Read and Deploy block: - name: Reset configuration ansible.builtin.include_tasks: _cleanup.yaml +- name: Clean persist operation output + + block: + - name: Reset configuration + ansible.builtin.include_tasks: _cleanup.yaml + + - name: Set data data_store + ansible.builtin.set_fact: + test_data_store: + local: ~/test_backup + + - name: Set resources + ansible.builtin.set_fact: + test_resources: + - bgp_global + - bgp_address_family + + - name: Run network.bgp validated content with deploy operation + ansible.builtin.include_role: + name: network.bgp.run + vars: + operations: + - name: persist + data_store: "{{ test_data_store }}" + + - name: Run network.bgp validated content with deploy operation + ansible.builtin.include_role: + name: network.bgp.run + vars: + operations: + - name: deploy + data_store: "{{ test_data_store }}" + register: bgp_result + + - name: Assert that gresult + ansible.builtin.assert: + that: + - bgp_result.changed == false + + - name: Reset configuration + ansible.builtin.include_tasks: _cleanup.yaml + +- name: Clean persist operation output + + block: + - name: Reset configuration + ansible.builtin.include_tasks: _cleanup.yaml + - name: Set data data_store ansible.builtin.set_fact: test_data_store: - local: "~/test_backup" + local: ~/test_backup - name: Set resources ansible.builtin.set_fact: test_resources: - - 'bgp_global' - - 'bgp_address_family' + - bgp_global + - bgp_address_family - name: Run network.bgp validated content with deploy operation ansible.builtin.include_role: @@ -47,4 +95,4 @@ - name: Debug ansible.builtin.debug: - msg: "END network.bgp deploy operation integration tests on connection={{ ansible_connection }}" + msg: END network.bgp deploy operation integration tests on connection={{ ansible_connection }} diff --git a/tests/integration/targets/bgp_detect/includes/assertions.yaml b/tests/integration/targets/bgp_detect/includes/assertions.yaml index 17a82e7..7fc70ea 100644 --- a/tests/integration/targets/bgp_detect/includes/assertions.yaml +++ b/tests/integration/targets/bgp_detect/includes/assertions.yaml @@ -2,9 +2,7 @@ - name: Task name ansible.builtin.stat: path: "{{ test_data_store['local'] }}/host_vars/{{ inventory_hostname }}/{{ filename }}.yaml" - register: result - name: Assert that gather result ansible.builtin.assert: that: - - result.stat.exists == true diff --git a/tests/integration/targets/bgp_detect/tasks/_cleanup.yaml b/tests/integration/targets/bgp_detect/tasks/_cleanup.yaml index 1157d8f..eef7864 100644 --- a/tests/integration/targets/bgp_detect/tasks/_cleanup.yaml +++ b/tests/integration/targets/bgp_detect/tasks/_cleanup.yaml @@ -1,5 +1,5 @@ --- - name: Clean persist operation output ansible.builtin.file: - path: "~/test_backup" + path: ~/test_backup state: absent diff --git a/tests/integration/targets/bgp_detect/tasks/main.yaml b/tests/integration/targets/bgp_detect/tasks/main.yaml index f640efe..e0c6203 100644 --- a/tests/integration/targets/bgp_detect/tasks/main.yaml +++ b/tests/integration/targets/bgp_detect/tasks/main.yaml @@ -1,23 +1,71 @@ --- - name: Debug ansible.builtin.debug: - msg: "START network.bgp detect opeartion integration tests on connection={{ ansible_connection }}" + msg: START network.bgp detect opeartion integration tests on connection={{ ansible_connection }} - name: Cleanup, Read and Deploy block: - name: Reset configuration ansible.builtin.include_tasks: _cleanup.yaml +- name: Clean persist operation output + + block: + - name: Reset configuration + ansible.builtin.include_tasks: _cleanup.yaml + + - name: Set resources + ansible.builtin.set_fact: + test_resources: + - bgp_global + - bgp_address_family + + - name: Set data data_store + ansible.builtin.set_fact: + test_data_store: + local: ~/test_backup + + - name: Run network.bgp validated content persist operation + ansible.builtin.include_role: + name: network.bgp.run + vars: + operations: + - name: persist + data_store: "{{ test_data_store }}" + + - name: Run network.bgp validated content with detect operation + ansible.builtin.include_role: + name: network.bgp.run + vars: + operations: + - name: detect + data_store: "{{ test_data_store }}" + register: bgp_result + + - name: Assert that gresult + ansible.builtin.assert: + that: + - bgp_result.changed == false + + - name: Reset configuration + ansible.builtin.include_tasks: _cleanup.yaml + +- name: Clean persist operation output + + block: + - name: Reset configuration + ansible.builtin.include_tasks: _cleanup.yaml + - name: Set resources ansible.builtin.set_fact: test_resources: - - 'bgp_global' - - 'bgp_address_family' + - bgp_global + - bgp_address_family - name: Set data data_store ansible.builtin.set_fact: test_data_store: - local: "~/test_backup" + local: ~/test_backup - name: Run network.bgp validated content persist operation ansible.builtin.include_role: @@ -47,4 +95,4 @@ - name: Debug ansible.builtin.debug: - msg: "END network.bgp detect operation integration tests on connection={{ ansible_connection }}" + msg: END network.bgp detect operation integration tests on connection={{ ansible_connection }} diff --git a/tests/integration/targets/bgp_gather/tasks/main.yaml b/tests/integration/targets/bgp_gather/tasks/main.yaml index d8ac2bb..75b1ad7 100644 --- a/tests/integration/targets/bgp_gather/tasks/main.yaml +++ b/tests/integration/targets/bgp_gather/tasks/main.yaml @@ -1,7 +1,7 @@ --- - name: Debug ansible.builtin.debug: - msg: "START network.bgp gather opeartion integration tests on connection={{ ansible_connection }}" + msg: START network.bgp gather opeartion integration tests on connection={{ ansible_connection }} - name: Gather and assertion block: @@ -20,4 +20,4 @@ - name: Debug ansible.builtin.debug: - msg: "END network.bgp gahter opeartion integration tests on connection={{ ansible_connection }}" + msg: END network.bgp gahter opeartion integration tests on connection={{ ansible_connection }} diff --git a/tests/integration/targets/bgp_health/includes/assertions.yaml b/tests/integration/targets/bgp_health/includes/assertions.yaml index 17a82e7..7fc70ea 100644 --- a/tests/integration/targets/bgp_health/includes/assertions.yaml +++ b/tests/integration/targets/bgp_health/includes/assertions.yaml @@ -2,9 +2,7 @@ - name: Task name ansible.builtin.stat: path: "{{ test_data_store['local'] }}/host_vars/{{ inventory_hostname }}/{{ filename }}.yaml" - register: result - name: Assert that gather result ansible.builtin.assert: that: - - result.stat.exists == true diff --git a/tests/integration/targets/bgp_health/tasks/_cleanup.yaml b/tests/integration/targets/bgp_health/tasks/_cleanup.yaml index 1157d8f..eef7864 100644 --- a/tests/integration/targets/bgp_health/tasks/_cleanup.yaml +++ b/tests/integration/targets/bgp_health/tasks/_cleanup.yaml @@ -1,5 +1,5 @@ --- - name: Clean persist operation output ansible.builtin.file: - path: "~/test_backup" + path: ~/test_backup state: absent diff --git a/tests/integration/targets/bgp_health/tasks/main.yaml b/tests/integration/targets/bgp_health/tasks/main.yaml index c3918b1..e3c86a2 100644 --- a/tests/integration/targets/bgp_health/tasks/main.yaml +++ b/tests/integration/targets/bgp_health/tasks/main.yaml @@ -1,7 +1,7 @@ --- - name: Debug ansible.builtin.debug: - msg: "START network.bgp health_check opeartion integration tests on connection={{ ansible_connection }}" + msg: START network.bgp health_check opeartion integration tests on connection={{ ansible_connection }} - name: Perform health check on BGP protocol block: @@ -23,4 +23,4 @@ - name: Debug ansible.builtin.debug: - msg: "END network.bgp health_check opeartion integration tests on connection={{ ansible_connection }}" + msg: END network.bgp health_check opeartion integration tests on connection={{ ansible_connection }} diff --git a/tests/integration/targets/bgp_persist/includes/assertions.yaml b/tests/integration/targets/bgp_persist/includes/assertions.yaml index 17a82e7..7fc70ea 100644 --- a/tests/integration/targets/bgp_persist/includes/assertions.yaml +++ b/tests/integration/targets/bgp_persist/includes/assertions.yaml @@ -2,9 +2,7 @@ - name: Task name ansible.builtin.stat: path: "{{ test_data_store['local'] }}/host_vars/{{ inventory_hostname }}/{{ filename }}.yaml" - register: result - name: Assert that gather result ansible.builtin.assert: that: - - result.stat.exists == true diff --git a/tests/integration/targets/bgp_persist/tasks/_cleanup.yaml b/tests/integration/targets/bgp_persist/tasks/_cleanup.yaml index 1157d8f..eef7864 100644 --- a/tests/integration/targets/bgp_persist/tasks/_cleanup.yaml +++ b/tests/integration/targets/bgp_persist/tasks/_cleanup.yaml @@ -1,5 +1,5 @@ --- - name: Clean persist operation output ansible.builtin.file: - path: "~/test_backup" + path: ~/test_backup state: absent diff --git a/tests/integration/targets/bgp_persist/tasks/main.yaml b/tests/integration/targets/bgp_persist/tasks/main.yaml index 8e5bcc5..a585abb 100644 --- a/tests/integration/targets/bgp_persist/tasks/main.yaml +++ b/tests/integration/targets/bgp_persist/tasks/main.yaml @@ -1,23 +1,77 @@ --- - name: Debug ansible.builtin.debug: - msg: "START network.bgp persist opeartion integration tests on connection={{ ansible_connection }}" + msg: START network.bgp persist opeartion integration tests on connection={{ ansible_connection }} - name: Cleanup, gather and persist block: - name: Reset configuration ansible.builtin.include_tasks: _cleanup.yaml +- name: Clean persist operation output + + block: + - name: Reset configuration + ansible.builtin.include_tasks: _cleanup.yaml + + - name: Set resources + ansible.builtin.set_fact: + test_resources: + - bgp_global + - bgp_address_family + + - name: Set data data_store + ansible.builtin.set_fact: + test_data_store: + local: ~/test_backup + + - name: Run network.bgp validated content with persist operation + ansible.builtin.include_role: + name: network.bgp.run + vars: + operations: + - name: persist + data_store: "{{ test_data_store }}" + + - name: Assert file generations + ansible.builtin.include_tasks: includes/assertions.yaml + loop: "{{ test_resources }}" + loop_control: + loop_var: filename + + - name: Run network.bgp validated content with persist operation + ansible.builtin.include_role: + name: network.bgp.run + vars: + operations: + - name: deploy + data_store: "{{ test_data_store }}" + register: bgp_result + + - name: Assert that result + ansible.builtin.assert: + that: + - bgp_result.changed == false + + - name: Reset configuration + ansible.builtin.include_tasks: _cleanup.yaml + +- name: Clean persist operation output + + block: + - name: Reset configuration + ansible.builtin.include_tasks: _cleanup.yaml + - name: Set resources ansible.builtin.set_fact: test_resources: - - 'bgp_global' - - 'bgp_address_family' + - bgp_global + - bgp_address_family - name: Set data data_store ansible.builtin.set_fact: test_data_store: - local: "~/test_backup" + local: ~/test_backup - name: Run network.bgp validated content with persist operation ansible.builtin.include_role: @@ -53,4 +107,4 @@ - name: Debug ansible.builtin.debug: - msg: "END network.bgp persist opeartion integration tests on connection={{ ansible_connection }}" + msg: END network.bgp persist opeartion integration tests on connection={{ ansible_connection }} diff --git a/tests/integration/targets/bgp_remediate/includes/assertions.yaml b/tests/integration/targets/bgp_remediate/includes/assertions.yaml index 17a82e7..7fc70ea 100644 --- a/tests/integration/targets/bgp_remediate/includes/assertions.yaml +++ b/tests/integration/targets/bgp_remediate/includes/assertions.yaml @@ -2,9 +2,7 @@ - name: Task name ansible.builtin.stat: path: "{{ test_data_store['local'] }}/host_vars/{{ inventory_hostname }}/{{ filename }}.yaml" - register: result - name: Assert that gather result ansible.builtin.assert: that: - - result.stat.exists == true diff --git a/tests/integration/targets/bgp_remediate/tasks/_cleanup.yaml b/tests/integration/targets/bgp_remediate/tasks/_cleanup.yaml index 1157d8f..eef7864 100644 --- a/tests/integration/targets/bgp_remediate/tasks/_cleanup.yaml +++ b/tests/integration/targets/bgp_remediate/tasks/_cleanup.yaml @@ -1,5 +1,5 @@ --- - name: Clean persist operation output ansible.builtin.file: - path: "~/test_backup" + path: ~/test_backup state: absent diff --git a/tests/integration/targets/bgp_remediate/tasks/main.yaml b/tests/integration/targets/bgp_remediate/tasks/main.yaml index a73f5ab..8a87535 100644 --- a/tests/integration/targets/bgp_remediate/tasks/main.yaml +++ b/tests/integration/targets/bgp_remediate/tasks/main.yaml @@ -1,23 +1,77 @@ --- - name: Debug ansible.builtin.debug: - msg: "START network.bgp remediate opeartion integration tests on connection={{ ansible_connection }}" + msg: START network.bgp remediate opeartion integration tests on connection={{ ansible_connection }} - name: Cleanup, Set and remediate block: - name: Reset configuration ansible.builtin.include_tasks: _cleanup.yaml +- name: Clean persist operation output + + block: + - name: Reset configuration + ansible.builtin.include_tasks: _cleanup.yaml + + - name: Set resources + ansible.builtin.set_fact: + test_resources: + - bgp_global + - bgp_address_family + + - name: Set data data_store + ansible.builtin.set_fact: + test_data_store: + local: ~/test_backup + + - name: Run network.bgp validated content with persist operation + ansible.builtin.include_role: + name: network.bgp.run + vars: + operations: + - name: persist + data_store: "{{ test_data_store }}" + + - name: Assert file generations + ansible.builtin.include_tasks: includes/assertions.yaml + loop: "{{ test_resources }}" + loop_control: + loop_var: filename + + - name: Run network.bgp validated content with remediate operation + ansible.builtin.include_role: + name: network.bgp.run + vars: + operations: + - name: remediate + data_store: "{{ test_data_store }}" + register: bgp_result + + - name: Assert that result + ansible.builtin.assert: + that: + - bgp_result.changed == false + + - name: Reset configuration + ansible.builtin.include_tasks: _cleanup.yaml + +- name: Clean persist operation output + + block: + - name: Reset configuration + ansible.builtin.include_tasks: _cleanup.yaml + - name: Set resources ansible.builtin.set_fact: test_resources: - - 'bgp_global' - - 'bgp_address_family' + - bgp_global + - bgp_address_family - name: Set data data_store ansible.builtin.set_fact: test_data_store: - local: "~/test_backup" + local: ~/test_backup - name: Run network.bgp validated content with persist operation ansible.builtin.include_role: @@ -53,4 +107,4 @@ - name: Debug ansible.builtin.debug: - msg: "END network.bgp remediate opeartion integration tests on connection={{ ansible_connection }}" + msg: END network.bgp remediate opeartion integration tests on connection={{ ansible_connection }}