-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontainers.yml
49 lines (45 loc) · 1.56 KB
/
containers.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Create VM inventory
- hosts: vm_hosts
become: True
tasks:
- include_role:
name: role-virt-host
tasks_from: inventory
- hosts: "{{ 'container_hosts_' + stage if stage is defined else 'container_hosts' }}"
become: True
gather_facts: no
pre_tasks:
# VM restart for VMFS
- name: wait for server to come online
become: false
wait_for_connection:
timeout: 300
- name: Gathering facts
setup:
roles:
- role-container-host
# Update routers with container config from all stages
- hosts: routers
become: True
tasks:
- set_fact:
dnsmasq_container_hosts: "{{ dnsmasq_container_hosts | default([]) +
[{ 'env': item, 'hosts': groups['container_hosts_' + item] }] }}"
loop: "{{ ['production', 'testing', 'staging'] }}"
- set_fact:
dnsmasq_containers_conf: {}
- set_fact:
dnsmasq_containers_conf: "{{ dnsmasq_containers_conf | combine({ item.0.env: dnsmasq_containers_conf[item.0.env] |
default('') + hostvars[item.1].dnsmasq_conf | default('') }) }}"
loop: "{{ dnsmasq_container_hosts | subelements('hosts') }}"
- name: dnsmasq container directives
copy:
content: "{{ item.value }}"
dest: /etc/dnsmasq.d/containers_{{ item.key }}.conf
loop: "{{ dnsmasq_containers_conf | dict2items }}"
notify: dnsmasq restart
when:
# If container hosts only have config for a stage, limit update to only that stage
- stage is not defined or item.key == stage
handlers:
- import_tasks: handlers/main.yml