Added evobackup-client role #83

Manually merged
Ghost merged 17 commits from evobackup-client into unstable 2020-02-06 22:31:45 +01:00
5 changed files with 50 additions and 1 deletions
Showing only changes of commit daad12fdeb - Show all commits

View file

@ -4,3 +4,7 @@
register: minifirewall_init_restart
failed_when: "'starting IPTables rules is now finish : OK' not in minifirewall_init_restart.stdout"
changed_when: "'starting IPTables rules is now finish : OK' in minifirewall_init_restart.stdout"
- name: 'created new jail'
command: "bkctld start {{ evolinux_hostname }}"
delegate_to: "{{ evobackup_client__hosts[0].ip }}"

View file

@ -0,0 +1,29 @@
---
- name: 'create jail'
command: "bkctld init {{ evolinux_hostname }}"
args:
creates: "/backup/jails/{{ evolinux_hostname }}/"
become: true
delegate_to: "{{ evobackup_client__hosts[0].ip }}"
notify: 'created new jail'
- name: 'add ssh key to jail'
command: "bkctld key {{ evolinux_hostname }} /root/{{ evolinux_hostname }}.pub"
become: true
delegate_to: "{{ evobackup_client__hosts[0].ip }}"
- name: 'add ip to jail'
command: "bkctld ip {{ evolinux_hostname }} {{ ansible_host }}"
become: true
delegate_to: "{{ evobackup_client__hosts[0].ip }}"
- name: 'get jail port'
command: "bkctld port {{ evolinux_hostname }}"
become: true
register: bkctld_port
delegate_to: "{{ evobackup_client__hosts[0].ip }}"
- name: 'register jail port'
set_fact:
evobackup_ssh_port={{ bkctld_port.stdout }}

View file

@ -5,6 +5,11 @@
- evobackup_client
- evobackup_client_backup_ssh_key
- include: "create_jail.yml"
tags:
- evobackup_client
- evobackup_client_jail
- include: "upload_scripts.yml"
tags:
- evobackup_client

View file

@ -11,7 +11,7 @@
- name: Add backup SSH port in /etc/default/minifirewall
Review

We can have multiple backup sections (with heterogenous ssh ports) in the minifirewall file. Let's be extra careful with what we insert and/ore replace.

We can have multiple backup sections (with heterogenous ssh ports) in the minifirewall file. Let's be extra careful with what we insert and/ore replace.
Review

Again, heterogeneous ports is kind of an outlier case. But the main question is how to define it without it being a chore.

Again, heterogeneous ports is kind of an outlier case. But the main question is how to define it without it being a chore.
Review

So I removed this task, instead setting the port directly in the rule.

So I removed this task, instead setting the port directly in the rule.
blockinfile:
dest: /etc/default/minifirewall
marker: "# {{ item.name }}"
marker: "# {mark} {{ item.name }}"
block: |
/sbin/iptables -A INPUT -p tcp --sport {{ item.port }} --dport 1024:65535 -s {{ item.ip }} -m state --state ESTABLISHED,RELATED -j ACCEPT
with_items: "{{ evobackup_client__hosts }}"

View file

@ -18,3 +18,14 @@
tags:
- evobackup_client
- evobackup_client_backup_ssh_key
- name: 'copy ssh public key to backup server'
copy:
content: "{{ evobackup_client__root_key.ssh_public_key }}"
dest: "/root/{{ evolinux_hostname }}.pub"
become: true
delegate_to: "{{ evobackup_client__hosts[0].ip }}"
tags:
- evobackup_client
- evobackup_client_backup_ssh_key
- evobackup_client_jail