-
Notifications
You must be signed in to change notification settings - Fork 23.8k
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
adhoc: allow -i * to use all hosts as-is #11426
Conversation
Sometimes I want to do something quick against a brand new host that I haven't yet added to the inventory. This is essentially a more flexible version of the "comma trick". This allows passing `-i '*'`, which means basically don't look at inventory files and just try to operate against any host that I specify verbatim. E.g.: # remotehost is not in any ansible inventory file or dynamic inventory # but I can target it anyway $ ansible -i '*' myuser@remotehost -a 'lsb_release -a' myuser@remotehost | SUCCESS => { ... "stdout": "Distributor ID:\tUbuntu\nDescription:\tUbuntu 12.04.5 LTS\nRelease:\t12.04\nCodename:\tprecise", "cmd": [ "lsb_release", "-a" ], ... "stdout_lines": [ "Distributor ID:\tUbuntu", "Description:\tUbuntu 12.04.5 LTS", "Release:\t12.04", "Codename:\tprecise" ], "warnings": [] } Note that this also makes the experience easier for new users and means that the "Getting started" docs (http://docs.ansible.com/intro_getting_started.html#your-first-commands) don't need to cover inventory right away. If one has an `ansible.cfg` with: [defaults] inventory = * then it becomes even easier and `-i '*'` can be omitted -- e.g.: ansible myuser@remotehost -a date
I find this confusing. I would think that a This makes it feel backwards to me. And in fact, the comma functionality is largely there to support internal cases such as what is used in I would actually find it more logical to type something like;
Which is basically what I do now when testing functionality. |
Also, just to give my description of what I understand this to do:
I could see many places where this would also cause lots of confusion and places where it just wouldn't work. |
My initial implementation used Here's my description of what I intended this to do:
So I don't know, maybe Maybe what is should really do is allow an inventory but also allow the use of hosts that are not in the inventory. |
I think I have a better idea... |
E.g.: # `somehost` is not in the ansible inventory $ ansible somehost -m ping --allow-hosts-not-in-inventory user@host | SUCCESS => { "invocation": { "module_name": "ping", "module_args": {} }, "changed": false, "ping": "pong" } Replaces ansible#11426
Closing in favor of #11431 |
Sometimes I want to do something quick against a brand new host that I
haven't yet added to the inventory. This is essentially a more flexible
version of the "comma trick". This allows passing
-i '*'
, which meansbasically don't look at inventory files and just try to operate against
any host that I specify verbatim. E.g.:
Note that this also makes the experience easier for new users and means that
the "Getting started" docs
(http://docs.ansible.com/intro_getting_started.html#your-first-commands) don't
need to cover inventory right away.
If one has an
ansible.cfg
with:then it becomes even easier and
-i '*'
can be omitted -- e.g.: