Add ntfy push notification system with comprehensive configuration, API endpoints, and automatic event notifications for tasks, schedules, health checks, and bootstrap operations
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
---
|
||||
- name: Backup configuration files
|
||||
hosts: all
|
||||
become: true
|
||||
gather_facts: true
|
||||
vars:
|
||||
category: backup
|
||||
subcategory: configuration
|
||||
backup_dir: /tmp/config_backup
|
||||
timestamp: "{{ ansible_date_time.iso8601_basic_short }}"
|
||||
tasks:
|
||||
- name: Create backup directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ backup_dir }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Backup /etc directory (essential configs)
|
||||
ansible.builtin.archive:
|
||||
path:
|
||||
- /etc/hostname
|
||||
- /etc/hosts
|
||||
- /etc/passwd
|
||||
- /etc/group
|
||||
- /etc/shadow
|
||||
- /etc/sudoers
|
||||
- /etc/ssh/sshd_config
|
||||
dest: "{{ backup_dir }}/etc_backup_{{ timestamp }}.tar.gz"
|
||||
format: gz
|
||||
ignore_errors: true
|
||||
|
||||
- name: Backup crontabs
|
||||
ansible.builtin.shell: |
|
||||
crontab -l > {{ backup_dir }}/crontab_{{ timestamp }}.txt 2>/dev/null || echo "No crontab"
|
||||
changed_when: false
|
||||
|
||||
- name: List backup files
|
||||
ansible.builtin.find:
|
||||
paths: "{{ backup_dir }}"
|
||||
patterns: "*{{ timestamp }}*"
|
||||
register: backup_files
|
||||
|
||||
- name: Display backup summary
|
||||
ansible.builtin.debug:
|
||||
msg: |
|
||||
Backup completed for {{ inventory_hostname }}
|
||||
Files created: {{ backup_files.files | map(attribute='path') | list }}
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
- name: Backup Serveurs Proxmox Configuration files
|
||||
hosts: role_proxmox
|
||||
become: true
|
||||
gather_facts: true
|
||||
vars:
|
||||
category: backup
|
||||
subcategory: configuration
|
||||
backup_dir: /mnt/pve/SHARE_PROXMOX/backups
|
||||
hostname: "{{ ansible_hostname }}"
|
||||
timestamp: "{{ ansible_date_time.iso8601_basic_short }}"
|
||||
backup_files_common:
|
||||
- /etc/hostname
|
||||
- /etc/hosts
|
||||
- /etc/passwd
|
||||
- /etc/group
|
||||
- /etc/shadow
|
||||
- /etc/sudoers
|
||||
- /etc/ssh/sshd_config
|
||||
tasks:
|
||||
- name: Ensure backup root directory exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ backup_dir }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Ensure host-specific backup directory exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ backup_dir }}/{{ hostname }}"
|
||||
state: directory
|
||||
mode: '0700'
|
||||
|
||||
- name: Backup /etc essential configuration files
|
||||
ansible.builtin.archive:
|
||||
path: "{{ backup_files_common }}"
|
||||
dest: "{{ backup_dir }}/{{ hostname }}/etc_backup_{{ timestamp }}.tar.gz"
|
||||
format: gz
|
||||
ignore_errors: true
|
||||
|
||||
- name: Get root crontab
|
||||
ansible.builtin.command: crontab -l
|
||||
register: root_crontab
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
|
||||
- name: Save root crontab to file
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ backup_dir }}/{{ hostname }}/crontab_{{ timestamp }}.txt"
|
||||
content: "{{ root_crontab.stdout | default('No crontab') }}"
|
||||
mode: '0600'
|
||||
|
||||
- name: Export installed packages list
|
||||
ansible.builtin.shell: |
|
||||
{% if ansible_os_family == 'Debian' %}
|
||||
dpkg --get-selections > {{ backup_dir }}/{{ hostname }}/packages_{{ timestamp }}.txt
|
||||
{% elif ansible_os_family == 'RedHat' %}
|
||||
rpm -qa > {{ backup_dir }}/{{ hostname }}/packages_{{ timestamp }}.txt
|
||||
{% else %}
|
||||
echo "Package export not implemented for {{ ansible_os_family }}" > {{ backup_dir }}/{{ hostname }}/packages_{{ timestamp }}.txt
|
||||
{% endif %}
|
||||
args:
|
||||
executable: /bin/bash
|
||||
changed_when: false
|
||||
|
||||
- name: List backup files
|
||||
ansible.builtin.find:
|
||||
paths: "{{ backup_dir }}/{{ hostname }}"
|
||||
patterns: "*{{ timestamp }}*"
|
||||
register: backup_files
|
||||
|
||||
- name: Display backup summary
|
||||
ansible.builtin.debug:
|
||||
msg: |
|
||||
Backup completed for {{ inventory_hostname }}
|
||||
Files created: {{ backup_files.files | map(attribute='path') | list }}
|
||||
@@ -6,7 +6,7 @@
|
||||
hosts: all
|
||||
become: yes
|
||||
vars:
|
||||
category: Test
|
||||
category: testing
|
||||
subcategory: other
|
||||
|
||||
tasks:
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
- name: NTFY test playbook (error)
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
become: false
|
||||
|
||||
vars:
|
||||
category: notifications
|
||||
subcategory: ntfy-test
|
||||
|
||||
tasks:
|
||||
- name: Simulate a failing operation (for NTFY error notifications)
|
||||
ansible.builtin.fail:
|
||||
msg: "NTFY test playbook: simulated error on host {{ inventory_hostname }}"
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
- name: NTFY test playbook (success)
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
become: false
|
||||
|
||||
vars:
|
||||
category: notifications
|
||||
subcategory: ntfy-test
|
||||
|
||||
tasks:
|
||||
- name: Simulate a successful operation
|
||||
ansible.builtin.debug:
|
||||
msg: "NTFY test playbook: success on host {{ inventory_hostname }}"
|
||||
|
||||
- name: Ensure playbook ends successfully
|
||||
ansible.builtin.ping:
|
||||
Reference in New Issue
Block a user