Why and How to use delegate_to, run_once and local connection with ansible ?
Like all orchestrators, Ansible has many tricks and tips. For example, ansible fans can use a playbook to install their laptops. So funny no ? Yes but this is very effective.
In this tutorial I would like to show you some smart options.
With “delegate_to” option, you can run a task on one server but for all remote server… You can see the video to understand with a short example.
With “run_once” option, when you use delegate_to but you just want to do the task only one time. For example when you create a cluster with multi-master and you generate token, you don’t want to generate one token per master but only one.
The “local connection” option, when you want to run ansible on your local server (laptop or dedicated ansible server) you don’t use ssh connection. Or for example when you use the cloud module with an api usage.