Migrated from legacy playbook repo into Ansible collection format: Roles (171 total): - common: 44 roles (fact gathering, SSH setup, utilities) - configuration: 32 roles (system config, networking, satellite) - provisioning: 16 roles (VMware, Azure, physical server deployment) - security: 15 roles (OpenSCAP hardening, certificates, AD integration) - monitoring: 12 roles (Zabbix, logging agents, metrics) - networking: 12 roles (DNS, DHCP, network interfaces) - satellite: 4 roles (Pulp/Satellite management) - misc: 36 roles (various utilities) Playbooks (159 total): - provisioning: 14 playbooks - azure: 13 playbooks - configuration: 22 playbooks - maintenance: 10 playbooks - security: 10 playbooks - monitoring: 9 playbooks - vcenter: 6 playbooks - networking: 7 playbooks - misc: 65 playbooks
54 lines
1.5 KiB
YAML
Executable File
54 lines
1.5 KiB
YAML
Executable File
---
|
|
# tasks file for backup_etcd
|
|
- name: Find old tarballs
|
|
shell: find /tmp/ -maxdepth 1 -type f | grep 'etcd.*.tar'
|
|
register: files_to_delete
|
|
ignore_errors: yes
|
|
|
|
- name: Files to delete
|
|
debug: msg={{ files_to_delete.stdout_lines }}
|
|
|
|
- name: Remove old tarballs
|
|
file:
|
|
state: absent
|
|
path: "{{ item }}"
|
|
with_items:
|
|
- "{{ files_to_delete.stdout_lines }}"
|
|
|
|
- name: Remove temporary etcd directory
|
|
file:
|
|
state: absent
|
|
path: /tmp/etcd
|
|
|
|
- name: Get ETCD container name on master host
|
|
shell: /bin/docker ps | grep etcd | awk '{ print $1 }'
|
|
register: etcd_container
|
|
|
|
- name: Clean up container temp dir
|
|
shell: /bin/docker exec {{ etcd_container.stdout }} rm -rf /tmp/etcd
|
|
|
|
- name: Backup ETCD
|
|
shell: /bin/docker exec {{ etcd_container.stdout }} etcdctl backup --data-dir {{ ETCD_DATA_DIR }} --backup-dir /tmp/etcd/
|
|
|
|
- name: Copy ETCD backup from container to host machine
|
|
shell: /bin/docker cp {{ etcd_container.stdout }}:/tmp/etcd /tmp/etcd
|
|
|
|
- name: Pack ETCD backup in a tarball
|
|
shell: cd /tmp/ && /usr/bin/tar cf /tmp/etcd-$(hostname)-$(date +"%Y-%m-%d_%H-%M-%S").tar etcd/*
|
|
|
|
- name: Find tarball on each host
|
|
shell: find /tmp/ -maxdepth 1 -type f | grep 'etcd*' | sort -r | head -1
|
|
register: files_to_copy
|
|
ignore_errors: yes
|
|
|
|
- name: Files to copy
|
|
debug: msg={{ files_to_copy.stdout_lines }}
|
|
|
|
- name: Fetch tarball from each hosts
|
|
synchronize:
|
|
src: "{{ item }}"
|
|
dest: backup/etcd/
|
|
mode: pull
|
|
with_items:
|
|
- "{{ files_to_copy.stdout_lines }}"
|