- hosts: localhost # Select all hosts tasks: - name: Debug the list debug: msg: "host: {{ item }}" with_items: "{{groups.all}}"- hosts: localhost # Select all hosts EXCEPT localhost tasks: - name: Debug the list debug: msg: "host: {{ item }}" with_items: "{{ groups.all:!localhost }}"
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8f8c3e61-f670-45d5-879e-9cdb781afab6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Check out with_inventory_hostnames
http://docs.ansible.com/ansible/playbooks_loops.html#looping-over-the-inventory
On Thursday, May 19, 2016, jzarzoso <jan...@d3fy.com> 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 hoststasks:- name: Debug the listdebug:msg: "host: {{ item }}"with_items: "{{groups.all}}"I wanted something like this:- hosts: localhost # Select all hosts EXCEPT localhosttasks:- name: Debug the listdebug: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 ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8f8c3e61-f670-45d5-879e-9cdb781afab6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.