diff --git a/CTL1-EXT-PRDSW-001_base-ansible.txt b/CTL1-EXT-PRDSW-001_base-ansible.txt deleted file mode 100644 index d58848145..000000000 --- a/CTL1-EXT-PRDSW-001_base-ansible.txt +++ /dev/null @@ -1,40 +0,0 @@ -! Configured from Ansible Playbook device.demo -! -hostname CTL1-EXT-PRDSW-001 -! -ip routing -! -! Build Management VRF if not default -vrf definition MGMNT - description ManagementVRF - rd 64900:00001 -exit -! -no ip routing vrf MGMNT -ip route vrf MGMNT 0.0.0.0/0 192.168.30.1 -! -! Build Management Config -! -management api http-commands -protocol unix-socket - cors allowed-origin all - no shutdown -vrf MGMNT - no shutdown - exit -! -interface Management 1 -description CTL1-EXT-PRDSW-001-MGMNT - vrf forwarding MGMNT - ip address 192.168.30.117/24 -exit -! -! Create Spanning Tree Config -! Configure SpanningTree from the start in case of loops -spanning-tree mode MSTP -spanning-tree portfast bpduguard default -spanning-tree priority 49152 -! -! Virtual MAC for vARP -ip virtual-router mac-address 00:1C:73:ee:01:01 -! \ No newline at end of file diff --git a/ansible_Configlet_cvp_server_1.txt b/ansible_Configlet_cvp_server_1.txt deleted file mode 100644 index edd9195c0..000000000 --- a/ansible_Configlet_cvp_server_1.txt +++ /dev/null @@ -1 +0,0 @@ -! This is a dynamic test configlet for cvpserver-1 diff --git a/ansible_Configlet_cvp_server_2.txt b/ansible_Configlet_cvp_server_2.txt deleted file mode 100644 index faa2a429d..000000000 --- a/ansible_Configlet_cvp_server_2.txt +++ /dev/null @@ -1 +0,0 @@ -! This is a dynamic test configlet for cvpserver-2 diff --git a/playbook.configlet.test.yaml b/playbook.configlet.test.yaml deleted file mode 100644 index 00ade0f16..000000000 --- a/playbook.configlet.test.yaml +++ /dev/null @@ -1,59 +0,0 @@ ---- -- name: Test cv_configlet_v2 - hosts: cvp_servers - connection: local - gather_facts: no - collections: - - arista.cvp - vars: - configlet_list: - ansible_Test_Configlet: "! This is a Very First Testing Configlet\n! it has no affect on the Device \n!\ninterface loopback 999\n description Test Interface_1\n ip address 192.168.99.99/32\n no shutdown\nexit" - # New_Configlet_2: "! This is a Testing Configlet\n! it has no affect on the Device\n!\ninterface loopback 998\n description Test Interface_2\n ip address 192.168.99.98/32\n no shutdown\nexit" - ansible_Test_DYNAMIC_Configlet: "{{ lookup('file', 'templates/ansible_Configlet_'+inventory_hostname+'.txt') }}" - - change_configlet_list: - ansible_Test_Configlet: "! This is a Very First Testing Configlet\n! it has no affect on the Device but has been changed again\n!\ninterface loopback 999\n description Test Interface_1.1\n ip address 192.168.99.98/32\n no shutdown\nexit" - # New_Configlet_2: "! This is a Testing Configlet\n! it has no affect on the Device\n!\ninterface loopback 998\n description Test Interface_2\n ip address 192.168.99.98/32\n no shutdown\nexit" - - tasks: - - name: 'Collecting facts from CVP {{inventory_hostname}}.' - tags: - - always - cv_facts: - register: cvp_facts - - - name: 'Create configlets on CVP {{inventory_hostname}}.' - tags: - - provision - cv_configlet: - cvp_facts: "{{cvp_facts.ansible_facts}}" - configlets: "{{configlet_list}}" - configlet_filter: ["New", "ansible"] - register: cvp_configlet - - - name: 'Change configlets on CVP {{inventory_hostname}}.' - tags: - - change - cv_configlet: - cvp_facts: "{{cvp_facts.ansible_facts}}" - configlets: "{{change_configlet_list}}" - configlet_filter: ["ansible"] - register: cvp_configlet - - - name: 'Delete configlets on CVP {{inventory_hostname}}.' - tags: - - delete - cv_configlet: - cvp_facts: "{{cvp_facts.ansible_facts}}" - configlets: "{{configlet_list}}" - configlet_filter: ["ansible"] - state: "absent" - register: cvp_configlet - - - name: 'CVP configlets status on {{inventory_hostname}}' - tags: - - provision - - change - - delete - debug: - var: cvp_configlet diff --git a/playbook.container.test.yaml b/playbook.container.test.yaml deleted file mode 100644 index 54b56e8aa..000000000 --- a/playbook.container.test.yaml +++ /dev/null @@ -1,161 +0,0 @@ ---- -- name: Playbook to validate and demonstrate cv_container module. - debugger: on_failed - hosts: cvp_servers - connection: local - gather_facts: no - collections: - - arista.cvp - vars: - verbose: False - containers_cleanup: - CTL1_TempTest: - parent_container: Arista_CTL1 - staging: - parent_container: CTL1_TempTest - devices: - - CTL1-EXT-PRDSW-001 - - containers_provision: - CTL1_TempTest: - parent_container: Arista_CTL1 - Fabric: - parent_container: CTL1_TempTest - Spines: - parent_container: Fabric - Leaves: - parent_container: Fabric - configlets: - - ansible_Configlet_1 - devices: - - CTL1-EXT-PRDSW-001 - - ROOM02: - parent_container: CTL1_TempTest - ROOM02_Spines: - parent_container: ROOM02 - configlets: - - ansible_Configlet_2 - ROOM02_Leaves: - parent_container: ROOM02 - - container_delete: - CTL1_TempTest: - parent_container: Arista_CTL1 - ROOM02: - parent_container: CTL1_TempTest - ROOM02_Spines: - parent_container: ROOM02 - ROOM02_Leaves: - parent_container: ROOM02 - - tasks: - - name: "Gather CVP facts from {{inventory_hostname}}" - cv_facts: - register: cvp_facts - tags: - - always - - - name: "RUN01 - Build Container topology on {{inventory_hostname}}" - tags: - - provision - - never - cv_container: - topology: '{{containers_provision}}' - cvp_facts: '{{cvp_facts.ansible_facts}}' - #save_topology: true - mode: 'merge' - register: cv_container - - - name: "RUN01 - Display cv_container outputs" - tags: - - provision - - never - debug: - msg: "{{cv_container}}" - - - name: "RUN01 - Check if Leaves container exists" - tags: - - provision - - never - cv_facts: - register: cvp_facts - - - name: "RUN01 - Check if Leaves container exists" - tags: - - provision - assert: - that: - - "cvp_facts.ansible_facts['containers'] | selectattr(search_key,'equalto',search_val) | list | count > 0" - fail_msg: "Leaves container has not been found in facts" - success_msg: "Leaves container has been found as expected" - vars: - search_key: name - search_val: Leaves - - - name: "RUN02 - Delete Container topology on {{inventory_hostname}}" - tags: - - delete - cv_container: - topology: '{{container_delete}}' - cvp_facts: '{{cvp_facts.ansible_facts}}' - mode: 'delete' - #save_topology: true - register: cv_container - - - name: "RUN02 - Check if ROOM02 container exists" - tags: - - delete - - never - cv_facts: - register: cvp_facts_delete - - - name: "RUN02 - Check if ROOM02 container exists" - tags: - - delete - - never - assert: - that: - - "cvp_facts_delete.ansible_facts['containers'] | selectattr(search_key,'equalto',search_val) | list | count < 0" - success_msg: "ROOM02 container has not been found in facts as expected" - fail_msg: "ROOM02 container has been found in facts" - vars: - search_key: name - search_val: ROOM02 - - - name: "RUN03 - Cleanup Container topology on {{inventory_hostname}}" - tags: - - never - - cleanup - cv_container: - topology: '{{containers_cleanup}}' - cvp_facts: '{{cvp_facts.ansible_facts}}' - mode: 'override' - register: cv_container - - - name: "RUN03 - Display cv_container outputs" - tags: - - cleanup - debug: - msg: "{{cv_container}}" - - - - name: "RUN03 - Gather CVP facts from {{inventory_hostname}}" - cv_facts: - register: cvp_facts - tags: - - never - - cleanup - - - name: "RUN03 - Check if Leaves container has been removed" - tags: - - never - - cleanup - assert: - that: - - "cvp_facts.ansible_facts['containers'] | selectattr(search_key,'equalto',search_val) | list | count == 0" - fail_msg: "Leaves container has been found in facts" - success_msg: "Leaves container has not been found as expected" - vars: - search_key: name - search_val: Leaves diff --git a/playbook.device.test.yaml b/playbook.device.test.yaml deleted file mode 100644 index 8ae0860f6..000000000 --- a/playbook.device.test.yaml +++ /dev/null @@ -1,94 +0,0 @@ ---- -- name: Test cv_device - hosts: cvp_servers - connection: local - gather_facts: no - collections: - - arista.cvp - vars: - configlet_list: - ansible_device_test01: "alias a{{ 999 | random }} show version" - ansible_device_test02: "alias a{{ 999 | random }} show version" - CTL1-EXT-PRDSW-001_base-ansible: "{{ lookup('file', 'templates/CTL1-EXT-PRDSW-001_base-ansible.txt') }}" - # Device inventory for provision activity: bind configlet - devices_inventory: - CTL1-EXT-PRDSW-001: - name: CTL1-EXT-PRDSW-001 - configlets: - - ansible_device_test01 - - CTL1-EXT-PRDSW-001_base-ansible - parentContainerName: "provision" - imageBundle: "" - # Device inventory for rollback activity: unbind configlet - devices_inventory_rollback: - CTL1-EXT-PRDSW-001: - name: CTL1-EXT-PRDSW-001 - configlets: - - CTL1-EXT-PRDSW-001_base-ansible - - tasks: - # Collect CVP Facts as init process - - name: "Gather CVP facts from {{inventory_hostname}}" - cv_facts: - register: cvp_facts - tags: - - always - -################################################### -### Provision -################################################### - - - name: 'Create configlets on CVP {{inventory_hostname}}.' - tags: - - provision - cv_configlet: - cvp_facts: "{{cvp_facts.ansible_facts}}" - configlets: "{{configlet_list}}" - configlet_filter: ["ansible"] - register: cvp_configlet - - - name: "Configure devices on {{inventory_hostname}}" - tags: - - provision - cv_device: - devices: "{{devices_inventory}}" - cvp_facts: '{{cvp_facts.ansible_facts}}' - device_filter: ['PRDSW'] - register: cvp_device - -################################################### -### Cleanup -################################################### - - - name: "Rollback configlet on devices on {{inventory_hostname}}" - tags: - - cleanup - cv_device: - devices: "{{devices_inventory_rollback}}" - cvp_facts: '{{cvp_facts.ansible_facts}}' - device_filter: ['PRDSW'] - register: cvp_device - -################################################### -### Reset -################################################### - - - name: "Reset devices on {{inventory_hostname}}" - tags: - - reset - cv_device: - devices: "{{devices_inventory_rollback}}" - cvp_facts: '{{cvp_facts.ansible_facts}}' - device_filter: ['PRDSW'] - state: "absent" - register: cvp_device - -################################################### -### Show Result -################################################### - - - name: Display cv_device - tags: - - always - debug: - msg: "{{cvp_device}}" diff --git a/playbook.facts.device.yaml b/playbook.facts.device.yaml deleted file mode 100644 index 7bb029ec4..000000000 --- a/playbook.facts.device.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- -- name: Get devices for cv_facts module. - hosts: cvp_servers - connection: local - gather_facts: no - collections: - - arista.cvp - vars: - - verbose: False - - deviceFilter: "CTL1-EXT-PRDSW-001" - tasks: - - name: "Gather CVP facts {{inventory_hostname}}" - cv_facts: - facts: - devices - register: cv_facts_devices - - - name: "Print out facts from CVP" - debug: - msg: "{{item}}" - with_items: - - "{{cv_facts_devices.ansible_facts}}" - \ No newline at end of file diff --git a/playbook.facts.test.yaml b/playbook.facts.test.yaml deleted file mode 100644 index 8afa493d7..000000000 --- a/playbook.facts.test.yaml +++ /dev/null @@ -1,79 +0,0 @@ ---- -- name: Test and validation for cv_facts module. - hosts: cvp_servers - connection: local - gather_facts: no - collections: - - arista.cvp - vars: - - verbose: False - - cloudvision_topology: - configlets: - - configletName: ansible_Configlet_test01 - data: "{{playbook_dir}}/templates/configlet1.txt" - - configletName: ansible_Configlet_test02 - data: "{{playbook_dir}}/templates/configlet2.txt" - devices: - - CTL1-PRD-SLEAF-001 - tasks: - - name: "Gather CVP facts {{inventory_hostname}}" - cv_facts: - register: cv_facts - - - name: "Print out facts from CVP" - debug: - msg: "{{cv_facts}}" - when: verbose|bool - - - name: "Check facts have expected lists" - assert: - that: - - "'configlets' in cv_facts.ansible_facts" - - "'devices' in cv_facts.ansible_facts" - - "'containers' in cv_facts.ansible_facts" - - "'imageBundles' in cv_facts.ansible_facts" - - "'tasks' in cv_facts.ansible_facts" - fail_msg: "'ansible_facts do not have expected lists" - success_msg: "ansible_facts have all expected list from CVP" - - - name: "Check containers facts " - assert: - that: - - "{{ cv_facts.ansible_facts['containers'] | length }} >1" - fail_msg: "Facts from CVP do not return any container. (>=2 are expected)" - success_msg: "Facts from CVP return more than 1 container as expected" - - - name: "Check if undefined container exists" - assert: - that: - - "cv_facts.ansible_facts['containers'] | selectattr(search_key,'equalto',search_val) | list | count > 0" - fail_msg: "Undefined_container has not been found in facts" - success_msg: "undefined_container has been found as expected" - vars: - search_key: key - search_val: undefined_container - - - name: "Check configlets facts " - assert: - that: - - "{{ cv_facts.ansible_facts['configlets'] | length }} >0" - fail_msg: "Facts from CVP do not return any configlets. (>=1 are expected)" - success_msg: "Facts from CVP return more than 1 configlets as expected" - - - name: "Gather running Configs for Devices" - cv_facts: - gather_subset: - config - facts: - devices - register: cv_facts_config - - - name: "Check for Running Config from in Device Data" - assert: - that: - - "{{item.config | length }} >0" - fail_msg: "Running Config for {{item.hostname}}: NOT FOUND" - success_msg: "Running Config for {{item.hostname}}: FOUND" - with_items: - - "{{cv_facts_config.ansible_facts['devices']}}" - #when: item.hostname in cloudvision_topology.devices \ No newline at end of file diff --git a/playbook.tasks.test.yaml b/playbook.tasks.test.yaml deleted file mode 100644 index 489c015f6..000000000 --- a/playbook.tasks.test.yaml +++ /dev/null @@ -1,112 +0,0 @@ ---- -- name: Test cv_task_v2 - hosts: cvp_servers - connection: local - gather_facts: no - collections: - - arista.cvp - tasks: - - - name: 'RUN 1: Collect initial facts' - tags: - - always - cv_facts: - register: cvp_facts - - - name: 'RUN 1: Apply configlets' - tags: - - provision - cv_configlet: - cvp_facts: "{{cvp_facts.ansible_facts}}" - configlets: "{{configlet_list}}" - configlet_filter: ["ansible"] - register: cvp_configlets - vars: - configlet_list: - ansible_Configlet_1: "alias a{{ 999 | random }} show version" - ansible_Configlet_2: "alias a{{ 999 | random }} show version" - - - name: 'RUN 1: Execute tasks registered in the previous task' - tags: - - provision - cv_task: - tasks: "{{ cvp_configlets.data.tasks }}" - register: cvp_tasks - - - name: 'RUN 1: Verify tasks have been changed' - assert: - that: - - "cvp_tasks.data|length == cvp_configlets.data.tasks|length" - - - name: 'RUN 2: Collect initial facts' - tags: - - always - cv_facts: - register: cvp_facts - - - - name: 'RUN 2: Apply configlets' - tags: - - provision - cv_configlet: - cvp_facts: "{{cvp_facts.ansible_facts}}" - configlets: "{{configlet_list}}" - configlet_filter: ["ansible"] - register: cvp_configlets - vars: - configlet_list: - ansible_Configlet_1: "alias a{{ 999 | random }} show version" - ansible_Configlet_2: "alias a{{ 999 | random }} show version" - - - name: 'RUN 2: Cancel tasks' - tags: - - provision - cv_task: - tasks: "{{ cvp_configlets.data.tasks }}" - state: cancelled - register: cvp_tasks - - - name: 'RUN 2: Verify tasks have been changed' - assert: - that: - - "cvp_tasks.data|length == cvp_configlets.data.tasks|length" - - - - name: 'RUN 3: Collect initial facts' - tags: - - always - cv_facts: - register: cvp_facts - - - name: 'RUN 3: Apply configlets' - tags: - - provision - cv_configlet: - cvp_facts: "{{cvp_facts.ansible_facts}}" - configlets: "{{configlet_list}}" - configlet_filter: ["ansible"] - notify: - - update cvp facts - vars: - configlet_list: - ansible_Configlet_1: "alias a{{ 999 | random }} show version" - ansible_Configlet_2: "alias a{{ 999 | random }} show version" - - - meta: flush_handlers - - - name: 'RUN 3: Execute all pending tasks and wait for completion for 60 seconds' - tags: - - provision - cv_task: - tasks: "{{ tasks }}" - wait: 60 - register: cvp_tasks - - - name: 'RUN 3: Verify tasks have been changed' - assert: - that: - - "cvp_tasks.data|length == cvp_configlets.data.tasks|length" - - handlers: - - name: update cvp facts - cv_facts: