Skip to content

Instantly share code, notes, and snippets.

@alces
Last active September 2, 2022 07:17

Revisions

  1. alces revised this gist May 25, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ansible_ad_hoc_inventories.md
    Original file line number Diff line number Diff line change
    @@ -11,5 +11,5 @@ If you have only one host to run your playbook against, your inventory string mu
    (because otherwise Ansible would interpret it as a name of inventory file, not a hosts' list) for example:

    ```bash
    ansible-playbook -i myhost, -a 'uname -a'
    ansible-playbook -i myhost, all -a 'uname -a'
    ```
  2. alces revised this gist May 25, 2016. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions ansible_ad_hoc_inventories.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    In case you want to run `ansible` (or `ansible-playbook`) command against a set of hosts that makes sense only for one run,
    you can don't bother to create one-time inventory file, but define a comma-separated list of hosts as argument of `--invertory` option
    (or its short form that's simply `-i`) as follows:
    you can don't bother to create one-time inventory file, but simply define a comma-separated list of hosts as argument of `--invertory` option (or its short form that's simply `-i`) as follows:

    ```bash
    ansible --inventory=myhost1,myhost2,myhost3 all -m setup -a 'filter=*name*'
  3. alces created this gist May 25, 2016.
    16 changes: 16 additions & 0 deletions ansible_ad_hoc_inventories.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    In case you want to run `ansible` (or `ansible-playbook`) command against a set of hosts that makes sense only for one run,
    you can don't bother to create one-time inventory file, but define a comma-separated list of hosts as argument of `--invertory` option
    (or its short form that's simply `-i`) as follows:

    ```bash
    ansible --inventory=myhost1,myhost2,myhost3 all -m setup -a 'filter=*name*'
    ```

    (note that `all` in this command line stands for the target hostname)

    If you have only one host to run your playbook against, your inventory string must ends with `,`
    (because otherwise Ansible would interpret it as a name of inventory file, not a hosts' list) for example:

    ```bash
    ansible-playbook -i myhost, -a 'uname -a'
    ```