-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook.yml
executable file
·101 lines (83 loc) · 2.45 KB
/
playbook.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
---
- hosts: all
become: true
vars_files:
- vars/default.yml
tasks:
- name: Install Prerequisites
apt: name=aptitude update_cache=yes state=latest force_apt_get=yes
# Sudo Group Setup
- name: Make sure we have a 'wheel' group
group:
name: wheel
state: present
- name: Allow 'wheel' group to have passwordless sudo
lineinfile:
path: /etc/sudoers
state: present
regexp: '^%wheel'
line: '%wheel ALL=(ALL) NOPASSWD: ALL'
validate: '/usr/sbin/visudo -cf %s'
# User + Key Setup
- name: Create a new regular user with sudo privileges
user:
name: "{{ create_user }}"
state: present
groups: wheel
append: true
create_home: true
shell: /bin/bash
- name: Set authorized key for remote user
authorized_key:
user: "{{ create_user }}"
state: present
key: "{{ copy_local_key }}"
- name: Disable password authentication for root
lineinfile:
path: /etc/ssh/sshd_config
state: present
regexp: '^#?PermitRootLogin'
line: 'PermitRootLogin prohibit-password'
# Upgrade All Packages
- name: Upgrade all packages to the latest version
apt:
name: "*"
state: latest
# Install Packages
- name: Update apt
apt: update_cache=yes
- name: Install required system packages
apt: name={{ sys_packages }} state=latest
# Setup Weather 'app'
- name: Install pip for python3
command: pip3 install matplotlib
- name: Remove lighttpd default index
command: rm -rf /var/www/html/index.lighttpd.html
- name: Create Website
shell: |
echo '<img src="weather_graph.png">' > /var/www/html/index.html
- name: Copy weather script
template:
src: get_weather.py.j2
dest: /etc/cron.hourly/get_weather.py
mode: '0744'
- name: Run weather program
shell: |
/usr/bin/python3 /etc/cron.hourly/get_weather_py
# UFW Setup
- name: UFW - Allow SSH connections
ufw:
rule: allow
name: OpenSSH
- name: UFW - Allow http connections
ufw:
rule: allow
name: Lighttpd HTTP
- name: UFW - Deny all other incoming traffic by default
ufw:
state: enabled
policy: deny
direction: incoming
- name: Reboot machine after updates were installed
reboot:
reboot_timeout: 600