-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_server.yml
62 lines (53 loc) · 1.18 KB
/
setup_server.yml
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
---
- name: Create Ansible user
hosts: testubuntu1
remote_user: itadmin
become: true
tasks:
- name: Create Ansible group
group:
name: ansible
gid: 20000
state: present
- name: Create user Ansible
user:
name: ansible
createhome: yes
uid: 20000
group: ansible
state: present
- name: Copy SSH key
authorized_key:
user: ansible
key: "{{ lookup('file', './ssh/id_rsa.pub') }}"
key_options: 'no-port-forwarding'
- name: Install Sudo
package:
name: sudo
state: present
- name: Add ansible user to sudoers
copy:
dest: /etc/sudoers.d/ansible
content: 'ansible ALL= NOPASSWD: ALL'
owner: root
group: root
mode: 0500
- name: Create user
user:
name: mo
createhome: yes
uid: 1337
state: present
shell: /bin/bash
- name: Copy SSH key
authorized_key:
user: mo
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
key_options: 'no-port-forwarding'
- name: Add user to sudoers
copy:
dest: /etc/sudoers.d/mo
content: 'mo ALL= NOPASSWD: ALL'
owner: root
group: root
mode: 0500