diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2019-07-23 13:17:56 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2019-07-23 13:17:56 +0200 |
commit | 67f5d1008eef96f13dbf8910092155b7aa1bcee4 (patch) | |
tree | 00901863a6ab5c24c3e5616a9d4308499810c568 /terraform/ansible/roles/lusers/tasks | |
parent | ba76764c198e9232b3152568008d5aa5199a1fd0 (diff) | |
download | k8s-sandbox-67f5d1008eef96f13dbf8910092155b7aa1bcee4.tar.gz k8s-sandbox-67f5d1008eef96f13dbf8910092155b7aa1bcee4.tar.bz2 k8s-sandbox-67f5d1008eef96f13dbf8910092155b7aa1bcee4.tar.xz k8s-sandbox-67f5d1008eef96f13dbf8910092155b7aa1bcee4.zip |
o Merging in Terraform setup.
Diffstat (limited to 'terraform/ansible/roles/lusers/tasks')
-rw-r--r-- | terraform/ansible/roles/lusers/tasks/main.yml | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/terraform/ansible/roles/lusers/tasks/main.yml b/terraform/ansible/roles/lusers/tasks/main.yml new file mode 100644 index 0000000..cb10845 --- /dev/null +++ b/terraform/ansible/roles/lusers/tasks/main.yml @@ -0,0 +1,45 @@ +--- +- become: yes + tags: lusers + vars: + usernames: "{{ users|dict2items|map(attribute='key')|list }}" + block: + - name: adduser + with_items: "{{ lusers }}" + user: + name: "{{ item }}" + shell: /bin/bash + + - name: getent passwd + getent: + database: passwd + + - name: disable user + with_items: "{{ usernames }}" + when: (item not in lusers) and (item in getent_passwd) + user: + name: "{{ item }}" + shell: /usr/sbin/nologin + + - name: mkdir ~/.ssh + when: lusers_authorized_keys_exclusive + with_items: "{{ lusers }}" + file: + path: "~{{ item }}/.ssh" + state: directory + owner: "{{ item }}" + mode: 0700 + + - name: authorized_keys, exclusively managed by Ansible + copy: + dest: "/home/{{ item }}/.ssh/authorized_keys" + content: "{{ users[item].authorized_keys }}" + when: lusers_authorized_keys_exclusive + with_items: "{{ lusers }}" + + - name: authorized_keys, shared management with Ansible + authorized_key: + user: "{{ item }}" + key: "{{ users[item].authorized_keys }}" + with_items: "{{ lusers }}" + when: not lusers_authorized_keys_exclusive |