-
Notifications
You must be signed in to change notification settings - Fork 0
/
jmdroplet.yml
85 lines (72 loc) · 2 KB
/
jmdroplet.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# export ANSIBLE_BECOME_PASS=....
#
# adduser jm && usermod -aG sudo jm
# mkdir -p /home/jm/.ssh && chmod 0700 /home/jm/.ssh && cp /root/.ssh/authorized_keys /home/jm/.ssh/authorized_keys && chmod 0600 /home/jm/.ssh/authorized_keys && chown -R jm:jm /home/jm/.ssh
# sudo apt update
#
---
- hosts: jmdroplet
vars:
roles:
- base
tasks:
- name: install nginx
apt: pkg=nginx state=present
become: True
tags: [nginx]
- name: install fail2ban
apt: pkg=fail2ban state=present
become: true
- name: Delete root password
user:
name: root
password: ""
become: yes
- name: Remove authorized_keys file for root user
file:
path: /root/.ssh/authorized_keys
state: absent
become: yes
- name: Disallow root SSH access
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "^PermitRootLogin"
line: "PermitRootLogin no"
state: present
become: yes
notify: Restart sshd
- name: Disallow password authentication
lineinfile:
dest: /etc/ssh/sshd_config
regexp: "^PasswordAuthentication"
line: "PasswordAuthentication no"
state: present
become: yes
notify: Restart sshd
- name: create the website directory
become: yes
file: path=/opt/apps state=directory
- name: create the website config
become: yes
file: path=/opt/nginx state=directory
- name: add certbot PPA
become: True
apt_repository: repo=ppa:certbot/certbot
- name: install certbot
apt: pkg=python-certbot-nginx state=present
become: true
- name: install DO certbot
apt: pkg=python3-certbot-dns-digitalocean state=present
become: true
- name: install redis
apt: pkg=redis state=present
become: true
- name: install msmtp
apt: pkg=msmtp state=present
become: true
handlers:
- name: Restart sshd
service:
name: ssh
state: restarted
become: yes