Hi sorry for late response. Actually, I have found a way that works for me, and I hope can help others looking for the same thing. I found this solution elsewhere on the Internet as well. Basically, it seems hosts cannot take in a variable that is just defined, so the way around this is to have hosts reference a dynamic group, and then have the inputted hostname be added to the group via the add_hosts task
--- - hosts: localhost gather_facts: no vars_prompt: - name: var_hostname prompt: "Enter hostname to deploy to" private: no tasks: - add_host: hostname: "{{ var_hostname }}" groups: dynamic_list with_items: "{{ var_hostname.split(',') }}" - hosts: dynamic_list gather_facts: no tasks: .... On Tuesday, November 27, 2018 at 5:02:57 PM UTC-5, John Harmon wrote: > > I believe your problem is that you are specifying hosts twice. The > following works for me (gather facts is enabled for this example (to check > ansible_fqdn), but wouldn't be necessary for this to work): > > --- > - hosts: "{{ var_hostname }}" > gather_facts: yes > > vars_prompt: > - name: var_hostname > prompt: "Enter hostname to deploy to" > private: no > > tasks: > - name: TEST > debug: > var: ansible_fqdn > > > -- 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 post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/79fa1ab3-0c33-422c-b8fb-c7f2505987c6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.