diff --git a/ansible_collections/arista/avd/molecule/deploy_to_cv/converge.yml b/ansible_collections/arista/avd/molecule/deploy_to_cv/converge.yml index 579b8c80a9f..8b256db9ec9 100644 --- a/ansible_collections/arista/avd/molecule/deploy_to_cv/converge.yml +++ b/ansible_collections/arista/avd/molecule/deploy_to_cv/converge.yml @@ -28,138 +28,138 @@ # TODO: change cc stage to `running`, get CC state from cvp and assert tasks: - # - name: Test = Provision CVP with AVD configuration - # run_once: true - # delegate_to: localhost - # arista.avd.deploy_to_cv: - # configuration_dir: "{{ configuration_dir }}" - # structured_config_dir: "{{ structured_config_dir }}" - # # structured_config_suffix: "yml" - # # device_list: "{{ ansible_play_hosts }}" - # device_list: ["s1-leaf1", "s1-leaf2", "s1-leaf3", "s1-leaf4", "s1-spine1", "s1-spine2"] - # # device_list: ["s1-leaf1"] - # strict_tags: true - # # skip_missing_devices: false - # # configlet_name_template: "AVD-${hostname}" - # cv_servers: [ '{{ cv_server }}' ] - # cv_token: '{{ token }}' - # # cv_verify_certs: True - # workspace: - # name: '{{ ws_name }}' - # description: '{{ ws_description }}' - # id: '{{ ws_name }}' - # requested_state: '{{ ws_req_state }}' - # force: '{{ ws_force }}' - # change_control: - # name: '{{ cc_name }}' - # description: '{{ cc_desctiption }}' - # requested_state: '{{ cc_requested_state }}' - # # timeouts: - # # workspace_build_timeout: 300.0 - # # change_control_creation_timeout: 300.0 - # return_details: true - # register: CVP_RESULTS - - # - name: 'Display CVP result' - # run_once: true - # debug: - # msg: '{{CVP_RESULTS}}' - - # - name: check CVP returns - # ansible.builtin.assert: - # that: - # # workspace - # - CVP_RESULTS.workspace.name == ws_name - # - CVP_RESULTS.workspace.final_state == CVP_RESULTS.workspace.requested_state - # - CVP_RESULTS.workspace.final_state - # # errors and warnings - # - CVP_RESULTS.errors == [] - # # tags - # - CVP_RESULTS.deployed_device_tags != [] - # - CVP_RESULTS.deployed_interface_tags != [] - # # Change control - # - CVP_RESULTS.change_control.id == cc_id - # - CVP_RESULTS.change_control.name == cc_name - # - CVP_RESULTS.change_control.requested_state == cc_requested_state - # - CVP_RESULTS.change_control.description == cc_desctiption - - # - name: check tags from output - # ansible.builtin.assert: - # that: - # - item.0.label == item.1.label - # - item.0.value == item.1.value - # loop: "{{ CVP_RESULTS.deployed_device_tags | zip(CVP_RESULTS.device_tags) | list }}" - - # - name: get workspace information - # delegate_to: localhost - # run_once: true - # ansible.builtin.uri: - # url: '{{ ws_url }}' - # return_content: true - # validate_certs: false - # headers: - # Cookie: "access_token={{ token }}" - # method: POST - # body_format: json - # body: - # key: - # workspace_id: '{{ ws_name }}' - # configlet_id: '{{ item }}' - # loop: - # - "avd-s1-leaf1" - # - "avd-s1-leaf2" - # - "avd-s1-leaf3" - # - "avd-s1-leaf4" - # register: result - - # # CC information - # - name: get CC information - # delegate_to: localhost - # run_once: true - # ansible.builtin.uri: - # url: '{{ cc_url }}' - # return_content: true - # validate_certs: false - # headers: - # Cookie: "access_token={{ token }}" - # method: POST - # body_format: json - # body: - # key: - # id: '{{ cc_id }}' - # register: CC_INFO - # until: CC_INFO.json[0].value.status == "CHANGE_CONTROL_STATUS_COMPLETED" - # retries: 5 - # delay: 30 + - name: Test = Provision CVP with AVD configuration + run_once: true + delegate_to: localhost + arista.avd.deploy_to_cv: + configuration_dir: "{{ configuration_dir }}" + structured_config_dir: "{{ structured_config_dir }}" + # structured_config_suffix: "yml" + # device_list: "{{ ansible_play_hosts }}" + device_list: ["s1-leaf1", "s1-leaf2", "s1-leaf3", "s1-leaf4", "s1-spine1", "s1-spine2"] + # device_list: ["s1-leaf1"] + strict_tags: true + # skip_missing_devices: false + # configlet_name_template: "AVD-${hostname}" + cv_servers: [ '{{ cv_server }}' ] + cv_token: '{{ token }}' + # cv_verify_certs: True + workspace: + name: '{{ ws_name }}' + description: '{{ ws_description }}' + id: '{{ ws_name }}' + requested_state: '{{ ws_req_state }}' + force: '{{ ws_force }}' + change_control: + name: '{{ cc_name }}' + description: '{{ cc_desctiption }}' + requested_state: '{{ cc_requested_state }}' + # timeouts: + # workspace_build_timeout: 300.0 + # change_control_creation_timeout: 300.0 + return_details: true + register: CVP_RESULTS + + - name: 'Display CVP result' + run_once: true + debug: + msg: '{{CVP_RESULTS}}' - # - name: 'Display CC result' - # run_once: true - # debug: - # msg: '{{ CC_INFO.json[0].value.status }}' + - name: check CVP returns + ansible.builtin.assert: + that: + # workspace + - CVP_RESULTS.workspace.name == ws_name + - CVP_RESULTS.workspace.final_state == CVP_RESULTS.workspace.requested_state + - CVP_RESULTS.workspace.final_state + # errors and warnings + - CVP_RESULTS.errors == [] + # tags + - CVP_RESULTS.deployed_device_tags != [] + - CVP_RESULTS.deployed_interface_tags != [] + # Change control + - CVP_RESULTS.change_control.id == cc_id + - CVP_RESULTS.change_control.name == cc_name + - CVP_RESULTS.change_control.requested_state == cc_requested_state + - CVP_RESULTS.change_control.description == cc_desctiption + + - name: check tags from output + ansible.builtin.assert: + that: + - item.0.label == item.1.label + - item.0.value == item.1.value + loop: "{{ CVP_RESULTS.deployed_device_tags | zip(CVP_RESULTS.device_tags) | list }}" - # - name: 'Set configlets facts' - # run_once: true - # vars: - # configs: ['{{ configuration_dir }}/s1-leaf1.cfg', - # '{{ configuration_dir }}/s1-leaf2.cfg', - # '{{ configuration_dir }}/s1-leaf3.cfg', - # '{{ configuration_dir }}/s1-leaf4.cfg' - # ] - # set_fact: - # response_configlet: "{{ response_configlet | default({}) | combine({item.0.json[0].value.body | trim: item.1}) }}" - # loop: "{{ result.results | zip(configs) | list }}" - - # - name: check configlets - # ansible.builtin.assert: - # that: - # - item.key == lookup('file', item.value) - # loop: "{{ response_configlet | dict2items }}" + - name: get workspace information + delegate_to: localhost + run_once: true + ansible.builtin.uri: + url: '{{ ws_url }}' + return_content: true + validate_certs: false + headers: + Cookie: "access_token={{ token }}" + method: POST + body_format: json + body: + key: + workspace_id: '{{ ws_name }}' + configlet_id: '{{ item }}' + loop: + - "avd-s1-leaf1" + - "avd-s1-leaf2" + - "avd-s1-leaf3" + - "avd-s1-leaf4" + register: result + + # CC information + - name: get CC information + delegate_to: localhost + run_once: true + ansible.builtin.uri: + url: '{{ cc_url }}' + return_content: true + validate_certs: false + headers: + Cookie: "access_token={{ token }}" + method: POST + body_format: json + body: + key: + id: '{{ cc_id }}' + register: CC_INFO + until: CC_INFO.json[0].value.status == "CHANGE_CONTROL_STATUS_COMPLETED" + retries: 5 + delay: 30 - - name: 'Display intended tags' + - name: 'Display CC result' run_once: true debug: - msg: '{{ item }}' - loop: '{{ intended_tags.metadata.cv_tags.interface_tags }}' + msg: '{{ CC_INFO.json[0].value.status }}' + + - name: 'Set configlets facts' + run_once: true + vars: + configs: ['{{ configuration_dir }}/s1-leaf1.cfg', + '{{ configuration_dir }}/s1-leaf2.cfg', + '{{ configuration_dir }}/s1-leaf3.cfg', + '{{ configuration_dir }}/s1-leaf4.cfg' + ] + set_fact: + response_configlet: "{{ response_configlet | default({}) | combine({item.0.json[0].value.body | trim: item.1}) }}" + loop: "{{ result.results | zip(configs) | list }}" + + - name: check configlets + ansible.builtin.assert: + that: + - item.key == lookup('file', item.value) + loop: "{{ response_configlet | dict2items }}" + + # - name: 'Display intended tags' + # run_once: true + # debug: + # msg: '{{ item }}' + # loop: '{{ intended_tags.metadata.cv_tags.interface_tags }}' - name: Get Device Tag information delegate_to: localhost