Delegating to a group of hosts
Say you have two groups of servers in your inventory: webservers and cacheserver. When deploying new content on webservers the cacheservers have to be flushed. You use notify:
to only flush when needed and combine delegate_to:
with with_items:
- name: deploy new stuff
hosts: webservers
tasks:
- name: deploy new stuff (faked here)
action: shell true
notify:
- flush caches
handlers:
- name: flush caches
action: service name=memcached state=restarted
delegate_to: $item
with_items: ${groups.cacheservers}
Written by cigor
Related protips
1 Response
When you delegate_to groups of hosts, it is concurrent or sequential?
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ansible
Authors
Misha Behersky
78.97K
tartansandal
73.31K
Related Tags
#ansible
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#