Skip to content

Commit

Permalink
Dump instance detail during on test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealHaoLiu committed May 21, 2024
1 parent cc1e7de commit 37a9df3
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion molecule/default/tasks/awx_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@
controller_username: admin
controller_password: "{{ admin_pw_secret.resources[0].data.password | b64decode }}"

- name: TEST inject failure
fail:
msg: "TEST inject failure"

rescue:
- name: Create debug output directory
ansible.builtin.file:
Expand All @@ -163,7 +167,7 @@
dest: "{{ debug_output_dir }}/job_lists.json"
when: store_debug_output | default(false)

- name: Get all job and project details
- name: Get all job and project_update details
uri:
url: "http://localhost{{ endpoint }}"
user: admin
Expand All @@ -181,6 +185,38 @@
dest: "{{ debug_output_dir }}/job_details.json"
when: store_debug_output | default(false)

- name: Get list of instances
uri:
url: "http://localhost/awx/api/v2/instances"
user: admin
password: "{{ admin_pw_secret.resources[0].data.password | b64decode }}"
force_basic_auth: yes
register: instances_list

- name: Store instance_list debug output
copy:
content: "{{ instances_list | to_nice_json }}"
dest: "{{ debug_output_dir }}/instances_list.json"
when: store_debug_output | default(false)

- name: Get instances detail
uri:
url: "http://localhost{{ item }}"
user: admin
password: "{{ admin_pw_secret.resources[0].data.password | b64decode }}"
force_basic_auth: yes
loop: |
{{ instances_list.results | map(attribute='json') | map(attribute='results') | flatten | map(attribute='url') }}
loop_control:
loop_var: item
register: instances_details

- name: Store instances_details debug output
copy:
content: "{{ instances_details | to_nice_json }}"
dest: "{{ debug_output_dir }}/instances_details.json"
when: store_debug_output | default(false)

## TODO: figure out why this doesn't work
# - name: Store debug outputs
# copy:
Expand Down

0 comments on commit 37a9df3

Please sign in to comment.