How to pass all server information from a JSON file in Ansible Forms to AWX for use in a template? #272
-
Hi, I'm using Ansible Forms and AWX, and I have a JSON file with details of several servers on my local machine. The JSON looks like this: [
{"name": "Server1", "ip": "192.168.1.10", "role": "web"},
{"name": "Server2", "ip": "192.168.1.11", "role": "db"}
] In the Ansible Forms form, the user selects a server, but currently, only the server name is passed to AWX, not all the information (like IP, role, etc.). My playbook looks like this: - name: Convert Enum to JSON text and then to Dictionary
hosts: localhost
gather_facts: no
vars:
tasks:
- name: Convert Enum to JSON text
set_fact:
json_text: "{{ awx_variable | to_json }}"
- name: Show JSON as text
debug:
msg: "JSON text: {{ json_text }}"
- name: Convert JSON text to Ansible structure
set_fact:
data_json: "{{ json_text | from_json }}"
- name: Show processed structure
debug:
msg: "{{ data_json }}" The issue is that Ansible Forms is on my local machine and AWX is on a different server, so I can't use the lookup to access the JSON file directly. The user selects a server in the form, but only the server name is passed, and I need all the details (like IP, role, etc.) to be available in the AWX playbook. Would it be possible to upload the JSON file to an accessible repository like GitHub and use it in AWX? Or is there an easier way to achieve this? Thanks for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
|
Beta Was this translation helpful? Give feedback.
outputObject: true