-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinitializeJumpHosts.yml
More file actions
78 lines (62 loc) · 1.83 KB
/
initializeJumpHosts.yml
File metadata and controls
78 lines (62 loc) · 1.83 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Run this playbook to initialise your machines: The jumphosts, the rsync machine and all services.
# It sets up the firewall, disables root login, creates admin users, puts their ssh keys to the machines.
# It installs GA and the Google Authenticator file to the jumphosts.
# Example run:
# ansible-playbook initialize.yml --extra-vars "@/path/to/admins.yml"
# ansible-playbook initialize.yml --extra-vars "@/home/jacoba/dev/stf-php-ansible/etc/admins.yml"
# Add admin user and pubkey everywhere
- hosts:
- jumphost
remote_user: root
tasks:
- name: Create a linux user and add it to sudo group
user:
name: "{{ item.name }}"
create_home: yes
state: present
groups: sudo
append: yes
shell: /bin/bash
loop: "{{ admins }}"
# Allow members of group sudo to execute any command without specifying their password
- name: Configure sudoers
copy:
dest: /etc/sudoers.d/20-sudo-password
content: "%sudo ALL=(ALL) NOPASSWD: ALL"
- name: Copy admin's ssh-keys
loop: "{{ admins }}"
include_role:
name: add_ssh_key
vars:
username: "{{ item.name }}"
pubkeys: "{{ item.pubkeys }}"
# Install Google Authenticator and copy GA file on jumphosts
- hosts:
- jumphost
remote_user: root
tasks:
- name: Copy admin's Google Authenticator files
loop: "{{ admins }}"
include_role:
name: add_GA_file
vars:
username: "{{ item.name }}"
path_to_google_auth: "{{ item.GA_file }}"
roles:
- role: install_GA
# Disable root login at the very end
- hosts:
- jumphost
remote_user: root
tasks:
- name: Disable root login
lineinfile:
path: /etc/ssh/sshd_config
regexp: ^PermitRootLogin
line: PermitRootLogin no
notify: restart ssh
handlers:
- name: restart ssh
service:
name: ssh
state: restarted