-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaddAdminUser.yml
More file actions
41 lines (33 loc) · 999 Bytes
/
addAdminUser.yml
File metadata and controls
41 lines (33 loc) · 999 Bytes
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
35
36
37
38
39
40
41
# This playbook adds an admin user with the given name to all machines.
# It creates a linux user, adds it to sudo group and puts the ssh key to all machines.
# The Google Authenticator file is only put to the jumphosts.
# The parameters `username` and `path_to_google_auth` are required.
# Usage:
# ansible-playbook addAdminUser.yml --extra-vars "username=tacocat path_to_google_auth=absolute/path/to/.google_authenticator"
- hosts:
- all
become: yes
become_user: root
pre_tasks:
- name: Create a linux sudo user
user:
name: "{{ username }}"
create_home: yes
state: present
groups: sudo
append: yes
shell: /bin/bash
roles:
- role: add_ssh_key
vars:
username: "{{ username }}"
# Put the GA file only on jumphost
- hosts:
- jumphost
become: yes
become_user: root
roles:
- role: add_GA_file
vars:
username: "{{ username }}"
path_to_google_auth: "{{ path_to_google_auth }}"