Explorar el Código

add ability to add users from common role

Blaine Story hace 3 años
padre
commit
b63359cda3
Se han modificado 2 ficheros con 15 adiciones y 0 borrados
  1. 1 0
      roles/common/defaults/main.yml
  2. 14 0
      roles/common/tasks/main.yml

+ 1 - 0
roles/common/defaults/main.yml

@@ -1,2 +1,3 @@
 ---
 host_ssh_root_keys: []
+users: []

+ 14 - 0
roles/common/tasks/main.yml

@@ -149,6 +149,20 @@
   tags: ssh
 
 
+- name: Create additional users
+  user:
+    name: "{{ item.name }}"
+    uid: "{{ item.uid }}"
+    state: present
+    shell: "{{ item.shell | default('/bin/bash') }}"
+    create_home: "{{ item.create_home | default('yes') }}"
+  with_items:
+    - "{{ users }}"
+  when:
+    - item.name is defined
+    - item.uid is defined
+
+
 - name: Add Bash aliases for root user
   lineinfile:
     dest: /root/.bashrc