Browse Source

Make possible to create more than one admin account

Emmanuel Bouthenot 11 years ago
parent
commit
fd82af5bc4
3 changed files with 11 additions and 7 deletions
  1. 5 3
      group_vars/all
  2. 4 2
      roles/common/tasks/base.yml
  3. 2 2
      roles/common/templates/aliases.j2

+ 5 - 3
group_vars/all

@@ -8,9 +8,11 @@ ansible_master_user: $PIPE(whoami)
 ansible_master_hostname: $PIPE(hostname --fqdn)
 ansible_master_ip: $PIPE(hostname --ip)
 
-admin_fullname: Emmanuel Bouthenot
-admin_user: manu
-admin_email: kolter@openics.org
+admins:
+  - user: manu
+    fullname: Emmanuel Bouthenot
+
+email_forward: kolter@openics.org
 
 hosts_deny_nfs: False
 host_deny_paranoid: True

+ 4 - 2
roles/common/tasks/base.yml

@@ -47,10 +47,12 @@
   action: template src=sudo/local-admin.j2 dest=/etc/sudoers.d/local-admin owner=root group=root mode=0440
 
 - name: Install unprivileged user
-  action: user name="${admin_user}" comment="${admin_fullname}" groups=adm,operator,sudo append=yes shell=/bin/zsh state=present
+  action: user name="${item.user}" comment="${item.fullname}" groups=adm,operator,sudo append=yes shell=/bin/zsh state=present
+  with_items: ${admins}
 
 - name: Install SSH key for unprivileged user
-  action: authorized_key user="${admin_user}" key="$FILE(roles/common/data/users/${admin_user}/id_rsa.pub)" state=present
+  action: authorized_key user="${item.user}" key="$FILE(roles/common/data/users/${item.user}/id_rsa.pub)" state=present
+  with_items: ${admins}
 
 - name: Install SSH key for root
   action: authorized_key user=root key="$FILE(roles/common/data/users/${admin_user}/id_rsa.pub)" state=present

+ 2 - 2
roles/common/templates/aliases.j2

@@ -15,6 +15,6 @@ logcheck:       root
 clamav:         root
 monit:          root
 
-{% if admin_email is defined %}
-root:           {{ admin_email }}
+{% if email_forward is defined %}
+root:           {{ email_forward }}
 {% endif %}