Styleguide improvements
This commit is contained in:
parent
3e1b0473cc
commit
01bc64e95c
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
- name: Configure Borg backup
|
- name: Configure Borg backup
|
||||||
hosts: all
|
hosts: all
|
||||||
become: True
|
become: true
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- role: borgbackup
|
- role: borgbackup
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
borgbackup_required: True
|
borgbackup_required: true
|
||||||
|
|
||||||
borgbackup_client_user: root
|
borgbackup_client_user: root
|
||||||
borgbackup_ssh_key: "~{{ borgbackup_client_user }}/.ssh/id_borg_rsa"
|
borgbackup_ssh_key: "~{{ borgbackup_client_user }}/.ssh/id_borg_rsa"
|
||||||
@ -36,8 +36,8 @@ borgbackup_cron_day: "*"
|
|||||||
borgbackup_cron_hour: "{{ 5|random(seed=inventory_hostname) }}"
|
borgbackup_cron_hour: "{{ 5|random(seed=inventory_hostname) }}"
|
||||||
borgbackup_cron_minute: "{{ 59|random(seed=inventory_hostname) }}"
|
borgbackup_cron_minute: "{{ 59|random(seed=inventory_hostname) }}"
|
||||||
|
|
||||||
borgbackup_appendonly: False
|
borgbackup_appendonly: false
|
||||||
borgbackup_appendonly_repoconfig: False
|
borgbackup_appendonly_repoconfig: false
|
||||||
borgbackup_management_station: ''
|
borgbackup_management_station: ''
|
||||||
borgbackup_management_user: ''
|
borgbackup_management_user: ''
|
||||||
borgbackup_management_ssh_pubkey: ''
|
borgbackup_management_ssh_pubkey: ''
|
||||||
|
@ -5,15 +5,15 @@ galaxy_info:
|
|||||||
license: MIT
|
license: MIT
|
||||||
min_ansible_version: 1.9
|
min_ansible_version: 1.9
|
||||||
platforms:
|
platforms:
|
||||||
- name: EL
|
- name: EL
|
||||||
versions:
|
versions:
|
||||||
- all
|
- all
|
||||||
- name: Debian
|
- name: Debian
|
||||||
versions:
|
versions:
|
||||||
- all
|
- all
|
||||||
- name: Ubuntu
|
- name: Ubuntu
|
||||||
versions:
|
versions:
|
||||||
- all
|
- all
|
||||||
galaxy_tags:
|
galaxy_tags:
|
||||||
- borg
|
- borg
|
||||||
- borgbackup
|
- borgbackup
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
- name: client | generate ssh key for this machine
|
- name: client | generate ssh key for this machine
|
||||||
user:
|
user:
|
||||||
name: "{{ borgbackup_client_user }}"
|
name: "{{ borgbackup_client_user }}"
|
||||||
generate_ssh_key: yes
|
generate_ssh_key: true
|
||||||
ssh_key_bits: 2048
|
ssh_key_bits: 2048
|
||||||
ssh_key_file: "{{ borgbackup_ssh_key }}"
|
ssh_key_file: "{{ borgbackup_ssh_key }}"
|
||||||
ssh_key_type: rsa
|
ssh_key_type: rsa
|
||||||
@ -10,19 +10,19 @@
|
|||||||
- name: client | fetch ssh-key
|
- name: client | fetch ssh-key
|
||||||
shell: "cat {{ borgbackup_ssh_key }}.pub"
|
shell: "cat {{ borgbackup_ssh_key }}.pub"
|
||||||
register: sshkey
|
register: sshkey
|
||||||
changed_when: False
|
changed_when: false
|
||||||
|
|
||||||
- name: client | write passphrase
|
- name: client | write passphrase
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: "~{{ borgbackup_client_user }}/.borg.passphrase"
|
dest: "~{{ borgbackup_client_user }}/.borg.passphrase"
|
||||||
state: "present"
|
state: "present"
|
||||||
line: 'export BORG_PASSPHRASE="{{ borgbackup_passphrase }}"'
|
line: 'export BORG_PASSPHRASE="{{ borgbackup_passphrase }}"'
|
||||||
create: "yes"
|
create: true
|
||||||
|
|
||||||
- name: client | disable strict key checking for backup servers
|
- name: client | disable strict key checking for backup servers
|
||||||
blockinfile:
|
blockinfile:
|
||||||
dest: "~{{ borgbackup_client_user }}/.ssh/config"
|
dest: "~{{ borgbackup_client_user }}/.ssh/config"
|
||||||
create: yes
|
create: true
|
||||||
marker: "### {mark} ANSIBLE MANAGED BLOCK {{ item.fqdn }} ###"
|
marker: "### {mark} ANSIBLE MANAGED BLOCK {{ item.fqdn }} ###"
|
||||||
content: |
|
content: |
|
||||||
Host {{ item.fqdn }}
|
Host {{ item.fqdn }}
|
||||||
@ -46,7 +46,7 @@
|
|||||||
- name: client | get authorized_keys file
|
- name: client | get authorized_keys file
|
||||||
raw: scp {{ item.user }}@{{ item.fqdn }}:.ssh/authorized_keys /tmp/authkeys-{{ item.type }}-{{ item.fqdn }}-authkeys
|
raw: scp {{ item.user }}@{{ item.fqdn }}:.ssh/authorized_keys /tmp/authkeys-{{ item.type }}-{{ item.fqdn }}-authkeys
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: no
|
become: false
|
||||||
when: item.type in ['rsync.net','hetzner']
|
when: item.type in ['rsync.net','hetzner']
|
||||||
with_items: "{{ borgbackup_servers }}"
|
with_items: "{{ borgbackup_servers }}"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
@ -57,9 +57,9 @@
|
|||||||
key: "{{ sshkey.stdout }}"
|
key: "{{ sshkey.stdout }}"
|
||||||
key_options: 'command="cd {{ item.pool }}/{{ inventory_hostname }};/usr/local/bin/borg1 serve {% if borgbackup_appendonly %}--append-only {% endif %} --restrict-to-path {{ item.pool }}/{{ inventory_hostname }}",no-port-forwarding,no-X11-forwarding,no-pty,no-agent-forwarding,no-user-rc'
|
key_options: 'command="cd {{ item.pool }}/{{ inventory_hostname }};/usr/local/bin/borg1 serve {% if borgbackup_appendonly %}--append-only {% endif %} --restrict-to-path {{ item.pool }}/{{ inventory_hostname }}",no-port-forwarding,no-X11-forwarding,no-pty,no-agent-forwarding,no-user-rc'
|
||||||
path: "/tmp/authkeys-{{ item.type }}-{{ item.fqdn }}-authkeys"
|
path: "/tmp/authkeys-{{ item.type }}-{{ item.fqdn }}-authkeys"
|
||||||
manage_dir: no
|
manage_dir: false
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: no
|
become: false
|
||||||
when: item.type in ['rsync.net','hetzner']
|
when: item.type in ['rsync.net','hetzner']
|
||||||
with_items: "{{ borgbackup_servers }}"
|
with_items: "{{ borgbackup_servers }}"
|
||||||
register: authkeys
|
register: authkeys
|
||||||
@ -67,7 +67,7 @@
|
|||||||
- name: client | upload local authorized_keys to rsync.net / hetzner
|
- name: client | upload local authorized_keys to rsync.net / hetzner
|
||||||
raw: scp /tmp/authkeys-{{ item.type }}-{{ item.fqdn }}-authkeys {{ item.user }}@{{ item.fqdn }}:.ssh/authorized_keys
|
raw: scp /tmp/authkeys-{{ item.type }}-{{ item.fqdn }}-authkeys {{ item.user }}@{{ item.fqdn }}:.ssh/authorized_keys
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: no
|
become: false
|
||||||
when: item.type in ['rsync.net','hetzner'] and authkeys.changed
|
when: item.type in ['rsync.net','hetzner'] and authkeys.changed
|
||||||
with_items: "{{ borgbackup_servers }}"
|
with_items: "{{ borgbackup_servers }}"
|
||||||
|
|
||||||
@ -76,7 +76,7 @@
|
|||||||
path: /tmp/authkeys-{{ item.type }}-{{ item.fqdn }}-authkeys
|
path: /tmp/authkeys-{{ item.type }}-{{ item.fqdn }}-authkeys
|
||||||
state: absent
|
state: absent
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: no
|
become: false
|
||||||
with_items: "{{ borgbackup_servers }}"
|
with_items: "{{ borgbackup_servers }}"
|
||||||
when: authkeys.changed
|
when: authkeys.changed
|
||||||
changed_when: false
|
changed_when: false
|
||||||
@ -109,12 +109,12 @@
|
|||||||
day: "{{ borgbackup_cron_day }}"
|
day: "{{ borgbackup_cron_day }}"
|
||||||
job: "/usr/local/bin/borg-backup backup"
|
job: "/usr/local/bin/borg-backup backup"
|
||||||
|
|
||||||
- name: client | disable automysqlbackup cronjob, it's in our pre-backup-tasks
|
- name: client | disable automysqlbackup cronjob, it's in our pre-backup-tasks
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: "/etc/cron.daily/automysqlbackup"
|
dest: "/etc/cron.daily/automysqlbackup"
|
||||||
regexp: "^/usr/sbin/automysqlbackup$"
|
regexp: "^/usr/sbin/automysqlbackup$"
|
||||||
line: "#/usr/sbin/automysqlbackup"
|
line: "#/usr/sbin/automysqlbackup"
|
||||||
state: "present"
|
state: "present"
|
||||||
backrefs: "yes"
|
backrefs: true
|
||||||
create: "no"
|
create: false
|
||||||
when: automysql.stat.isdir is defined and automysql.stat.isdir == True
|
when: automysql.stat.isdir is defined and automysql.stat.isdir == True
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
# Due to inverse logic behaviour when searching for an item in an undefined list.
|
# Due to inverse logic behaviour when searching for an item in an undefined list.
|
||||||
- set_fact:
|
- name: setting facts
|
||||||
|
set_fact:
|
||||||
borgbackup_servers_group: "{{ groups.borgbackup_servers | default([]) }} "
|
borgbackup_servers_group: "{{ groups.borgbackup_servers | default([]) }} "
|
||||||
borgbackup_management_group: "{{ groups.borgbackup_management | default([]) }}"
|
borgbackup_management_group: "{{ groups.borgbackup_management | default([]) }}"
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
- name: management | get rsync.net authorized_keys file
|
- name: management | get rsync.net authorized_keys file
|
||||||
raw: scp {{ item.user }}@{{ item.fqdn }}:.ssh/authorized_keys /tmp/rsync.net-{{ item.fqdn }}-authkeys
|
raw: scp {{ item.user }}@{{ item.fqdn }}:.ssh/authorized_keys /tmp/rsync.net-{{ item.fqdn }}-authkeys
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: no
|
become: false
|
||||||
when: item.type == 'rsync.net'
|
when: item.type == 'rsync.net'
|
||||||
with_items: "{{ borgbackup_servers }}"
|
with_items: "{{ borgbackup_servers }}"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
@ -30,9 +30,9 @@
|
|||||||
user: "{{ ansible_user_id }}"
|
user: "{{ ansible_user_id }}"
|
||||||
key: "{{ borgbackup_management_ssh_pubkey }}"
|
key: "{{ borgbackup_management_ssh_pubkey }}"
|
||||||
path: "/tmp/rsync.net-{{ item.fqdn }}-authkeys"
|
path: "/tmp/rsync.net-{{ item.fqdn }}-authkeys"
|
||||||
manage_dir: no
|
manage_dir: false
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: no
|
become: false
|
||||||
when: item.type == 'rsync.net'
|
when: item.type == 'rsync.net'
|
||||||
with_items: "{{ borgbackup_servers }}"
|
with_items: "{{ borgbackup_servers }}"
|
||||||
register: authkeys
|
register: authkeys
|
||||||
@ -40,7 +40,7 @@
|
|||||||
- name: management | upload local authorized_keys to rsync.net
|
- name: management | upload local authorized_keys to rsync.net
|
||||||
raw: scp /tmp/rsync.net-{{ item.fqdn }}-authkeys {{ item.user }}@{{ item.fqdn }}:.ssh/authorized_keys
|
raw: scp /tmp/rsync.net-{{ item.fqdn }}-authkeys {{ item.user }}@{{ item.fqdn }}:.ssh/authorized_keys
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: no
|
become: false
|
||||||
when: item.type == 'rsync.net' and authkeys.changed
|
when: item.type == 'rsync.net' and authkeys.changed
|
||||||
with_items: "{{ borgbackup_servers }}"
|
with_items: "{{ borgbackup_servers }}"
|
||||||
|
|
||||||
@ -49,7 +49,7 @@
|
|||||||
path: /tmp/rsync.net-{{ item.fqdn }}-authkeys
|
path: /tmp/rsync.net-{{ item.fqdn }}-authkeys
|
||||||
state: absent
|
state: absent
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: no
|
become: false
|
||||||
with_items: "{{ borgbackup_servers }}"
|
with_items: "{{ borgbackup_servers }}"
|
||||||
when: authkeys.changed
|
when: authkeys.changed
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
Loading…
Reference in New Issue
Block a user