mirror of
https://github.com/lemeow125/ansible-playbooks.git
synced 2025-04-27 10:11:18 +08:00
Update playbooks
This commit is contained in:
parent
46250f9a99
commit
2150c17f24
14 changed files with 315 additions and 9 deletions
41
roles/tasks/debian/README.md
Normal file
41
roles/tasks/debian/README.md
Normal file
|
@ -0,0 +1,41 @@
|
|||
## Usage
|
||||
|
||||
### Setup
|
||||
|
||||
1. Run `setup.yml` using a non-sudo user, providing regular and sudo credentials.
|
||||
|
||||
```bash
|
||||
ansible-playbook roles/tasks/debian/setup.yml -u keannu125 -k --ask-become-pass
|
||||
```
|
||||
|
||||
This will elevate to `root` user via `sudo` and set up root SSH access through the provided `id_rsa.pub` file in the control node's own `.ssh` directory
|
||||
|
||||
2. Set up the necessary template scripts provided at `/root/scripts`
|
||||
|
||||
- Rename `.env.sample` to `.env.` (via `mv .env.sample .env`)
|
||||
- Provide your ACME SSL access tokens in the `.env` for `renew_ssl.sh` to parse
|
||||
- Provide project directories to spin up on boot through `start_services.sh`
|
||||
- Provide the same project directories to back up via Borg in `backup.sh`
|
||||
|
||||
3. Update the Samba credentials file located at `/root/.samba`
|
||||
|
||||
```
|
||||
# credentials
|
||||
user=USERNAME
|
||||
password=PASSWORD
|
||||
```
|
||||
|
||||
4. Update the CIFS/Samba mount for backups located in `crontab` (via `crontab -e`)
|
||||
|
||||
```
|
||||
# crontab entry
|
||||
* * * * * mount.cifs "//255.255.255.0/SAMBA-MOUNT" "/mnt/backups" -o credentials="/root/.samba/credentials"
|
||||
```
|
||||
|
||||
If you'd need to run the `setup.yml` playbook again for any reason. You can omit specifying user or sudo credentials and simply run
|
||||
|
||||
```bash
|
||||
ansible-playbook roles/tasks/debian/setup.yml
|
||||
```
|
||||
|
||||
Any existing or additional scripts that have already been modified will not be overwritten (See `force: false` directives in [`setup.yml`](./setup.yml))
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
- hosts:
|
||||
- debian
|
||||
# Runs on root user already
|
||||
become: false
|
||||
become: true
|
||||
vars_files: "{{ playbook_dir | dirname | dirname | dirname }}/inventory/group_vars/debian.yml"
|
||||
tasks:
|
||||
- name: Add SSH key to authorized_hosts - Debian
|
||||
authorized_key:
|
||||
|
@ -10,11 +10,27 @@
|
|||
state: present
|
||||
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
|
||||
path: /root/.ssh/authorized_keys
|
||||
- name: Enable Root Login
|
||||
lineinfile:
|
||||
dest: /etc/ssh/sshd_config
|
||||
regexp: "^PermitRootLogin"
|
||||
line: "PermitRootLogin yes"
|
||||
state: present
|
||||
notify: Restart SSHD on Config Change
|
||||
- name: Update all packages
|
||||
apt:
|
||||
update_cache: true
|
||||
autoremove: true
|
||||
state: latest
|
||||
- name: Install Docker
|
||||
apt:
|
||||
name:
|
||||
- docker
|
||||
update_cache: false
|
||||
autoremove: true
|
||||
state: latest
|
||||
# Safety net if this script is ran twice
|
||||
notify: Restart Docker Containers
|
||||
- name: Install packages - Debian
|
||||
apt:
|
||||
name:
|
||||
|
@ -23,7 +39,6 @@
|
|||
- htop
|
||||
- tmux
|
||||
- samba
|
||||
- docker
|
||||
- docker-compose
|
||||
- neofetch
|
||||
- cifs-utils
|
||||
|
@ -32,9 +47,47 @@
|
|||
- syncthing
|
||||
- socat
|
||||
- fish
|
||||
- iperf3
|
||||
# Cache is already updated from previous step
|
||||
update_cache: false
|
||||
autoremove: true
|
||||
state: latest
|
||||
- name: Install ACME
|
||||
command: curl https://get.acme.sh | sh -s email=noehbernasol0@gmail.com
|
||||
shell: curl https://get.acme.sh | sh -s email="{{ ACME_EMAIL }}"
|
||||
- name: Enable Syncthing Service
|
||||
command: systemctl enable syncthing@root.service
|
||||
- name: Allow Syncthing Remote Management
|
||||
replace:
|
||||
path: /root/.config/syncthing/config.xml
|
||||
regexp: "<address>127.0.0.1:8384</address>"
|
||||
replace: "<address>0.0.0.0:8384</address>"
|
||||
notify: Restart Syncthing Service
|
||||
- name: Copy Template Scripts
|
||||
copy:
|
||||
src: "{{ playbook_dir | dirname | dirname }}/files/debian/setup/scripts/"
|
||||
dest: /root/scripts/
|
||||
mode: "0644"
|
||||
force: false
|
||||
- name: Copy Crontab Template
|
||||
copy:
|
||||
src: "{{ playbook_dir | dirname | dirname }}/files/debian/setup/crontabs/"
|
||||
dest: /var/spool/cron/crontabs/
|
||||
mode: "0600"
|
||||
force: false
|
||||
- name: Copy Samba Credentials Template
|
||||
copy:
|
||||
src: "{{ playbook_dir | dirname | dirname }}/files/debian/setup/samba/"
|
||||
dest: /root/.samba/
|
||||
mode: "0644"
|
||||
force: false
|
||||
|
||||
handlers:
|
||||
# Restart Syncthing on Config Change
|
||||
- name: Restart Syncthing Service
|
||||
command: systemctl restart syncthing@root.service
|
||||
# Restart SSHD on Config Change
|
||||
- name: Restart SSHD on Config Change
|
||||
command: systemctl restart sshd
|
||||
# Restart Docker Containers on Docker Update
|
||||
- name: Restart Docker Containers
|
||||
command: bash /root/scripts/start_services.sh
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
# Runs on root user already
|
||||
become: false
|
||||
tasks:
|
||||
- name: Restart all services
|
||||
- name: Start all services
|
||||
command: bash /root/scripts/start_services.sh
|
|
@ -4,10 +4,23 @@
|
|||
# Runs on root user already
|
||||
become: false
|
||||
tasks:
|
||||
- name: Update Docker
|
||||
apt:
|
||||
name:
|
||||
- docker
|
||||
update_cache: true
|
||||
autoremove: true
|
||||
state: latest
|
||||
notify: Restart Docker Containers
|
||||
- name: Update all packages
|
||||
apt:
|
||||
update_cache: true
|
||||
update_cache: false
|
||||
autoremove: true
|
||||
state: latest
|
||||
- name: Update ACME
|
||||
command: /root/.acme.sh/acme.sh --upgrade --auto-upgrade
|
||||
|
||||
handlers:
|
||||
# Restart Docker Containers on Docker Update
|
||||
- name: Restart Docker Containers
|
||||
command: bash /root/scripts/start_services.sh
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue