Compare commits

...

24 Commits

Author SHA1 Message Date
max db217f4ce2 Merge pull request 'feat(maintenance): new checks added, existing improved' (#6) from dev into main
Reviewed-on: #6
2026-08-24 13:32:09 +04:00
max cdfcc844e0 FIX: encloses the variable name with brackets and double quotes
Deploy new config to the Ansible server / trigger-webhook (pull_request) Successful in 26s
2026-08-24 14:20:24 +05:00
max 71a98b34ca FEATURE: replaces hardcoded ip of proxmox with a variable 2026-08-24 14:11:42 +05:00
max d2ee60c0fb FIX: become password added to drive resize task 2026-08-24 12:49:18 +04:00
max baab14c3fc FIX: adds 'children' directive in inventory/hosts.yaml 2026-08-23 17:05:57 +05:00
max 5e253db9c7 FEATURE: resizes rootfs if a host is LXC and its rootfs is almost full 2026-08-23 17:02:01 +05:00
max 54ec2bdbee FEATURE: adds proxmox host to inventory, but excludes it from playbooks/maintain.yaml 2026-08-23 17:00:23 +05:00
max 91d4dabea8 FEATURE: adds domain names to hosts 2026-08-23 15:00:00 +05:00
max 857813d78f FIX: errors from the previous commit 2026-08-23 14:51:07 +05:00
max 9200553be6 FEATURE: new host added, list of services to check added to hosts. Services checker added 2026-08-23 14:29:45 +05:00
max d833004dee FEATURE: adds a prompt about un/privileged LXC 2026-08-21 20:29:50 +04:00
max 43ce6a94c0 Merge pull request 'CHANGE: ensures pulls and updates before running jobs' (#4) from dev into main
Reviewed-on: #4
2026-08-18 21:24:44 +04:00
max e9d38ece4d CHANGE: removes unnecessary steps from the gitea action
Deploy new config to the Ansible server / trigger-webhook (pull_request) Successful in 14s
2026-08-18 21:22:38 +04:00
max 04894aef9f CHANGE: ensures pulls and updates before running jobs 2026-08-18 16:57:27 +04:00
max 1ecc1775ef Merge pull request 'FIX: file extensions in update_modules.sh' (#3) from dev into main
Reviewed-on: #3
2026-08-18 15:54:22 +04:00
max b698108980 FIX: file extensions in update_modules.sh
Deploy new config to the Ansible server / trigger-webhook (pull_request) Successful in 14s
2026-08-18 15:51:58 +04:00
max 1ed42f148c Merge pull request 'feat(all): updates some configs' (#2) from dev into main
Reviewed-on: #2
2026-08-18 15:41:32 +04:00
max 5215f8d082 CHANGE: adds new webhooks to the gitea action
Deploy new config to the Ansible server / trigger-webhook (pull_request) Successful in 24s
2026-08-18 13:36:29 +04:00
max 122157eeeb CHANGE: updates inventory 2026-08-18 13:00:22 +04:00
max 6d584bc582 CHANGE: updates systemd service and timer 2026-08-18 13:00:01 +04:00
max 0daa4a4cf9 CHANGE: adds a lock file to the scripts 2026-08-18 12:49:54 +04:00
max 09145ac1e5 CHANGE: moves scripts into a new directory 2026-08-18 12:29:48 +04:00
max 271213d1ca CHANGE: adds ansible requirements file and a script for updating it on production machines, updates pip requirements 2026-08-18 12:26:49 +04:00
max ca24bb73dc CHANGE: drops unnecessary lines from maintain playbook 2026-08-17 16:26:15 +04:00
18 changed files with 147 additions and 39 deletions
+1 -1
View File
@@ -16,6 +16,6 @@ jobs:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Trigger the webhook to start pulling new Ansible configs
- name: Trigger the webhook to run the playbook
# LAN IP is used because those hosts are in the same network
run: curl "http://192.168.0.38:9000/hooks/run-maintain-playbook"
+1
View File
@@ -2,3 +2,4 @@
ansible_become_passwd: "{{ ansible_password }}"
human_admin_user: max
proxmox_1_host: 192.168.0.2
+32 -4
View File
@@ -1,13 +1,41 @@
---
physical:
all:
children:
physical:
proxmox_1:
ansible_host: "{{ proxmox_1_host }}"
ansible_become_password: "{{ ansible_become_passwd }}"
services_to_run: []
virtual:
hosts:
localhost:
ansible_become_password: "{{ ansible_become_passwd }}"
ansible_connection: local
ansible_python_interpreter: "{{ ansible_playbook_python }}"
192.168.0.98:
services_to_run:
- webhook
nfs-server:
ansible_host: 192.168.0.6
ansible_become_password: "{{ ansible_become_passwd }}"
192.168.0.6:
services_to_run: []
jellyfin:
ansible_host: 192.168.0.8
ansible_become_password: "{{ ansible_become_passwd }}"
192.168.0.8:
services_to_run: []
frigate:
ansible_host: 192.168.0.12
ansible_become_password: "{{ ansible_become_passwd }}"
services_to_run: []
vs-code:
ansible_host: 192.168.0.16
ansible_become_password: "{{ ansible_become_passwd }}"
services_to_run: []
gitea-server:
ansible_host: 192.168.0.39
ansible_become_password: "{{ ansible_become_passwd }}"
services_to_run: []
ai-host:
ansible_host: 192.168.0.50
ansible_become_password: "{{ ansible_become_passwd }}"
services_to_run:
- coder_ai
@@ -25,6 +25,10 @@
prompt: "IP address for the container (in x.x.x.x/x formant)"
private: false
- name: lxc_is_privileged
prompt: "Unprivileged LXC (true/false)?"
private: false
pre_tasks:
- name: Validate hostname
ansible.builtin.fail:
+3 -4
View File
@@ -1,13 +1,10 @@
---
- name: Deploy and set up an LXC container in Proxmox
hosts: all
hosts: virtual
remote_user: ansible
vars_files:
../inventory/group_vars/all/secrets.yaml
vars:
ansible_user_passwd_hash: "{{ ansible_password | password_hash('sha512', 's3edscrj45e6r') }}"
user_passwd_hash: "{{ user_password | password_hash('sha512', 's3ed6123jhgcr') }}"
roles:
# Check the Internet connection
@@ -21,3 +18,5 @@
- ../roles/harden_ssh
# Update configs - omz, nvim, ranger and so on. Distribute the last version of those configs
- ../roles/update_configs
# Make sure that the services that are supposed to run are running
- ../roles/check_services
+7 -2
View File
@@ -4,29 +4,34 @@ ansible-lint==26.6.0
attrs==26.1.0
black==26.5.1
bracex==3.0
certifi==2026.7.22
cffi==2.1.0
charset-normalizer==3.4.9
click==8.4.2
cryptography==49.0.0
distro==1.9.0
filelock==3.29.7
idna==3.18
Jinja2==3.1.6
jsonschema==4.26.0
jsonschema-specifications==2025.9.1
MarkupSafe==3.0.3
mypy_extensions==1.1.0
netaddr==1.3.0
packaging==26.2
pathspec==1.1.1
platformdirs==4.10.0
proxmoxer>=2.3
proxmoxer==2.3.0
pycparser==3.0
pytokens==0.4.1
PyYAML==6.0.3
referencing==0.37.0
requests>=2.34.2
requests==2.34.2
resolvelib==1.2.1
rpds-py==2026.6.3
ruamel.yaml==0.19.1
ruamel.yaml.clib==0.2.15
subprocess-tee==0.4.2
urllib3==2.7.0
wcmatch==11.0
yamllint==1.38.0
+17
View File
@@ -0,0 +1,17 @@
---
collections:
- name: ansible.posix
version: 2.2.2
- name: ansible.utils
version: 6.0.3
- name: community.general
version: 13.2.0
- name: community.library_inventory_filtering_v1
version: 1.1.5
- name: community.proxmox
version: 2.0.0
+7
View File
@@ -0,0 +1,7 @@
---
- name: Make sure required services are running
ansible.builtin.service:
name: "{{ item }}"
state: started
loop: "{{ services_to_run }}"
+7 -3
View File
@@ -23,8 +23,8 @@
become: false
# We have to use this complicated pipeline because of Alpine and its wierd df implementation
ansible.builtin.shell: set -o pipefail && df -h / | tail -1 | awk '{gsub(/%/, "", $5); print $5}'
register: free_disk_space_result
failed_when: free_disk_space_result.stdout | int > 85
register: common_healthcheck_space_left_result
failed_when: common_healthcheck_space_left_result.stdout | int > 85
changed_when: false # This task does not change the system
rescue:
@@ -41,5 +41,9 @@
body:
- "{{ ansible_facts['hostname'] }}: Disk space is low"
delegate_to: 127.0.0.1
failed_when: false
failed_when: false # It's OK if it fails, not critical
changed_when: false # This task does not change the system
- name: Resize rootfs if it's an LXC
ansible.builtin.include_tasks: resize_lxc_rootfs.yaml
when: ansible_virtualization_type == 'lxc'
@@ -0,0 +1,24 @@
---
- name: Get container info by name
delegate_to: localhost
become: false
community.general.proxmox_vm_info:
validate_certs: false
node: proxmox-server
api_user: root@pam
api_host: 192.168.0.2
api_token_id: ansible
api_token_secret: "{{ proxmox_token_secret }}"
name: "{{ inventory_hostname }}"
type: lxc
register: common_healthcheck_vmid
- name: Resize LXC's rootfs
become: true
ansible.builtin.command:
cmd: pct resize {{ common_healthcheck_vmid.proxmox_vms[0].vmid }} rootfs +5G
delegate_to: 192.168.0.2
changed_when: true
vars:
ansible_become_password: "{{ ansible_become_passwd }}"
+3 -2
View File
@@ -6,7 +6,7 @@
validate_certs: false
node: proxmox-server
api_user: root@pam
api_host: 192.168.0.2
api_host: "{{ proxmox_1_host }}"
api_token_id: ansible
api_token_secret: "{{ proxmox_token_secret }}"
@@ -14,6 +14,7 @@
password: "{{ lxc_root_password }}"
hostname: "{{ lxc_hostname }}"
ostemplate: 'main:vztmpl/debian-13-golden-image.tar.gz'
unprivileged: "{{ lxc_is_privileged }}"
memory: 2048
cores: 2
state: present
@@ -33,7 +34,7 @@
validate_certs: false
node: proxmox-server
api_user: root@pam
api_host: 192.168.0.2
api_host: "{{ proxmox_1_host }}"
api_token_id: ansible
api_token_secret: "{{ proxmox_token_secret }}"
@@ -6,7 +6,7 @@
validate_certs: false
node: proxmox-server
api_user: root@pam
api_host: 192.168.0.2
api_host: "{{ proxmox_1_host }}"
api_token_id: ansible
api_token_secret: "{{ proxmox_token_secret }}"
@@ -29,7 +29,7 @@
validate_certs: false
node: proxmox-server
api_user: root@pam
api_host: 192.168.0.2
api_host: "{{ proxmox_1_host }}"
api_token_id: ansible
api_token_secret: "{{ proxmox_token_secret }}"
@@ -49,7 +49,7 @@
validate_certs: false
node: proxmox-server
api_user: root@pam
api_host: 192.168.0.2
api_host: "{{ proxmox_1_host }}"
api_token_id: ansible
api_token_secret: "{{ proxmox_token_secret }}"
@@ -64,10 +64,9 @@
validate_certs: false
node: proxmox-server
api_user: root@pam
api_host: 192.168.0.2
api_host: "{{ proxmox_1_host }}"
api_token_id: ansible
api_token_secret: "{{ proxmox_token_secret }}"
name: "{{ vm_hostname }}"
state: started
+1 -1
View File
@@ -5,7 +5,7 @@
validate_certs: false
node: proxmox-server
api_user: root@pam
api_host: 192.168.0.2
api_host: "{{ proxmox_1_host }}"
api_token_id: ansible
api_token_secret: "{{ proxmox_token_secret }}"
@@ -6,7 +6,7 @@
validate_certs: false
node: proxmox-server
api_user: root@pam
api_host: 192.168.0.2
api_host: "{{ proxmox_1_host }}"
api_token_id: ansible
api_token_secret: "{{ proxmox_token_secret }}"
@@ -19,4 +19,3 @@
timeout: 120
delegate_to: localhost
changed_when: false
@@ -1,3 +1,11 @@
#!/bin/bash
# 1 - Pull the latest code
git pull origin main
# 2 - Update dependencies and modules
./scripts/update_modules.sh
# 3 - Run the job
source .venv/bin/activate
ansible-playbook playbooks/maintain.yaml --vault-pass-file ~/vault_password -i inventory/hosts.yaml --private-key ~/.ssh/ansible_key
+12
View File
@@ -0,0 +1,12 @@
#!/bin/bash
source .venv/bin/activate
# Install python packages
pip install -r requirements.txt
# Install collections from the file
ansible-galaxy collection install -r requirements.yaml -p ./collections/
# Install roles
ansible-galaxy role install -r requirements.yaml -p ./roles/
+4 -4
View File
@@ -6,10 +6,10 @@ Wants=network-online.target
[Service]
Type=oneshot
# CAHNGE TO MATCH YOUR REQUIREMENTS
User=max
Group=max
WorkingDirectory=/home/max/projects/ansible_home
ExecStart=/home/max/projects/ansible_home/run_playbook.sh /home/max/projects/ansible_home/playbooks/maintain.yaml
User=ansible
Group=ansible
WorkingDirectory=/home/ansible/ansible-production
ExecStart=/home/ansible/ansible-production/run_maintain_playbook.sh
StandardOutput=journal
StandardError=journal
# Optional: prevent runaway if the playbook hangs
+2 -2
View File
@@ -1,9 +1,9 @@
[Unit]
Description=Timer for Ansible maintenance playbook, runs every 10 minutes
Description=Timer for Ansible maintenance playbook, runs every day
Requires=ansible-maintenance.service
[Timer]
OnUnitActiveSec=10min
OnUnitActiveSec=1d
Persistent=true
Unit=ansible-maintenance.service