commit c8894687067a6982e258521666008244d5dc34a4 Author: Michael Date: Sat Mar 21 17:42:45 2026 +0000 Initial commit diff --git a/backup/list.yml b/backup/list.yml new file mode 100644 index 0000000..c578701 --- /dev/null +++ b/backup/list.yml @@ -0,0 +1,5 @@ +- hosts: localhost + tasks: + - name: List backup sets (simulated) + ansible.builtin.debug: + msg: "Simulating listing of backup sets." diff --git a/backup/restore.yml b/backup/restore.yml new file mode 100644 index 0000000..de2da80 --- /dev/null +++ b/backup/restore.yml @@ -0,0 +1,5 @@ +- hosts: localhost + tasks: + - name: Restore backup (simulated) + ansible.builtin.debug: + msg: "Simulating restoring backup with ID: {{ id }}" diff --git a/backup/run.yml b/backup/run.yml new file mode 100644 index 0000000..3ecc916 --- /dev/null +++ b/backup/run.yml @@ -0,0 +1,5 @@ +- hosts: localhost + tasks: + - name: Trigger rsync.net job (simulated) + ansible.builtin.debug: + msg: "Simulating rsync.net backup job trigger." diff --git a/git/commit.yml b/git/commit.yml new file mode 100644 index 0000000..f27c58e --- /dev/null +++ b/git/commit.yml @@ -0,0 +1,12 @@ +- hosts: localhost + tasks: + - name: Create dummy file for commit + ansible.builtin.copy: + content: "{{ ansible_date_time.iso8601_micro }}" + dest: "/data/mcp-history/dummy_file.txt" + + - name: Commit current state + ansible.builtin.command: git -C /data/mcp-history add . + + - name: Commit with message + ansible.builtin.command: git -C /data/mcp-history commit -m "{{ message }}" diff --git a/git/rollback.yml b/git/rollback.yml new file mode 100644 index 0000000..ca14149 --- /dev/null +++ b/git/rollback.yml @@ -0,0 +1,4 @@ +- hosts: localhost + tasks: + - name: Rollback to specific SHA + ansible.builtin.command: git -C /data/mcp-history reset --hard {{ sha }} diff --git a/log/tail.yml b/log/tail.yml new file mode 100644 index 0000000..36ccae9 --- /dev/null +++ b/log/tail.yml @@ -0,0 +1,9 @@ +- hosts: localhost + tasks: + - name: Tail logs for service + ansible.builtin.command: journalctl -u {{ service }} -n {{ lines }} + register: log_output + + - name: Print logs + ansible.builtin.debug: + var: log_output.stdout_lines diff --git a/lxd/launch.yml b/lxd/launch.yml new file mode 100644 index 0000000..5212ae8 --- /dev/null +++ b/lxd/launch.yml @@ -0,0 +1,4 @@ +- hosts: localhost + tasks: + - name: Launch LXD container + ansible.builtin.shell: lxc launch {{ image }} {{ name }} diff --git a/lxd/list.yml b/lxd/list.yml new file mode 100644 index 0000000..64d73cc --- /dev/null +++ b/lxd/list.yml @@ -0,0 +1,13 @@ +- hosts: localhost + tasks: + - name: List LXD containers + ansible.builtin.command: lxc list --format json + register: lxd_containers_raw + + - name: Parse JSON output + ansible.builtin.set_fact: + lxd_containers: "{{ lxd_containers_raw.stdout | from_json }}" + + - name: Print LXD containers + ansible.builtin.debug: + var: lxd_containers diff --git a/lxd/restore.yml b/lxd/restore.yml new file mode 100644 index 0000000..74f5c26 --- /dev/null +++ b/lxd/restore.yml @@ -0,0 +1,4 @@ +- hosts: localhost + tasks: + - name: Restore LXD container snapshot + ansible.builtin.shell: lxc restore {{ name }} {{ snapshot }} diff --git a/lxd/snapshot.yml b/lxd/snapshot.yml new file mode 100644 index 0000000..1bd403b --- /dev/null +++ b/lxd/snapshot.yml @@ -0,0 +1,4 @@ +- hosts: localhost + tasks: + - name: Create LXD container snapshot + ansible.builtin.shell: lxc snapshot {{ name }} {{ label | default('') }} diff --git a/monitor/disk.yml b/monitor/disk.yml new file mode 100644 index 0000000..7479fb1 --- /dev/null +++ b/monitor/disk.yml @@ -0,0 +1,29 @@ +- hosts: localhost + tasks: + - name: Get disk usage + ansible.builtin.command: df -h --output=source,size,used,avail,pcent,target + register: disk_usage_raw + + - name: Parse disk usage + ansible.builtin.set_fact: + disk_usage: | + {% set lines = disk_usage_raw.stdout_lines[1:] %} + {% set parsed = [] %} + {% for line in lines %} + {% set parts = line.split() %} + {% if parts | length >= 6 %} + {% set _ = parsed.append({ + 'source': parts[0], + 'size': parts[1], + 'used': parts[2], + 'avail': parts[3], + 'pcent': parts[4], + 'target': parts[5] + }) %} + {% endif %} + {% endfor %} + {{ parsed }} + + - name: Print disk usage + ansible.builtin.debug: + var: disk_usage diff --git a/monitor/load.yml b/monitor/load.yml new file mode 100644 index 0000000..2ce6f39 --- /dev/null +++ b/monitor/load.yml @@ -0,0 +1,14 @@ +- hosts: localhost + tasks: + - name: Get load average + ansible.builtin.command: cat /proc/loadavg + register: load_avg_raw + + - name: Parse load average + ansible.builtin.set_fact: + load_avg: "{{ load_avg_raw.stdout | regex_replace('^(\S+)\s+(\S+)\s+(\S+).*$', '{\"1_min\": \"\\1\\", \"5_min\": \"\\2\\", \"15_min\": \"\\3\\"}') | from_json }}" + + - name: Print load average + ansible.builtin.debug: + var: load_avg + diff --git a/net/list_ips.yml b/net/list_ips.yml new file mode 100644 index 0000000..a8e9b00 --- /dev/null +++ b/net/list_ips.yml @@ -0,0 +1,13 @@ +- hosts: localhost + tasks: + - name: Get IP addresses and interfaces + ansible.builtin.command: ip -json a + register: ip_output + + - name: Parse JSON output + ansible.builtin.set_fact: + network_info: "{{ ip_output.stdout | from_json }}" + + - name: Print network information + ansible.builtin.debug: + var: network_info diff --git a/svc/restart.yml b/svc/restart.yml new file mode 100644 index 0000000..6b72926 --- /dev/null +++ b/svc/restart.yml @@ -0,0 +1,6 @@ +- hosts: localhost + tasks: + - name: Restart service + ansible.builtin.systemd: + name: "{{ service }}" + state: restarted diff --git a/svc/status.yml b/svc/status.yml new file mode 100644 index 0000000..5c9ffaa --- /dev/null +++ b/svc/status.yml @@ -0,0 +1,11 @@ +- hosts: localhost + tasks: + - name: Check service status + ansible.builtin.systemd: + name: "{{ service }}" + state: started + register: service_status + + - name: Print service status + ansible.builtin.debug: + var: service_status diff --git a/system/pkg_install.yml b/system/pkg_install.yml new file mode 100644 index 0000000..00c7af6 --- /dev/null +++ b/system/pkg_install.yml @@ -0,0 +1,6 @@ +- hosts: localhost + tasks: + - name: Install package + apt: + name: "{{ name }}" + state: present diff --git a/system/pkg_purge.yml b/system/pkg_purge.yml new file mode 100644 index 0000000..5bf9beb --- /dev/null +++ b/system/pkg_purge.yml @@ -0,0 +1,7 @@ +- hosts: localhost + tasks: + - name: Purge package + apt: + name: "{{ name }}" + state: absent + purge: yes diff --git a/system/reboot_required.yml b/system/reboot_required.yml new file mode 100644 index 0000000..291d9a1 --- /dev/null +++ b/system/reboot_required.yml @@ -0,0 +1,14 @@ +- hosts: localhost + tasks: + - name: Check if reboot required file exists + stat: + path: /var/run/reboot-required + register: reboot_file + + - name: Set fact if reboot is required + set_fact: + reboot_required: "{{ 1 if reboot_file.stat.exists else 0 }}" + + - name: Print reboot status + debug: + msg: "Reboot required: {{ reboot_file.stat.exists }}" diff --git a/system/update.yml b/system/update.yml new file mode 100644 index 0000000..05cecab --- /dev/null +++ b/system/update.yml @@ -0,0 +1,8 @@ +- hosts: localhost + tasks: + - name: Update apt cache + apt: + update_cache: yes + - name: Upgrade all packages + apt: + upgrade: dist diff --git a/ufw/allow.yml b/ufw/allow.yml new file mode 100644 index 0000000..d512d32 --- /dev/null +++ b/ufw/allow.yml @@ -0,0 +1,7 @@ +- hosts: localhost + tasks: + - name: Allow port + community.general.ufw: + rule: allow + port: "{{ port }}" + proto: "{{ proto | default(omit) }}" diff --git a/ufw/enable.yml b/ufw/enable.yml new file mode 100644 index 0000000..00e28b8 --- /dev/null +++ b/ufw/enable.yml @@ -0,0 +1,5 @@ +- hosts: localhost + tasks: + - name: Enable UFW + community.general.ufw: + state: enabled diff --git a/user/add.yml b/user/add.yml new file mode 100644 index 0000000..5450421 --- /dev/null +++ b/user/add.yml @@ -0,0 +1,7 @@ +- hosts: localhost + tasks: + - name: Add user + user: + name: "{{ username }}" + shell: "{{ shell | default('/bin/bash') }}" + generate_ssh_key: yes diff --git a/user/lock.yml b/user/lock.yml new file mode 100644 index 0000000..8ebf828 --- /dev/null +++ b/user/lock.yml @@ -0,0 +1,6 @@ +- hosts: localhost + tasks: + - name: Lock user account + user: + name: "{{ username }}" + state: locked