MOAR DEBUG
This commit is contained in:
@@ -39,9 +39,60 @@
|
|||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
changed_when: true
|
changed_when: true
|
||||||
|
|
||||||
- name: Parse inventory JSON
|
- name: Show script execution details
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: |
|
||||||
|
Script execution results:
|
||||||
|
Return code: {{ linode_inventory_result.rc }}
|
||||||
|
Stdout length: {{ linode_inventory_result.stdout | length }}
|
||||||
|
Stderr length: {{ linode_inventory_result.stderr | length }}
|
||||||
|
|
||||||
|
- name: Show stderr if present
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "Script stderr: {{ linode_inventory_result.stderr }}"
|
||||||
|
when: linode_inventory_result.stderr | length > 0
|
||||||
|
|
||||||
|
- name: Show stdout if present
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "Script stdout: {{ linode_inventory_result.stdout }}"
|
||||||
|
when: linode_inventory_result.stdout | length > 0
|
||||||
|
|
||||||
|
- name: Test API token directly
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "https://api.linode.com/v4/linode/instances"
|
||||||
|
method: GET
|
||||||
|
headers:
|
||||||
|
Authorization: "Bearer {{ linode_api_token }}"
|
||||||
|
Content-Type: "application/json"
|
||||||
|
return_content: yes
|
||||||
|
status_code: [200, 401, 403]
|
||||||
|
register: direct_api_test
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
|
- name: Display direct API test results
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: |
|
||||||
|
Direct API test results:
|
||||||
|
Status: {{ direct_api_test.status }}
|
||||||
|
Response: {{ direct_api_test.json | default('No JSON response') }}
|
||||||
|
|
||||||
|
- name: Parse inventory JSON (only if stdout exists)
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
linode_inventory_data: "{{ linode_inventory_result.stdout | from_json }}"
|
linode_inventory_data: "{{ linode_inventory_result.stdout | from_json }}"
|
||||||
|
when:
|
||||||
|
- linode_inventory_result.stdout | length > 0
|
||||||
|
- linode_inventory_result.rc == 0
|
||||||
|
|
||||||
|
- name: Set empty inventory if script failed
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
linode_inventory_data:
|
||||||
|
_meta:
|
||||||
|
hostvars: {}
|
||||||
|
all:
|
||||||
|
children: ['ungrouped']
|
||||||
|
ungrouped:
|
||||||
|
hosts: []
|
||||||
|
when: linode_inventory_data is not defined
|
||||||
|
|
||||||
- name: Save inventory to file
|
- name: Save inventory to file
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
@@ -57,6 +108,7 @@
|
|||||||
Total hosts discovered: {{ linode_inventory_data._meta.hostvars | length }}
|
Total hosts discovered: {{ linode_inventory_data._meta.hostvars | length }}
|
||||||
Groups created: {{ linode_inventory_data.keys() | reject('equalto', '_meta') | list | length }}
|
Groups created: {{ linode_inventory_data.keys() | reject('equalto', '_meta') | list | length }}
|
||||||
Inventory saved to: {{ temp_inventory_path }}
|
Inventory saved to: {{ temp_inventory_path }}
|
||||||
|
API Token status: {{ 'Set (' + (linode_api_token[:8] + '...' if linode_api_token | length > 8 else linode_api_token) + ')' if linode_api_token is defined else 'NOT SET' }}
|
||||||
|
|
||||||
- name: Show raw script output for debugging
|
- name: Show raw script output for debugging
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
|
Reference in New Issue
Block a user