Using Ansible per directory instead of per host

17 views
Skip to first unread message

Emmanuel Jaep

unread,
Feb 6, 2018, 2:52:13 PM2/6/18
to Ansible Project
I know it will sound a bit strange but I wonder if there is a way to use Ansible per directory instead of per host.

Our current use case is the following: the same application (here WordPress) is deployed into multiple folders onto the same host (probably a very common scenario at a hosting provider).

We want to manage the configuration of all the instances in a 'smart' way (hence the idea of using Ansible). for instance, the same file (plugin) should be copied into the same subfolders of the instances.

This could be very easily achieved if all instances were hosted on different hosts, but I can find a way to achieve this in different folders on the same host.

Is that completely stupid? Any insight will be greatly appreciated.

Brian Coca

unread,
Feb 6, 2018, 4:48:06 PM2/6/18
to Ansible Project
Just use a loop that traverses per plugin + per dir.

- hosts: wordpress_servers
tasks:
- copy: src=files/plugins/{{item.1}} dest={{ item|join('/')}}
loop: '{{ list_of_dirs|zip(list_of_plugins)}}'

^ pseudo code, but very similar to what you can do

--
----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages