Infra: AWS Jenkins Integration
[csit.git] / fdio.infra.ansible / roles / user_add / tasks / main.yaml
1 ---
2 # file: roles/user_add/tasks/main.yaml
3
4 - name: Conf - Add User
5   user:
6     append: "{{ item.append | default(omit) }}"
7     createhome: "{{ 'yes' if users_create_homedirs else 'no' }}"
8     generate_ssh_key: "{{ item.generate_ssh_key | default(omit) }}"
9     groups: "{{ item.groups | join(',') if 'groups' in item else '' }}"
10     name: "{{ item.username }}"
11     password: "{{ item.password if item.password is defined else '!' }}"
12     shell: "{{ item.shell if item.shell is defined else users_shell }}"
13     state: present
14   with_items: "{{ users }}"
15   tags:
16     - user-add-conf
17
18 - name: Conf - SSH keys
19   authorized_key:
20     user: "{{ item.0.username }}"
21     key: "{{ item.1 }}"
22   with_subelements:
23     - "{{ users }}"
24     - ssh_key
25     - skip_missing: true
26   tags:
27     - user-add-conf
28
29 - name: Conf - Disable Password Login
30   lineinfile:
31     dest: "/etc/ssh/sshd_config"
32     regexp: "^PasswordAuthentication yes"
33     line: "PasswordAuthentication no"
34   notify:
35     - "Restart SSHd"
36   when:
37     - sshd_disable_password_login
38   tags:
39     - user-add-conf