summaryrefslogtreecommitdiff
path: root/common/tasks/user.yaml
blob: 9b81e0dd32a476a8d829cc6cb4225a378f30b05b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
- name: "Create user {{ user_name }}"
  user:
    name: "{{ user_name }}"
    comment: "{{ user_full_name }}"
    shell: /bin/bash
    uid: 1000
    groups:
      - sudo
- name: "Configure authorized key for {{ user_name }}"
  authorized_key:
    user: "{{ user_name }}"
    key: "{{ user_ssh_key }}"
- name: Create GnuPG directory
  file:
    path: "{{ user_name }}/.gnupg"
    owner: "{{ user_name }}"
    group: "{{ user_name }}"
    mode: u=rwx,g=,o=
    state: directory
- name: Copy OpenPGP key
  copy:
    src: "{{ user_pgp_key }}.txt"
    dest: "{{ user_name }}/.gnupg/{{ user_pgp_key }}.txt"
    owner: "{{ user_name }}"
    group: "{{ user_name }}"
    mode: u=rw,g=,o=
- name: Import OpenPGP key
  command: "gpg --import {{ user_name}}/.gnupg/{{ user_pgp_key }}.txt"
  become: yes
  become_user: "{{ user_name }}"
- name: Delete temporary key file
  file:
    path: "{{ user_name }}/.gnupg/{{ user_pgp_key }}.txt"
    state: absent