Support configuration of multiple hosts
This commit is contained in:
parent
b4f88686b8
commit
dad7d71f09
1
coreos-config/group_vars/all/rendering.yaml
Normal file
1
coreos-config/group_vars/all/rendering.yaml
Normal file
@ -0,0 +1 @@
|
||||
render_blacklist: []
|
4
coreos-config/group_vars/testenv/rendering.yaml
Normal file
4
coreos-config/group_vars/testenv/rendering.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
render_blacklist:
|
||||
- "03_syncthing/config/cert.pem"
|
||||
- "03_syncthing/config/key.pem"
|
||||
- "03_syncthing/config/config.xml"
|
@ -1,39 +1,40 @@
|
||||
---
|
||||
|
||||
- name: Wait for hosts to be ready
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Wait for system to become reachable
|
||||
wait_for_connection:
|
||||
timeout: 300
|
||||
sleep: 10
|
||||
|
||||
- name: Render compose files
|
||||
hosts: localhost
|
||||
hosts: all
|
||||
tags: template
|
||||
vars:
|
||||
render_path: "./render/compose"
|
||||
render_blacklist:
|
||||
- EMPTY
|
||||
render_path: "./render/{{ inventory_hostname }}/compose"
|
||||
tasks:
|
||||
- file:
|
||||
state: absent
|
||||
dest: '{{ render_path }}'
|
||||
changed_when: false
|
||||
- file:
|
||||
state: directory
|
||||
dest: '{{ render_path }}/{{ item.path }}'
|
||||
changed_when: false
|
||||
with_filetree: './compose'
|
||||
when: item.state == 'directory'
|
||||
- name: Template Compose structure
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ render_path }}/{{ item.path }}"
|
||||
force: true
|
||||
changed_when: false
|
||||
with_filetree: './compose'
|
||||
when: item.state == 'file' and item.path not in render_blacklist
|
||||
- name: Copy blacklisted files
|
||||
copy:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ render_path }}/{{ item.path }}"
|
||||
force: true
|
||||
changed_when: false
|
||||
with_filetree: './compose'
|
||||
when: item.state == 'file' and item.path in render_blacklist
|
||||
- block:
|
||||
- file:
|
||||
state: absent
|
||||
dest: '{{ render_path }}'
|
||||
changed_when: false
|
||||
- file:
|
||||
state: directory
|
||||
dest: '{{ render_path }}/{{ item.path }}'
|
||||
changed_when: false
|
||||
with_filetree: './compose'
|
||||
when: item.state == 'directory'
|
||||
- name: Template Compose structure
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ render_path }}/{{ item.path }}"
|
||||
force: true
|
||||
changed_when: false
|
||||
with_filetree: './compose'
|
||||
when: item.state == 'file' and item.path not in render_blacklist
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Backup
|
||||
hosts: all
|
||||
@ -111,7 +112,7 @@
|
||||
- name: Gather local Config
|
||||
delegate_to: 127.0.0.1
|
||||
find:
|
||||
paths: ./render/compose
|
||||
paths: "./render/{{ inventory_hostname }}/compose"
|
||||
recurse: true
|
||||
file_type: file
|
||||
register: local_compose_files
|
||||
@ -129,7 +130,7 @@
|
||||
verbosity: 2
|
||||
|
||||
- ansible.builtin.set_fact:
|
||||
compose_dirs_tainted: "{{ remote_compose_files.files | map(attribute='path') | difference(local_compose_files.files | map(attribute='path') | map('regex_replace', '^render/', '/home/core/')) | map('dirname') }}"
|
||||
compose_dirs_tainted: "{{ remote_compose_files.files | map(attribute='path') | difference(local_compose_files.files | map(attribute='path') | map('regex_replace', '^render/.*/compose', '/home/core/compose')) | map('dirname') }}"
|
||||
- ansible.builtin.debug:
|
||||
var: compose_dirs_tainted
|
||||
verbosity: 2
|
||||
@ -142,7 +143,7 @@
|
||||
|
||||
- name: Copy Compose files
|
||||
ansible.posix.synchronize:
|
||||
src: ./render/compose
|
||||
src: "./render/{{ inventory_hostname }}/compose"
|
||||
dest: /home/core/
|
||||
archive: false
|
||||
checksum: true
|
||||
|
Loading…
Reference in New Issue
Block a user