I'm a greenhorn...I have this problem where I want the user to input either dev or prod in an env prompt then I take that and access a dictionary to get its custom properties. it works fine if I hardcode {{ dev.ip }} but if I do a lookup it says variable dev.ip not found. Also, let me know if there is a better way. Only gotcha is this if for networking so the target is always localhost and then it does api calls.
- hosts: localhost gather_facts: no vars_prompt: - name: username prompt: "Username" - name: password prompt: "Password" - name: env prompt: "Environment" vars: prod: ip: '1.1.1.1' dev: ip: '10.130.155.53' - name: Query tenant customer-xyz aci_tenant: host: "{{ lookup('vars', env + '.ip') }}" #host: "{{ dev.ip }}" username: "{{ username }}" password: "{{password}}" state: present validate_certs: false register: my_tenant fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: No variable found with this name: dev.ip\n\nThe error appears to be in '/var/lib/awx/projects/aci-dev/querytenant.yml': line 19, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n var: host\n - name: Query tenant customer-xyz\n ^ here\n"} -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/294e7528-fe8a-4741-b2ca-e542acede3e6%40googlegroups.com.