Re: [ansible-project] Configuration files deployment

28 views
Skip to first unread message
Message has been deleted

Kai Stian Olstad

unread,
Dec 7, 2016, 1:47:25 PM12/7/16
to ansible...@googlegroups.com
On 05. des. 2016 09:45, vu001 wrote:
> So I started to define FS variable on all hosts or groups if it is
> possible.
> Then I created 10 templates. In every template is some host specific
> variable references.
> With this simple task I accomplish main idea.
>
> - name: Deploy configuration files
> template: src=config1.j2 dest={{FS }}/config1
>
> But I need some ideas how to deploy this on multiple FS on same host. Is it
> possible to define array of FS (somewhere this array would have only one
> element, somewhere would have 3 elements) and then deploy this on all
> elements of array (which is basically location on filesystem where to
> deploy configuration).

Make FS a list, then you can do this

- name: Deploy configuration files
template: src=config1.j2 dest={{ item }}/config1
with_items: "{{ FS }}"

--
Kai Stian Olstad

vu001

unread,
Dec 13, 2016, 9:46:54 AM12/13/16
to Ansible Project, ansible-pr...@olstad.com
Hi Kai, thanks for help...

your suggestion could be useful, but it is not the best one.
If I have let say 10 hosts and 10 config files, on each host for each FS I need to create list where I specify which config files to deploy on which FS.
i.e. 
config1
[host1.yml]
config1: ["FS1","FS2", "FS4"]
[host2.yml]
config1: ["FS5"]
[host3.yml]
config1: ["FS7","FS9"]

config2
[host1.yml]
config1: ["FS3","FS4"]
[host2.yml]
config1: ["FS7"]
[host3.yml]
config1: ["FS1","FS3"]
That is to complicate because I have more than 30 hosts, and more than 20 config files.

My idea was to define list of FS-s in inventory file for each host
[host1.yml]
FS_LISTS:
   - name: "FS1"
     config_files: ["config1","config3","config7"]
   - name: "FS3"
     config_files: ["config5","config6","config7","config9","config12","config13"]   
   - name: "FS4"
     config_files: ["config1"]

[host2.yml]
FS_LISTS:
   - name: "FS3"
     config_files: ["config1",]
   - name: "FS6"
     config_files: ["config5","config6","config7","config9","config12","config13"]   
   - name: "FS7"
     config_files: ["config1","config12","config13"]


It's simple when I want to deploy only one config file to each FS.

 template: src=config1.j2 dest={{ item.name }}/config1
 with_items: "{{MEMBERS_LIST}}"

But I can't figure out how to deploy all config files specified for some host, not just config1. 
How to permutate FS_LIST.name with every element of list FS_LIST.config_files
I want this on host1
FS1 config1
FS1 config2
FS1 config3

FS3 config5
FS3 config6
FS3 config7
FS3 config9
FS3 config12
FS3 config13

How to nest that to lists, and do this permutation.

Thanks a lot











 but I'm searching for better solution. 
Reply all
Reply to author
Forward
Message has been deleted
0 new messages