1
votes

I do not wish to specify any hosts file to ansible-playbook command.

ansible-playbook site.yml  -e "source_host=mymac1 source_file=myfile1"

My site.yml looks like this:

more site.yml

---

- hosts: "{{ source_host | default('my_pc')}}"
  user: weblogic

However, I get the following error:

[WARNING]: Could not match supplied host pattern, ignoring: all

[WARNING]: provided hosts list is empty, only localhost is available

PLAYBOOK: site.yml ********************************************************************************************************************************************************************************** 2 plays in site.yml [WARNING]: Could not match supplied host pattern, ignoring: mymac1

Can you please suggest how can i pass any host to my playbook without having to maintain and host respository with all the host information

I am on ansible version 2.3.1.0

1

1 Answers

3
votes

You can use inline inventory:

playbook.yml:

- hosts: all
  tasks:
    - debug: msg=hello

command:

ansible-playbook -i 'mymac1,' -e source_file=myfile1 playbook.yml

note comma after hostname.

Also see: Ansible ad-hoc command with direct host specified - no hosts matched