Skip to content

Commit a53ce6f

Browse files
committed
Move settings and configuration inside SITE home
Create a private copy of the settings.yml file into the SITE home directory so that it can be modified without interfering other environments. The config.yml file is also created inside the SITE home to avoid interferences. Signed-off-by: Xavi Hernandez <[email protected]>
1 parent 139104b commit a53ce6f

File tree

12 files changed

+26
-14
lines changed

12 files changed

+26
-14
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ playbooks/ansible/ssh-config-setup
55
playbooks/site_inventory
66
playbooks/ssh-config-host
77
playbooks/Vagrantfile
8-
playbooks/ansible/config.yml
98
devel/authorized_keys

playbooks/cleanup.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
become: no
55
gather_facts: false
66
vars_files:
7-
- ansible/config.yml
7+
- "{{ lookup('env', 'SITE_HOME') | default('.') }}/config.yml"
88
vars:
99
provision_action: destroy
1010
roles:

playbooks/hosts.update.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
become: yes
77
become_method: sudo
88
vars_files:
9-
- ansible/config.yml
9+
- "{{ lookup('env', 'SITE_HOME') | default('.') }}/config.yml"
1010
roles:
1111
- hosts.update

playbooks/nodes.statedump.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
become: yes
44
become_method: sudo
55
vars_files:
6-
- ansible/config.yml
6+
- "{{ lookup('env', 'SITE_HOME') | default('.') }}/config.yml"
77
roles:
88
- logs.collect
99
- config.collect

playbooks/roles/local.clean/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
path: "{{ item }}"
55
state: absent
66
with_items:
7-
- ansible/config.yml
7+
- "{{ lookup('env', 'SITE_HOME') | default('.') }}/config.yml"
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
11
---
2+
- name: Locate SITE home
3+
set_fact:
4+
site_home: "{{ lookup('env', 'SITE_HOME') | default('.', true) }}"
5+
26
- name: Load settings
37
include_vars:
4-
file: "settings.yml"
8+
file: "{{ site_home }}/settings.yml"
59

610
- name: Generate config.yml in ansible directory
711
template:
812
src: config.yml.j2
9-
dest: ./ansible/config.yml
13+
dest: "{{ site_home }}/config.yml"
1014
vars:
1115
os: "{{ use_distro | default('centos9') }}"
1216
be: "{{ (backend | default('xfs') | split('.'))[0] }}"
1317
variant: "{{ (backend | default('xfs') | split('.'))[1] | default('default') }}"
1418
max_memory: "{{ ansible_memfree_mb }}"
1519
max_cpu: "{{ ansible_processor_nproc }}"
1620
vm_prefix: "{{ lookup('env', 'SITE_NAME') | default('site', true) }}"
21+
home: "{{ site_home }}"
1722

1823
- name: Load configuration
1924
include_vars:
20-
file: "ansible/config.yml"
25+
file: "{{ site_home }}/config.yml"
2126

2227
- debug:
2328
var: config
29+
30+
- name: Copy common playbook configuration
31+
copy:
32+
src: "{{ site_home }}/config.yml"
33+
dest: "{{ config.statedir }}"

playbooks/roles/local.defaults/templates/config.yml.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
config:
3+
home: "{{ home }}"
4+
35
os:
46
{%- for os_name in os_info +%}
57
{{ os_name }}:

playbooks/roles/provisioner.vagrant/tasks/create/main.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,3 @@
6666
path: "{{ config.statedir }}/{{ item }}"
6767
state: directory
6868
loop: "{{ config.groups['cluster'] + config.groups['clients'] }}"
69-
70-
- name: Copy common playbook configuration
71-
copy:
72-
src: ansible/config.yml
73-
dest: "{{ config.statedir }}"

playbooks/roles/setup.prep/tasks/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@
2929
src: ansible/ssh-config-setup
3030
dest: .ssh/config
3131
mode: 0600
32+
33+
- name: Copy config.yml
34+
copy:
35+
src: "{{ config.home }}/config.yml"
36+
dest: ansible/config.yml

playbooks/setup.prep.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
become: yes
77
become_method: sudo
88
vars_files:
9-
- ansible/config.yml
9+
- "{{ lookup('env', 'SITE_HOME') | default('.') }}/config.yml"
1010
roles:
1111
- setup.prep

0 commit comments

Comments
 (0)