Delegating a task
Sometimes you want to execute an action on a different system. This could be, for instance, a database node while you are deploying something on an application server node or to the local host. To do so, you can just add the 'delegate_to: HOST
' property to your task and it will be run on the proper node. Let's rework the previous example to achieve this:
--- - hosts: database remote_user: ansible tasks: - name: Count processes running on the remote system shell: ps | wc -l register: remote_processes_number - name: Print remote running processes debug: msg: '{{ remote_processes_number.stdout }}' - name: Count processes running on the local system shell: ps | wc -l &...