814e4be128
This introduces two new roles for managing the backup-server and hosts that we wish to back up. Firstly the "backup" role runs on hosts we wish to backup. This generates and configures a separate ssh key for running bup and installs the appropriate cron job to run the backup daily. The "backup-server" job runs on the backup server (or, indeed servers). It creates users for each backup host, accepts the remote keys mentioned above and initalises bup. It is then ready to receive backups from the remote hosts. This eliminates a fairly long-standing requirement for manual setup of the backup server users and keys; this section is removed from the documentation. testinfra coverage is added. Change-Id: I9bf74df351e056791ed817180436617048224d2c
32 lines
981 B
YAML
32 lines
981 B
YAML
# note bup_user is the parent loop variable name; this works on each
|
|
# element from the bup_users global.
|
|
- name: Set variables
|
|
set_fact:
|
|
user_name: '{{ bup_user[0] }}'
|
|
user_key: '{{ bup_user[1] }}'
|
|
|
|
- name: Create bup user
|
|
user:
|
|
name: '{{ user_name }}'
|
|
comment: 'Backup user'
|
|
shell: /bin/bash
|
|
home: '/opt/backups/{{ user_name }}'
|
|
create_home: yes
|
|
register: homedir
|
|
|
|
- name: Create bup user authorized key
|
|
authorized_key:
|
|
user: '{{ user_name }}'
|
|
state: present
|
|
key: '{{ user_key }}'
|
|
key_options: 'command="BUP_DEBUG=0 BUP_FORCE_TTY=3 bup server",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty'
|
|
|
|
# ansible-lint wants this in a handler, it should be done here and
|
|
# now; this isn't like a service restart where multiple things might
|
|
# call it.
|
|
- name: Initalise bup # noqa 503
|
|
shell: |
|
|
BUP_DIR=/opt/backups/{{ user_name }}/.bup bup init
|
|
become: yes
|
|
become_user: '{{ user_name }}'
|
|
when: homedir.changed |