diff --git a/plays/home.yml b/plays/home.yml new file mode 100755 index 0000000000000000000000000000000000000000..aa47fa4c9b58861a07e10d009c570dfdf82e93ae --- /dev/null +++ b/plays/home.yml @@ -0,0 +1,11 @@ +#!/usr/bin/env ansible-playbook +--- +- hosts: cameron.adm.crans.org + vars: + home: + ldap_server: ldap://re2o-ldap.adm.crans.org + ldap_password: "{{ vault_ldap_home_password }}" + binddn: cn=home,ou=service-users,dc=crans,dc=org + rootdn: cn=Utilisateurs,dc=crans,dc=org + roles: + - home diff --git a/roles/dns/templates/cron.d/firewall.j2 b/roles/dns/templates/cron.d/dns.j2 similarity index 100% rename from roles/dns/templates/cron.d/firewall.j2 rename to roles/dns/templates/cron.d/dns.j2 diff --git a/roles/dns/templates/firewall/re2o-config.ini.j2 b/roles/dns/templates/dns/re2o-config.ini.j2 similarity index 100% rename from roles/dns/templates/firewall/re2o-config.ini.j2 rename to roles/dns/templates/dns/re2o-config.ini.j2 diff --git a/roles/home/tasks/main.yml b/roles/home/tasks/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..10b1ebc5d328f1a684c722929df22cd28a92fd35 --- /dev/null +++ b/roles/home/tasks/main.yml @@ -0,0 +1,46 @@ +--- +- name: Install home dependencies + apt: + update_cache: true + install_recommends: false + name: + - python3-ldap + register: apt_result + retries: 3 + until: apt_result is succeeded + +- name: Create home directory + file: + path: /var/local/home + state: directory + mode: '2775' + owner: root + group: nounou + +- name: Set ACL for home directory + acl: + path: /var/local/home + default: true + entity: nounou + etype: group + permissions: rwx + state: query + +- name: Clone home repository + git: + repo: 'http://gitlab.adm.crans.org/nounous/home.git' + dest: /var/local/home + umask: '002' + +- name: Deploy home config + template: + src: home/config.py.j2 + dest: /var/local/home/config.py + mode: 0600 + owner: root + group: root + +- name: Deploy cron for home + template: + src: cron.d/home.j2 + dest: /etc/cron.d/home diff --git a/roles/home/templates/cron.d/home.j2 b/roles/home/templates/cron.d/home.j2 new file mode 100644 index 0000000000000000000000000000000000000000..f26e2e46734839b18be7d60a469130bc7326ffd4 --- /dev/null +++ b/roles/home/templates/cron.d/home.j2 @@ -0,0 +1,2 @@ +{{ ansible_header | comment }} +* * * * * root /usr/bin/python3 /var/local/home/main.py diff --git a/roles/home/templates/home/config.py.j2 b/roles/home/templates/home/config.py.j2 new file mode 100644 index 0000000000000000000000000000000000000000..e7f29b91b6c6753939a38d4618b88295e79a98e9 --- /dev/null +++ b/roles/home/templates/home/config.py.j2 @@ -0,0 +1,10 @@ +{{ ansible_header | comment }} + +ldap_server = '{{ home.ldap_server }}' +binddn = '{{ home.binddn }}' +password = '{{ home.ldap_password }}' +rootdn = '{{ home.rootdn }}' +home_dir = '/pool/home' +mail_dir = '/pool/mail' +home_quota = 'zfs set userquota@{user}=30G pool/home' +mail_quota = 'zfs set userquota@{user}=10G pool/mail'