Skip to content

Commit

Permalink
infra: base role for user setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dzeban committed Mar 9, 2018
1 parent 24aff3e commit f412dd8
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
2 changes: 2 additions & 0 deletions infrastructure/ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ inventory = ./inventory
roles_path = ./roles
host_key_checking = False
allow_world_readable_tmpfiles = True
remote_user = test

[privilege_escalation]

[paramiko_connection]
Expand Down
3 changes: 2 additions & 1 deletion infrastructure/roles/base/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
# defaults file for base
base_user: test
base_group: test
1 change: 1 addition & 0 deletions infrastructure/roles/base/files/avd.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDdYP1gM8Pk60KPzfMg6lwY9l+uZfs88Rd6bsAPKTgK/TSGiOjFd69zvhW5bqaRGE7nyNhGD/boFB2XMQvil++13nq5ZL1xC2xZVYFfu5HSTtU9+jU0SZWvcbZ9Z/MHAP9WfWm+//w3qB+nJJhuxs2w+mweFKNBptFKEibOXhgDeHJn1xZwKTf61GZn4LDEbw7dIkjzNLLT2nYXJbMYgnVGmXv065jrYPSy+KVmHX+RIljDzOW6gK8uIL8AylXlxlKp2klzxVvLiCSlWGM8Zu3v6B6crEqeZkm5C6PagMoUo0qr/eN6fK2GVGR5dD09ptMDVHjz0aQfvZi9vMLAWQyt avd@lenovo
38 changes: 34 additions & 4 deletions infrastructure/roles/base/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
---

- name: Ensure test dir
file:
path: /tmp/test
state: directory
- name: Make sure we have a 'wheel' group
group:
name: wheel
state: present

- name: Allow 'wheel' group to have passwordless sudo
lineinfile:
dest: /etc/sudoers
state: present
regexp: '^%wheel'
line: '%wheel ALL=(ALL) NOPASSWD: ALL'
validate: 'visudo -cf %s'

- name: Ensure base group
group:
name: "{{ base_group }}"
state: present

- name: Ensure base user
user:
name: "{{ base_user }}"
group: "{{ base_group }}"
groups: wheel
append: yes
state: present

- name: Set authorized key took from file
authorized_key:
user: "{{ base_user }}"
state: present
key: "{{ lookup('file', '{{ item }}') }}"
with_fileglob:
- "files/*.pub"

0 comments on commit f412dd8

Please sign in to comment.