Getting hostvars when using serial

22 views
Skip to first unread message

Ivan Dimitrov

unread,
Jun 22, 2015, 7:46:58 AM6/22/15
to ansible...@googlegroups.com
Hello Group,

I'm looking for a way to access facts for my hostnames through the hostvars and groups methods. This all works well, but I'm stuck when I try to limit the batch size with the "serial" directive.

For example: I have 10 web servers that I want to do rolling update using the "serial: 50%".
{% for host in groups['app_servers'] %}
   {{ hostvars[host]['ansible_eth0']['ipv4']['address'] }}
{% endfor %}

Using the above example will give me all hosts in the group "app_servers" and there is no way to get only 50% of the hosts.

Is there a way to get facts information for "all hosts in the scope" and "all hosts outside of scope"?

Brian Coca

unread,
Jun 22, 2015, 12:15:12 PM6/22/15
to ansible...@googlegroups.com
you could use the loop.index and compare against group['app_servers']|length to break the loop at the serial point.
--
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/a34343e2-3266-49bb-a483-e894350d25fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Brian Coca

Reply all
Reply to author
Forward
0 new messages