-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Autoconfiguration of backup servers.
- Loading branch information
Showing
13 changed files
with
133 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,3 @@ | |
name: sshd | ||
state: started | ||
enabled: yes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
testinfra_hosts = ["borg-centos-upstream", "borg-centos-system"] | ||
|
||
|
||
def test_backup(host): | ||
assert host.run("systemctl start borgbackup").rc == 0 | ||
assert host.run("systemctl is-failed borgbackup").rc == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
testinfra_hosts = ["borg-ubuntu-upstream", "borg-ubuntu-system"] | ||
|
||
|
||
def test_backup(host): | ||
assert host.run("systemctl --wait start borgbackup").rc == 0 | ||
assert host.run("systemctl is-failed borgbackup").rc == 1 |
5 changes: 0 additions & 5 deletions
5
molecule/default/tests/test_host_centos-borgbackup-system.yml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
|
||
- name: Simplify variables | ||
set_fact: | ||
_repository_server: "{{ borgbackup_config.repository_server }}" | ||
_user: "{{ hostvars[borgbackup_config.repository_server].borgbackup_user|default('backup') }}" | ||
_repo_path: "{{ hostvars[borgbackup_config.repository_server].borgbackup_repository_storage.rstrip('/') }}/{{ inventory_hostname }}" | ||
_borg_executable: "{{ hostvars[borgbackup_config.repository_server].borgbackup_path|default('/usr/' + ('' if hostvars[borgbackup_config.repository_server].borgbackup_install_method|default('system') == 'system' else 'local/') + 'bin/borg') }}" # noqa 204 | ||
_repo_url: "ssh://{{ hostvars[borgbackup_config.repository_server].borgbackup_user|default('backup') }}@{{ hostvars[borgbackup_config.repository_server].ansible_facts.fqdn }}/./" # noqa 204 | ||
|
||
- name: Get public key | ||
slurp: | ||
src: "{{ borgbackup_home }}/.ssh/id_rsa.pub" | ||
register: slurped_key_b64 | ||
|
||
- name: Regather facts to get SSH host keys | ||
setup: | ||
gather_subset: "!all" | ||
delegate_to: "{{ _repository_server }}" | ||
delegate_facts: True | ||
|
||
- name: Create borg repository folder | ||
file: | ||
path: "{{ _repo_path }}" | ||
state: directory | ||
owner: "{{ _user }}" | ||
group: "{{ _user }}" | ||
mode: 0700 | ||
delegate_to: "{{ _repository_server }}" | ||
become: yes | ||
|
||
- name: Configure SSH to allow the clients to access | ||
authorized_key: | ||
user: "{{ _user }}" | ||
state: present | ||
key: "{{ slurped_key_b64.content|b64decode }}" | ||
key_options: 'command="cd {{ _repo_path }}; {{ _borg_executable }} serve --append-only --restrict-to-repository {{ _repo_path }}",restrict' | ||
delegate_to: "{{ _repository_server }}" | ||
become: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters