-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase.yaml
66 lines (56 loc) · 1.63 KB
/
base.yaml
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
---
- hosts: all
become: true
vars:
- key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}"
- packages: [ 'curl', 'vim', 'git', 'ufw', 'fail2ban', 'zip', 'unzip', 'php-zip']
tasks:
- name: Update and upgrade apt packages
apt:
upgrade: "yes"
update_cache: yes
cache_valid_time: 86400 #One day
- name: Make sure we have a 'wheel' group
group:
name: wheel
state: present
- name: Create a new regular user with sudo privileges
user:
name: "{{ deploy_user }}"
state: present
groups: wheel
append: true
create_home: true
shell: /bin/bash
- name: Add deploy user to sudo
lineinfile:
path: /etc/sudoers.d/deploy
line: 'deploy ALL=(ALL) NOPASSWD: ALL'
state: present
mode: 0440
create: yes
validate: 'visudo -cf %s'
- name: Set authorized key for remote user
authorized_key:
user: "{{ deploy_user }}"
state: present
key: "{{ key }}"
- name: Disable password authentication for root
lineinfile:
path: /etc/ssh/sshd_config
state: present
regexp: '^#?PermitRootLogin'
line: 'PermitRootLogin prohibit-password'
- name: Update apt
apt: update_cache=yes
- name: Install required system packages
apt: name={{ packages }} state=present
- name: UFW - Allow SSH connections
ufw:
rule: allow
name: OpenSSH
- name: UFW - Deny all other incoming traffic by default
ufw:
state: enabled
policy: deny
direction: incoming