Ciasto piekarz
Ciasto piekarz

Reputation: 8277

Using limit flag with ansible-playbook causes localhost to not be found

I am running ansible playbook with the limit flag.

ansible-playbook -i hosts --vault-password-file /etc/hostname playbooks/install.yml --tags "printa" --limit 'all:!vm'

but this causes localhost to be not found:

PLAY [Playing with Ansible and Git] *****************************************************************************
skipping: no hosts matched

PLAY [all] ******************************************************************************************************
.
.

This is my install.yml

---
- name: "Playing with Ansible and Git"
  hosts: localhost
  connection: local 
  tasks:

  - name: "just execute a ls -lrt command"
    shell: "ls -lrt"
    register: "output"

  - debug: var=output.stdout_lines

Upvotes: 3

Views: 1327

Answers (1)

Zeitounator
Zeitounator

Reputation: 44615

Ansible implicit localhost is not part of the all (nor any other...) group.

You either need to:

  • add localhost explicitly to your inventory. But it will then match the all group in your playbooks too with all undesired possible effects
  • add that localhost to your limit which would be my preferred option here:
    --limit 'localhost:all:!vm'
    

Upvotes: 4

Related Questions