This repository was archived by the owner on Nov 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaybook.yml
More file actions
98 lines (83 loc) · 2.13 KB
/
playbook.yml
File metadata and controls
98 lines (83 loc) · 2.13 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
- name: Update apt packages
apt:
update_cache: "yes"
force_apt_get: "yes"
- name: Install packages needed for Docker
apt:
name: "{{ docker_packages }}"
state: present
force_apt_get: "yes"
- name: Add Docker GPG apt Key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Save the current Ubuntu release version into a variable
shell: lsb_release -cs
register: ubuntu_version
- name: Add Docker Repository
apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ubuntu_version.stdout }} stable"
state: present
- name: Update apt packages
apt:
update_cache: "yes"
force_apt_get: "yes"
- name: Install Docker
apt:
name: "docker-ce"
state: present
force_apt_get: "yes"
- name: Install Docker Compose
get_url:
url: https://github.com/docker/compose/releases/download/{{ docker_compose_version }}/docker-compose-Linux-x86_64
dest: "/usr/local/bin/docker-compose"
mode: 0755
- name: Create docker group
group:
name: "docker"
state: present
- name: Add a new functional user "drone"
user:
name: drone
password: {{ drone_password }}
group: docker
- name: Add a user named debug for developers
user:
name: debug
password: {{ debug_password }}
groups: sudo,docker
append: yes
- name: Deploy SSH Key for drone
authorized_key:
user: drone
key: "{{ lookup('file', './keys/drone.pubkey' }}"
state: present
- name: Deploy SSH Key for debug
authorized_key:
user: debug
key: "{{ lookup('file', './keys/debug.pubkey' }}"
state: present
- name: Disable Password Authentication
lineinfile:
dest=/etc/ssh/sshd_config
regexp='^PasswordAuthentication'
line="PasswordAuthentication no"
state=present
backup=yes
notify:
- restart ssh
- name: Disable Root Login
lineinfile:
dest=/etc/ssh/sshd_config
regexp='^PermitRootLogin'
line="PermitRootLogin no"
state=present
backup=yes
notify:
- restart ssh
handlers:
- name: restart ssh
service:
name: sshd
state: restarted