Имам подготвена среда с инсталиран Openshift 4.6 във VMware среда.
Необходимо бе да измисля начин, с който да правя backup на etcd, след което да го копирам на машината от която е извикан playbook-a. Написах си ansible playbook за целта:
---
- hosts: all
become: yes
gather_facts: no
tasks:
- debug: msg="{{ lookup('pipe','date') }}"
- name: Test connection
ping:
- name: Create backup files
shell: "/usr/local/bin/cluster-backup.sh /home/core/backup"
- name: Copy backup files
synchronize:
src: "/home/core/backup"
dest: "/backup/"
recursive: yes
mode: pull
- name: Find all files that are older than 10 days
find:
paths: "/home/core/backup"
age: 10d
recurse: yes
register: filesOlderThan10
- name: Remove older files than 10 days
file:
paths: "/home/core/backup"
state: absent
with_items: "{{ filesOlderThan10.files }}"
- name: Send notification Slack
slack:
token: "XXX/YYY/ZZZ"
msg: 'Backup ETCD on {{ inventory_hostname }} completed :)'
channel: '#monitoring'
delegate_to: localhost
След, което го вкарах в crontab и готово.