Initial commit
This commit is contained in:
commit
c889468706
5
backup/list.yml
Normal file
5
backup/list.yml
Normal file
@ -0,0 +1,5 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: List backup sets (simulated)
|
||||
ansible.builtin.debug:
|
||||
msg: "Simulating listing of backup sets."
|
||||
5
backup/restore.yml
Normal file
5
backup/restore.yml
Normal file
@ -0,0 +1,5 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Restore backup (simulated)
|
||||
ansible.builtin.debug:
|
||||
msg: "Simulating restoring backup with ID: {{ id }}"
|
||||
5
backup/run.yml
Normal file
5
backup/run.yml
Normal file
@ -0,0 +1,5 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Trigger rsync.net job (simulated)
|
||||
ansible.builtin.debug:
|
||||
msg: "Simulating rsync.net backup job trigger."
|
||||
12
git/commit.yml
Normal file
12
git/commit.yml
Normal file
@ -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 }}"
|
||||
4
git/rollback.yml
Normal file
4
git/rollback.yml
Normal file
@ -0,0 +1,4 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Rollback to specific SHA
|
||||
ansible.builtin.command: git -C /data/mcp-history reset --hard {{ sha }}
|
||||
9
log/tail.yml
Normal file
9
log/tail.yml
Normal file
@ -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
|
||||
4
lxd/launch.yml
Normal file
4
lxd/launch.yml
Normal file
@ -0,0 +1,4 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Launch LXD container
|
||||
ansible.builtin.shell: lxc launch {{ image }} {{ name }}
|
||||
13
lxd/list.yml
Normal file
13
lxd/list.yml
Normal file
@ -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
|
||||
4
lxd/restore.yml
Normal file
4
lxd/restore.yml
Normal file
@ -0,0 +1,4 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Restore LXD container snapshot
|
||||
ansible.builtin.shell: lxc restore {{ name }} {{ snapshot }}
|
||||
4
lxd/snapshot.yml
Normal file
4
lxd/snapshot.yml
Normal file
@ -0,0 +1,4 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Create LXD container snapshot
|
||||
ansible.builtin.shell: lxc snapshot {{ name }} {{ label | default('') }}
|
||||
29
monitor/disk.yml
Normal file
29
monitor/disk.yml
Normal file
@ -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
|
||||
14
monitor/load.yml
Normal file
14
monitor/load.yml
Normal file
@ -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
|
||||
|
||||
13
net/list_ips.yml
Normal file
13
net/list_ips.yml
Normal file
@ -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
|
||||
6
svc/restart.yml
Normal file
6
svc/restart.yml
Normal file
@ -0,0 +1,6 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Restart service
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ service }}"
|
||||
state: restarted
|
||||
11
svc/status.yml
Normal file
11
svc/status.yml
Normal file
@ -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
|
||||
6
system/pkg_install.yml
Normal file
6
system/pkg_install.yml
Normal file
@ -0,0 +1,6 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Install package
|
||||
apt:
|
||||
name: "{{ name }}"
|
||||
state: present
|
||||
7
system/pkg_purge.yml
Normal file
7
system/pkg_purge.yml
Normal file
@ -0,0 +1,7 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Purge package
|
||||
apt:
|
||||
name: "{{ name }}"
|
||||
state: absent
|
||||
purge: yes
|
||||
14
system/reboot_required.yml
Normal file
14
system/reboot_required.yml
Normal file
@ -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 }}"
|
||||
8
system/update.yml
Normal file
8
system/update.yml
Normal file
@ -0,0 +1,8 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Update apt cache
|
||||
apt:
|
||||
update_cache: yes
|
||||
- name: Upgrade all packages
|
||||
apt:
|
||||
upgrade: dist
|
||||
7
ufw/allow.yml
Normal file
7
ufw/allow.yml
Normal file
@ -0,0 +1,7 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Allow port
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
port: "{{ port }}"
|
||||
proto: "{{ proto | default(omit) }}"
|
||||
5
ufw/enable.yml
Normal file
5
ufw/enable.yml
Normal file
@ -0,0 +1,5 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Enable UFW
|
||||
community.general.ufw:
|
||||
state: enabled
|
||||
7
user/add.yml
Normal file
7
user/add.yml
Normal file
@ -0,0 +1,7 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Add user
|
||||
user:
|
||||
name: "{{ username }}"
|
||||
shell: "{{ shell | default('/bin/bash') }}"
|
||||
generate_ssh_key: yes
|
||||
6
user/lock.yml
Normal file
6
user/lock.yml
Normal file
@ -0,0 +1,6 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
- name: Lock user account
|
||||
user:
|
||||
name: "{{ username }}"
|
||||
state: locked
|
||||
Loading…
Reference in New Issue
Block a user