Add repo foundation: proxmox/lxc/vms groups, ansible.cfg, collections, lint configs

- inventory: add proxmox host, lxc and vms groups, critical_services per host
- retarget bootstrap and time-region to ubuntu:rocky so the Proxmox host is untouched
- add ansible.cfg, collections/requirements.yml, .gitignore, .yamllint, .ansible-lint
- remove stale root new_lxc.yml duplicate and the Nextcloud upgrade playbook

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JEczyvRjfakkiDNkbZA7PR
This commit is contained in:
Harwinder Sekhon
2026-09-06 20:27:50 -04:00
parent d070cbb06c
commit 3f4b067014
14 changed files with 111 additions and 229 deletions
+4 -4
View File
@@ -1,15 +1,15 @@
---
- name: Add plain text public SSH key to root user across mixed OS
hosts: all
become: yes # Elevates privileges to root via sudo
become: true
vars:
# Paste your PUBLIC key string inside the quotes below
my_plain_text_public_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDbFKxd6W+gHcNrugkxMwvixGmk3LxtsMEnSdaFp4L78WZ4VhdZrsnSJQ/rViT+vuc6K5SeugtggfQ90L25UyyMv2BhLZaoMS2dpoVJEZon/Y2Hemm11vdEApAK/u0kPTTM5JB0/TZfpoP9sr4pmRIUruRXBhLDvtUV9tJvKSzbhChtB+vBg+MpywG9VvDP6eCVpFaP43RcAFtJR7irJmexd5m4CVhIFaWNeTbbe8YI08i2gDinYl95ygu9i/TorQKLWme2v9ejxQFfJTWGaXHnQ18W0X94Ns4a4OccGcvJ8JmvYsaAPRAOSveq1Fpdw1VXHSKigTmRl6pHWd9/rq6K6Ojctbjo1kHiNHdLKLZbLDeM0OQlzNl74snsImmZddY59wnOKyHtfY0ZI7sQ+7A/0cSaMY6h7lt2xK0WmayuoT8UtKZlItZHCkOA5bV29arI/HTz+yR/LW8SihPPFpVv5aDiOUs0PYd9j0+CtULBJeYpMQJpkD93g06vgEJjhUOBZ6JmilxVDihDARU0x0xiRCQJcq4Nhk/x3GzPe2kkrTI+nZFaQn1K8hcBdSyA12/xAG8Fh1SMCxLwJdCNuL3gQoYd6XPzKqn6BIqAgiyq5DbHhO6mehOye4Rro6i/H1UkZe862QH/R5uH+8Z2/FYRpiCPzQyLwrqx/eVfT7JMFQ== harwinder@harwinder.net"
my_plain_text_public_key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDbFKxd6W+gHcNrugkxMwvixGmk3LxtsMEnSdaFp4L78WZ4VhdZrsnSJQ/rViT+vuc6K5SeugtggfQ90L25UyyMv2BhLZaoMS2dpoVJEZon/Y2Hemm11vdEApAK/u0kPTTM5JB0/TZfpoP9sr4pmRIUruRXBhLDvtUV9tJvKSzbhChtB+vBg+MpywG9VvDP6eCVpFaP43RcAFtJR7irJmexd5m4CVhIFaWNeTbbe8YI08i2gDinYl95ygu9i/TorQKLWme2v9ejxQFfJTWGaXHnQ18W0X94Ns4a4OccGcvJ8JmvYsaAPRAOSveq1Fpdw1VXHSKigTmRl6pHWd9/rq6K6Ojctbjo1kHiNHdLKLZbLDeM0OQlzNl74snsImmZddY59wnOKyHtfY0ZI7sQ+7A/0cSaMY6h7lt2xK0WmayuoT8UtKZlItZHCkOA5bV29arI/HTz+yR/LW8SihPPFpVv5aDiOUs0PYd9j0+CtULBJeYpMQJpkD93g06vgEJjhUOBZ6JmilxVDihDARU0x0xiRCQJcq4Nhk/x3GzPe2kkrTI+nZFaQn1K8hcBdSyA12/xAG8Fh1SMCxLwJdCNuL3gQoYd6XPzKqn6BIqAgiyq5DbHhO6mehOye4Rro6i/H1UkZe862QH/R5uH+8Z2/FYRpiCPzQyLwrqx/eVfT7JMFQ== harwinder@harwinder.net" # yamllint disable-line rule:line-length
tasks:
- name: Ensure the public key is present in root's authorized_keys
ansible.posix.authorized_key:
user: root
state: present
key: "{{ my_plain_text_public_key }}"
key: "{{ my_plain_text_public_key }}"
+3 -1
View File
@@ -1,3 +1,4 @@
---
- name: Bootstrap - Install packages on Ubuntu
hosts: ubuntu
become: true
@@ -78,7 +79,7 @@
update_cache: true
- name: Bootstrap - Configure SSH access
hosts: all
hosts: ubuntu:rocky
become: true
tasks:
@@ -114,6 +115,7 @@
line: 'PubkeyAuthentication yes'
state: present
# NOTE: playbooks/ssh_harden.yml overrides this via /etc/ssh/sshd_config.d/00-ansible.conf
- name: Ensure PasswordAuthentication is enabled
ansible.builtin.lineinfile:
path: /etc/ssh/sshd_config
+1 -1
View File
@@ -59,4 +59,4 @@
ansible.builtin.debug:
msg: "WARNING: {{ item.split()[-1] }} usage on {{ item.split()[0] }} of {{ inventory_hostname }}"
loop: "{{ disk_usage.stdout_lines }}"
when: (item.split()[-1] | replace('%','') | int) > 85
when: (item.split()[-1] | replace('%', '') | int) > 85
-140
View File
@@ -1,140 +0,0 @@
---
- name: Safe Nextcloud Upgrade Playbook
hosts: nextcloud
become: yes
vars:
nc_path: /var/www/nextcloud
php_bin: /usr/bin/php
tasks:
- name: Pause playbook for 3 seconds
pause:
seconds: 3
prompt: "Press Ctrl+C then A to abort if no backups exist."
###########################################################################
# 1 - CHECK CURRENT INSTALLED VERSION
###########################################################################
- name: 1.1 - Get current NC status
command: "{{ php_bin }} occ status"
args:
chdir: "{{ nc_path }}"
register: nc_status
- name: 1.2 - Extract installed version
set_fact:
installed_version: "{{ nc_status.stdout | regex_search('versionstring: (.*)', '\\1') }}"
- name: 1.3 - Show installed version
debug:
msg: "Current installed version: {{ installed_version }}"
###########################################################################
# 2 - CHECK LATEST AVAILABLE VERSION (via updater.phar)
###########################################################################
- name: 2.1 - Check for available update
command: "{{ php_bin }} updater/updater.phar --check"
args:
chdir: "{{ nc_path }}"
register: update_check
failed_when: false # we want to parse output even if exit code != 0
- name: 2.2 - Parse latest available version
set_fact:
available_version: "{{ update_check.stdout | regex_search('Update to version (.*) available', '\\1') }}"
when: update_check.stdout is search('Update to version')
- name: 2.3 - Show available version
debug:
msg: "Latest available version: {{ available_version | default('NONE') }}"
###########################################################################
# 2.4 - SKIP IF ALREADY UP TO DATE
###########################################################################
- name: 2.4 - Skip upgrade if already on latest version
debug:
msg: "Nextcloud is already up to date ({{ installed_version }}). Skipping upgrade."
when: available_version is not defined
tags: skip_upgrade
changed_when: false
- name: End play if up to date
meta: end_play
when: available_version is not defined
###########################################################################
# 3 - DISABLE APPS + MAINTENANCE MODE
###########################################################################
- name: 3.1 - Enable maintenance mode
command: "{{ php_bin }} occ maintenance:mode --on"
args:
chdir: "{{ nc_path }}"
###########################################################################
# 3.2 - RUN UPDATER WITH RETRIES
###########################################################################
- name: 3.2 - Run Nextcloud CLI updater (retry)
command: "{{ php_bin }} updater/updater.phar --no-interaction"
args:
chdir: "{{ nc_path }}"
register: updater_output
retries: 3
delay: 5
until: updater_output.rc == 0
failed_when: updater_output.rc != 0
###########################################################################
# 3.3 - OCC UPGRADE (DB MIGRATIONS)
###########################################################################
- block:
- name: 3.3 - Run occ upgrade
command: "{{ php_bin }} occ upgrade"
args:
chdir: "{{ nc_path }}"
register: upgrade_run
failed_when: >
upgrade_run.rc != 0 and
"already in process" not in upgrade_run.stdout and
"maintenance mode" not in upgrade_run.stdout
rescue:
- name: 3.3R - Handle locked upgrade
debug:
msg: "Upgrade appears stuck. Removing maintenance lock and retrying."
- name: Remove maintenance mode flag from config.php
lineinfile:
path: "{{ nc_path }}/config/config.php"
regexp: "'maintenance' => true"
line: " 'maintenance' => false,"
backrefs: yes
- name: Retry OCC upgrade
command: "{{ php_bin }} occ upgrade"
args:
chdir: "{{ nc_path }}"
register: upgrade_retry
failed_when: upgrade_retry.rc != 0
###########################################################################
# 4 - ALWAYS DISABLE MAINTENANCE MODE
###########################################################################
- name: ALWAYS disable maintenance mode
command: "{{ php_bin }} occ maintenance:mode --off"
args:
chdir: "{{ nc_path }}"
ignore_errors: true
###########################################################################
# 5 - FINAL RESULT
###########################################################################
- name: Show final upgrade result
debug:
msg: |
✔ Nextcloud upgrade completed.
Installed: {{ installed_version }}
Updated to: {{ available_version }}
Check logs if issues appear:
- {{ nc_path }}/data/updater.log
- {{ nc_path }}/data/nextcloud.log
+2 -2
View File
@@ -1,7 +1,7 @@
---
- name: Ping all servers
hosts: all
gather_facts: no
gather_facts: false
tasks:
- name: Test connectivity with ping
ansible.builtin.ping:
+3 -3
View File
@@ -1,6 +1,6 @@
---
- name: Configure timezone on all hosts
hosts: all
hosts: ubuntu:rocky
become: true
gather_facts: true
@@ -101,7 +101,7 @@
enabled: true
- name: Verify time configuration
hosts: all
hosts: ubuntu:rocky
become: true
tasks:
@@ -112,4 +112,4 @@
- name: Summary
ansible.builtin.debug:
msg: "{{ inventory_hostname }} ({{ ansible_virtualization_type | default('unknown') }}) - {{ check_time.stdout }}"
msg: "{{ inventory_hostname }} ({{ ansible_virtualization_type | default('unknown') }}) - {{ check_time.stdout }}"
+2 -1
View File
@@ -1,3 +1,4 @@
---
- name: Check Host Availability
hosts: all
gather_facts: false
@@ -43,4 +44,4 @@
ansible.builtin.dnf:
name: "*"
state: latest
update_cache: true
update_cache: true