Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansible-playbook does permit you to specify inventory on the command line #2

Open
larsks opened this issue Feb 10, 2016 · 1 comment

Comments

@larsks
Copy link

larsks commented Feb 10, 2016

In https://github.com/k4ml/importerror/blob/master/posts/ansible-playbook-specify-hosts-on-the-command-line.md, you say:

While we can specify what hosts to run the command through ansible command-line program, it's does not apply to ansible-playbook program. We always need to specify the hosts: attribute in our YAML playbook.

That is not in fact true. Consider this playbook, which simply runs the ping module:

- hosts: all
  tasks:
    - ping:

If we have this in playbook.yml we can run it on localhost like this:

ansible-playbook -i localhost, playbook.yml

Or on hosta.example.com like this:

ansible-playbook -i hosta.example.com, playbook.yml

That is in fact pretty much the same syntax as the ansible ad-hoc command.

@k4ml
Copy link
Owner

k4ml commented Feb 11, 2016

Hi, thanks for taking time to look into this. Probably I can't find the trick while searching for this issue. I'll update the post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants