diff --git a/group_vars/all/vars.yaml b/group_vars/all/vars.yaml index f2276672e2f1f6ed14a0ea429e1c96a3766467c1..3aecd849caf3307d26b0531dfc149a2e4f851ced 100644 --- a/group_vars/all/vars.yaml +++ b/group_vars/all/vars.yaml @@ -42,7 +42,9 @@ adm_subnet: 10.231.136.0/24 # # # global server definitions glob_smtp: smtp.adm.crans.org -glob_mirror: mirror.adm.crans.org +glob_mirror: + name: mirror.adm.crans.org + ip: 172.16.10.30 glob_ldap: servers: diff --git a/plays/certbot.yml b/plays/certbot.yml index 025db3ce4cb67910adf8c8f6b54387978e6da7a3..e1a97312ced74b69656d2de251dfa0c507ce3112 100755 --- a/plays/certbot.yml +++ b/plays/certbot.yml @@ -4,6 +4,6 @@ - hosts: certbot vars: certbot: '{{ glob_certbot | default({}) | combine(loc_certbot | default({})) }}' - mirror: '{{ glob_mirror }}' + mirror: '{{ glob_mirror.name }}' roles: - certbot diff --git a/plays/freeradius.yml b/plays/freeradius.yml index 37296a216d4c43d67dfefb314fe5da7510aadb23..51d994e1343636338301c66f70b841b0f7f391a8 100755 --- a/plays/freeradius.yml +++ b/plays/freeradius.yml @@ -5,7 +5,7 @@ vars: certbot: '{{ glob_certbot | default({}) | combine(loc_certbot | default({})) }}' freeradius: '{{ glob_freeradius | default({}) | combine(loc_freeradius | default({})) }}' - mirror: '{{ glob_mirror }}' + mirror: '{{ glob_mirror.name }}' roles: - certbot - freeradius diff --git a/plays/root.yml b/plays/root.yml index b8fe4a4b8f6fafcaf19d58dab528694dcfc8fd1b..10247c25f5e99c7de40ef82a225109f76793385e 100755 --- a/plays/root.yml +++ b/plays/root.yml @@ -1,6 +1,27 @@ #!/usr/bin/env ansible-playbook --- # root is the first playbook to launch (as root) whe initiation a new server + +- hosts: server + tasks: + - name: Check if mirror.adm is defined in /etc/hosts + lineinfile: + state: absent + path: /etc/hosts + regexp: '^{{ glob_mirror.ip }}' + check_mode: True + changed_when: False + register: check_mirror + + - name: Define mirror.adm.crans.org if it doesn't exist. + lineinfile: + path: /etc/hosts + line: '{{ glob_mirror.ip }} {{ glob_mirror.name }}' + insertafter: '127.0.0.1 localhost' + when: check_mirror.found == 0 + + + - hosts: tealc.adm.crans.org roles: - baie