Last Updated: July 16, 2017
·
17.07K
· cigor

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}

1 Response
Add your response

When you delegate_to groups of hosts, it is concurrent or sequential?

over 1 year ago ·