Create survey for variable

Hi All,
I am trying to move this code to Ansible Tower, but I am not able to figure out how to create survey for hostName variable. Can anyone help me on this

- hosts: all
  gather_facts: no
  become: yes
  vars:
          hostName:
            - { servername : xxxx , esxi_ip : xxxx , ilo_ip : xxxx }
            - { servername : xxxx , esxi_ip : xxxx , ilo_ip : xxxx }
            - { servername : xxxx , esxi_ip : xxxx , ilo_ip : xxxx }

          ansible_python_interpreter: /usr/bin/python3
  tasks:
  - name: Create destination directory
    ansible.builtin.file:
      path: "{{ file_path }}/{{ item.servername }}"
      state: directory
      group: root
      mode: '0755'    
    loop: "{{ hostName }}"

Make it a textarea with an appropriate default answer in yaml or json format. Then in your playbook use the β€œansible.builtin.from_yaml” or" ansible.builtin.from_json" filter to re-ingest the text into a new variable.

(β€œhostName” isn’t a good long-term variable name. Upper-case letters β€˜n’ such. β€œansible-lint” is your friend.)

1 Like