Check out with_inventory_hostnames http://docs.ansible.com/ansible/playbooks_loops.html#looping-over-the-inventory
On Thursday, May 19, 2016, jzarzoso <[email protected]> wrote: > Hi everyone! > > I'm thinking of looping through all the hosts from a playbook with a > pattern. I have this play: > > - hosts: localhost # Select all hosts > tasks: > - name: Debug the list > debug: > msg: "host: {{ item }}" > with_items: "{{groups.all}}" > > I wanted something like this: > > - hosts: localhost # Select all hosts EXCEPT localhost > tasks: > - name: Debug the list > debug: > msg: "host: {{ item }}" > with_items: "{{ groups.all:!localhost }}" > > > I tried but I got an error: > > fatal: [localhost]: FAILED! => {"failed": true, "msg": "template error > while templating string: expected token 'end of print statement', got ':'. > String: {{groups.all:!localhost}}"} > > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <javascript:_e(%7B%7D,'cvml','ansible-project%[email protected]');> > . > To post to this group, send email to [email protected] > <javascript:_e(%7B%7D,'cvml','[email protected]');>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/8f8c3e61-f670-45d5-879e-9cdb781afab6%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/8f8c3e61-f670-45d5-879e-9cdb781afab6%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Matt Martz @sivel sivel.net -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAD8N0v9eTssDJHAQ33dWiY1Lwd5grP4rDvKP5VNdCp%2BDd%2BY7EA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
