Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Test Checks for NDFC Connectivity & Authorization #145

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion roles/common_global/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
cisco.nac_dc_vxlan.dtc.verify_tags:
all_tags: "{{ nac_tags.all }}"
play_tags: "{{ ansible_run_tags }}"
tags: "{{ ansible_run_tags }}"
tags: "{{ ansible_run_tags }}"
6 changes: 6 additions & 0 deletions roles/validate/tasks/sub_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@
data_path: "{{ inventory_dir }}/host_vars/{{ inventory_hostname }}"
delegate_to: localhost

- name: Verify Connection to NDFC {{ ansible_host }} on Port {{ ansible_httpapi_port | default(443) }}
ansible.builtin.include_tasks: verify_ndfc_connectivity.yml

- name: Verify Authorization to NDFC {{ ansible_host }} on Port {{ ansible_httpapi_port | default(443) }}
ansible.builtin.include_tasks: verify_ndfc_authorization.yml

- name: Prepare Service Model
cisco.nac_dc_vxlan.common.prepare_service_model:
inventory_hostname: "{{ inventory_hostname }}"
Expand Down
28 changes: 28 additions & 0 deletions roles/validate/tasks/verify_ndfc_authorization.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---

- name: Verify Authorization to NDFC
block:
- name: Verify Authorization to NDFC {{ ansible_host }} on Port {{ ansible_httpapi_port | default(443) }}
ansible.builtin.uri:
url: "https://{{ ansible_host }}/login"
method: POST
headers:
Content-Type: "application/json"
body_format: json
body:
"domain": local
"userName": "{{ ansible_user }}"
"userPasswd": "{{ ansible_password }}"
status_code:
- 200
validate_certs: false
timeout: 30
register: response
# no_log: true
delegate_to: localhost
# when: ansible_user is defined and ansible_password is defined
rescue:
- name: Fail Play If NDFC Authorization Test Failed
ansible.builtin.fail:
msg: "NDFC authorization failed using specified ansible_user and ansible_password for https://{{ ansible_host }}:{{ ansible_httpapi_port | default(443) }}. Check NDFC credentials."
delegate_to: localhost
13 changes: 13 additions & 0 deletions roles/validate/tasks/verify_ndfc_connectivity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

- name: Verify Connection to NDFC {{ ansible_host }} on Port {{ ansible_httpapi_port | default(443) }}
ansible.builtin.wait_for:
host: "{{ ansible_host }}"
port: "{{ ansible_httpapi_port | default(443) }}"
connect_timeout: 5
delay: 0
sleep: 5
timeout: 30
state: started
msg: Timed out waiting to connect to NDFC at https://{{ ansible_host }}:{{ ansible_httpapi_port | default(443) }}. Check the NDFC is reachable from the Ansible Controller.
delegate_to: localhost