Dried up the tags for evobackup-client
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing

blocks allow us to assign multiple tags to multiple tasks without
repeating ourselves. This also simplifies other logic like conditional
includes.
This commit is contained in:
Patrick Marchand 2020-06-23 12:07:51 -04:00
parent 8caca4c711
commit de4ba88790
7 changed files with 115 additions and 130 deletions

View file

@ -1,5 +1,6 @@
---
- block:
- name: 'create jail'
command: "bkctld init {{ evolinux_hostname }}"
args:
@ -8,9 +9,6 @@
delegate_to: "{{ evobackup_client__hosts[0].ip }}"
notify:
- 'created new jail'
tags:
- evobackup_client
- evobackup_client_jail
# temp fix for bkctld 2.x because the ip and key command return 1
# if the jail is not started, see https://gitea.evolix.org/evolix/evobackup/issues/31
@ -18,24 +16,19 @@
command: "bkctld restart {{ evolinux_hostname }}"
become: true
delegate_to: "{{ evobackup_client__hosts[0].ip }}"
tags:
- evobackup_client
- evobackup_client_jail
- name: 'add ip to jail'
command: "bkctld ip {{ evolinux_hostname }} {{ ansible_host }}"
become: true
delegate_to: "{{ evobackup_client__hosts[0].ip }}"
notify: 'jail updated'
tags:
- evobackup_client
- evobackup_client_jail
- name: 'add key to jail'
command: "bkctld key {{ evolinux_hostname }} /root/{{ evolinux_hostname }}.pub"
become: true
delegate_to: "{{ evobackup_client__hosts[0].ip }}"
notify: 'jail updated'
tags:
- evobackup_client
- evobackup_client_jail

View file

@ -1,5 +1,6 @@
---
- block:
- name: 'get jail port'
command: "bkctld port {{ evolinux_hostname }}"
become: true
@ -9,3 +10,8 @@
- name: 'register jail port'
set_fact:
evobackup_ssh_port={{ bkctld_port.stdout }}
when: evobackup_ssh_port = ''
tags:
- evobackup_client
- evobackup_client_ssh_port

View file

@ -1,26 +1,11 @@
---
- block:
- include: "ssh_key.yml"
tags:
- evobackup_client
- evobackup_client_backup_ssh_key
- include: "jail.yml"
tags:
- evobackup_client
- evobackup_client_jail
- include: "upload_scripts.yml"
tags:
- evobackup_client
- evobackup_client_backup_scripts
- include: "open_ssh_ports.yml"
tags:
- evobackup_client
- evobackup_client_backup_firewall
- include: "verify_ssh.yml"
tags:
- evobackup_client
- evobackup_client_backup_hosts

View file

@ -1,15 +1,13 @@
---
- block:
- name: Is there a Minifirewall ?
stat:
path: /etc/default/minifirewall
register: evobackup_client__minifirewall
tags:
- evobackup_client
- evobackup_client_backup_firewall
- include: "jail_port.yml"
when: evobackup_ssh_port = ''
when: evobackup_client__minifirewall.stat.exists
- name: Add backup SSH port in /etc/default/minifirewall
blockinfile:
@ -20,6 +18,7 @@
with_items: "{{ evobackup_client__hosts }}"
notify: restart minifirewall
when: evobackup_client__minifirewall.stat.exists
tags:
- evobackup_client
- evobackup_client_backup_firewall
- evobackup_client_firewall

View file

@ -1,5 +1,6 @@
---
- block:
- name: Create SSH key
user:
name: root
@ -7,17 +8,11 @@
ssh_key_file: "{{ evobackup_client__root_key_path }}"
ssh_key_type: "{{ evobackup_client__root_key_type }}"
register: evobackup_client__root_key
tags:
- evobackup_client
- evobackup_client_backup_ssh_key
- name: Print SSH key
debug:
var: evobackup_client__root_key.ssh_public_key
when: evobackup_client__root_key.ssh_public_key is defined
tags:
- evobackup_client
- evobackup_client_backup_ssh_key
- name: 'copy ssh public key to backup server'
copy:
@ -26,6 +21,8 @@
become: true
delegate_to: "{{ evobackup_client__hosts[0].ip }}"
tags:
- evobackup_client
- evobackup_client_backup_ssh_key
- evobackup_client_jail
tags:
- evobackup_client
- evobackup_client_ssh_key

View file

@ -1,7 +1,7 @@
---
- block:
- include: "jail_port.yml"
when: evobackup_ssh_port = ''
- name: Upload evobackup script
template:
@ -14,3 +14,7 @@
- "templates/evobackup-client/{{ evobackup_client__cron_template_name }}.{{ host_group }}.sh.j2"
- "templates/evobackup-client/{{ evobackup_client__cron_template_name }}.sh.j2"
- "zzz_evobackup.default.sh.j2"
tags:
- evobackup_client
- evobackup_client_script

View file

@ -1,7 +1,7 @@
---
- block:
- include: "jail_port.yml"
when: evobackup_ssh_port = ''
- name: Verify evolix backup servers
known_hosts:
@ -9,6 +9,7 @@
name: "[{{ item.name }}]:{{ item.port }}"
key: "[{{ item.name }}]:{{ item.port }} {{ item.fingerprint }}"
with_list: "{{ evobackup_client__hosts }}"
tags:
- evobackup_client
- evobackup_client_backup_hosts
- evobackup_client_fingerprints