|
| 1 | +--- |
| 2 | +- name: "{{ test_id | upper }} Converge - cv_change_control_requested_state = pending approval" |
| 3 | + hosts: SITE1_FABRIC |
| 4 | + connection: local |
| 5 | + gather_facts: false |
| 6 | + vars: |
| 7 | + cv_server: "{{ lookup('env', 'CV_SERVER') }}" |
| 8 | + cv_token: "{{ lookup('env', 'CV_ACCESS_TOKEN') }}" |
| 9 | + proxy_host: "{{ lookup('env', 'CV_PROXY_HOST') | default('', true) }}" |
| 10 | + proxy_port: "{{ lookup('env', 'CV_PROXY_PORT') | default(3128, true) | int }}" |
| 11 | + proxy_username: "{{ lookup('env', 'CV_PROXY_USERNAME') | default('', true) }}" |
| 12 | + proxy_password: "{{ lookup('env', 'CV_PROXY_PASSWORD') | default('', true) }}" |
| 13 | + cv_verify_certs: "{{ lookup('env', 'CV_VERIFY_CERTS') | default(true, true) | bool }}" |
| 14 | + cv_skip_missing_devices: true |
| 15 | + eos_config_dir: "{{ playbook_dir }}/intended/configs/test_configs" |
| 16 | + structured_dir: "{{ playbook_dir }}/intended/structured_configs/test_configs" |
| 17 | + intended_tag_device: avd-ci-leaf1 |
| 18 | + intended_tags: "{{ lookup('file', structured_dir ~ '/' ~ intended_tag_device ~ '.yml')| from_yaml }}" |
| 19 | + test_id: "cc-requested-state-pending" |
| 20 | + cv_common_pattern: "avd_cv-deploy_{{ test_id }}" |
| 21 | + |
| 22 | + tasks: |
| 23 | + - name: "{{ test_id | upper }} Banner" |
| 24 | + tags: ["{{ test_id }}"] |
| 25 | + run_once: true |
| 26 | + ansible.builtin.debug: |
| 27 | + msg: |
| 28 | + - "{{ ('#' * (31 + test_id | length))[:100] }}" |
| 29 | + - "### STARTING MOLECULE TEST {{ test_id[:69] | upper }} ###" |
| 30 | + - "{{ ('#' * (31 + test_id | length))[:100] }}" |
| 31 | + |
| 32 | + - name: "{{ test_id | upper }} {{ 'Read' if lookup('env', 'MOLECULE_EXECUTION_ID') else 'Generate' }} molecule execution ID" |
| 33 | + tags: ["{{ test_id }}"] |
| 34 | + run_once: true |
| 35 | + ansible.builtin.set_fact: |
| 36 | + r: "{{ lookup('env', 'MOLECULE_EXECUTION_ID') or lookup('password', '/dev/null chars=ascii_lowercase,digits length=4') }}" |
| 37 | + |
| 38 | + - name: "{{ test_id | upper }} Code block to provision CVP with AVD configuration" |
| 39 | + tags: ["{{ test_id }}"] |
| 40 | + run_once: true |
| 41 | + delegate_to: localhost |
| 42 | + |
| 43 | + block: |
| 44 | + |
| 45 | + - name: "(BLOCK) {{ test_id | upper }} Banner" |
| 46 | + tags: ["{{ test_id }}"] |
| 47 | + run_once: true |
| 48 | + ansible.builtin.debug: |
| 49 | + msg: |
| 50 | + - "### ENGAGE CV_DEPLOY ROLE TO PUSH CONFIGURATION FOR {{ test_id[:69] | upper }} ###" |
| 51 | + |
| 52 | + - name: "(BLOCK) {{ test_id | upper }} Provision with cv_change_control_requested_state = pending approval" |
| 53 | + tags: ["{{ test_id }}"] |
| 54 | + run_once: true |
| 55 | + delegate_to: localhost |
| 56 | + ansible.builtin.import_role: |
| 57 | + name: arista.avd.cv_deploy |
| 58 | + vars: |
| 59 | + cv_workspace_name: "{{ cv_common_pattern }}_{{ r }}_converge" |
| 60 | + cv_workspace_description: "{{ (cv_common_pattern + '_' + r + '_converge') | upper }}" |
| 61 | + cv_change_control_name: "{{ cv_common_pattern }}_{{ r }}_converge" |
| 62 | + cv_change_control_description: "{{ (cv_common_pattern + '_' + r + '_converge') | upper }}" |
| 63 | + cv_register_detailed_results: true |
| 64 | + cv_submit_workspace_force: true |
| 65 | + # Should be ignored |
| 66 | + cv_run_change_control: true |
| 67 | + cv_change_control_requested_state: "pending approval" |
| 68 | + |
| 69 | + - name: "(BLOCK) {{ test_id | upper }} Check CVP returns" |
| 70 | + tags: ["{{ test_id }}"] |
| 71 | + run_once: true |
| 72 | + ansible.builtin.assert: |
| 73 | + that: |
| 74 | + # Workspace |
| 75 | + - cv_deploy_results.workspace.state == "submitted" |
| 76 | + # Change control |
| 77 | + - cv_deploy_results.change_control.name == cv_change_control_name |
| 78 | + - cv_deploy_results.change_control.description == cv_change_control_description |
| 79 | + - cv_deploy_results.change_control.requested_state == "pending approval" |
| 80 | + - cv_deploy_results.change_control.state == "pending approval" |
| 81 | + vars: |
| 82 | + cv_change_control_name: "{{ cv_common_pattern }}_{{ r }}_converge" |
| 83 | + cv_change_control_description: "{{ (cv_common_pattern + '_' + r + '_converge') | upper }}" |
| 84 | + |
| 85 | + always: |
| 86 | + |
| 87 | + - name: "(ALWAYS) {{ test_id | upper }} Display CVP detailed result" |
| 88 | + tags: ["{{ test_id }}"] |
| 89 | + run_once: true |
| 90 | + ansible.builtin.debug: |
| 91 | + var: cv_deploy_results |
| 92 | + |
| 93 | + - name: "(ALWAYS) {{ test_id | upper }} Cleanup orphan CC" |
| 94 | + tags: ["{{ test_id }}"] |
| 95 | + run_once: true |
| 96 | + ansible.legacy.uri: |
| 97 | + url: https://{{ cv_server }}/api/resources/changecontrol/v1/ChangeControlConfig?key.id={{ cv_deploy_results.change_control.id }} |
| 98 | + use_proxy: "{{ true if proxy_host and proxy_port else false }}" |
| 99 | + validate_certs: "{{ cv_verify_certs }}" |
| 100 | + return_content: true |
| 101 | + headers: |
| 102 | + Accept: "application/json" |
| 103 | + Content-Type: "application/json" |
| 104 | + Authorization: "Bearer {{ lookup('env', 'CV_ACCESS_TOKEN') }}" |
| 105 | + method: DELETE |
| 106 | + body_format: json |
| 107 | + force_basic_auth: true |
| 108 | + timeout: 10 |
| 109 | + register: cvp_abandon_cc_result |
| 110 | + until: cvp_abandon_cc_result.status == 200 |
| 111 | + retries: 3 |
| 112 | + delay: 3 |
| 113 | + ignore_errors: true |
| 114 | + when: cv_deploy_results.change_control.state | lower in ['pending approval', 'approved'] |
| 115 | + # Set HTTPS_PROXY environment variable scoped for this task only |
| 116 | + environment: |
| 117 | + https_proxy: >- |
| 118 | + http://{{ (proxy_username and proxy_password) | ternary(proxy_username ~ ':' ~ proxy_password ~ '@', '') }}{{ proxy_host }}:{{ proxy_port }} |
| 119 | +
|
| 120 | + - name: "(ALWAYS) {{ test_id | upper }} Banner" |
| 121 | + tags: ["{{ test_id }}"] |
| 122 | + run_once: true |
| 123 | + ansible.builtin.debug: |
| 124 | + msg: |
| 125 | + - "### ENGAGE CV_DEPLOY ROLE TO CLEANUP AFTER {{ test_id[:69] | upper }} ###" |
| 126 | + |
| 127 | + - name: "(ALWAYS) {{ test_id | upper }} Cleanup" |
| 128 | + tags: ["{{ test_id }}"] |
| 129 | + run_once: true |
| 130 | + delegate_to: localhost |
| 131 | + ansible.builtin.import_role: |
| 132 | + name: arista.avd.cv_deploy |
| 133 | + vars: |
| 134 | + cv_workspace_name: "{{ cv_common_pattern }}_{{ r }}_cleanup" |
| 135 | + cv_workspace_description: "{{ (cv_common_pattern + '_' + r + '_cleanup') | upper }}" |
| 136 | + cv_change_control_name: "{{ cv_common_pattern }}_{{ r }}_cleanup" |
| 137 | + cv_change_control_description: "{{ (cv_common_pattern + '_' + r + '_cleanup') | upper }}" |
| 138 | + cv_register_detailed_results: true |
| 139 | + cv_devices: "{{ ansible_play_hosts_all }}" |
| 140 | + eos_config_dir: "{{ playbook_dir }}/intended/configs/base_configs" |
| 141 | + structured_dir: "{{ playbook_dir }}/intended/structured_configs/base_configs" |
| 142 | + cv_submit_workspace_force: true |
| 143 | + cv_run_change_control: true |
0 commit comments