I try to setup a second borg backup server (normal installation) for our infrastructure. Goal would be that we have our backups on more than one server.
My configuration looks as follows: I have the following inventory:
[borgbackup_servers]
backup1
backup2
And then in group_vars/borgbackup_servers/vars.yml the definition for the servers that looks something like this:
borgbackup_servers:
- fqdn: backup1
user: borgds
type: normal
home: /var/backup/
pool: repos
options: ""
- fqdn: backup2
user: borgds
type: normal
home: /var/backup/
pool: repos
options: ""
My issue is that the necessary user on backup2 is never created as the task server | create user has run_once: true defined.
I'm not quite sure how to fix this or if my configuration is correct. A first idea I have is to just run the entire task once:
diff --git a/tasks/borg-server.yml b/tasks/borg-server.yml
index e3bafd2..f40920b 100644
--- a/tasks/borg-server.yml
+++ b/tasks/borg-server.yml
@@ -7,7 +7,6 @@
createhome: "yes"
delegate_to: "{{ item.fqdn }}"
with_items: "{{ borgbackup_servers }}"
- run_once: true
when: item.type == 'normal'
- name: server | set permissions
diff --git a/tasks/main.yml b/tasks/main.yml
index 5e9b82c..f98b781 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -21,14 +21,16 @@
- always
- include_tasks: borg-server.yml
- when: inventory_hostname in borgbackup_servers_group
+ run_once: true
This has the drawback that if you have different borgbackup_servers defined, let's say a different one in each host_vars, that only the first one is executed if you run the playbook with all the hosts at once.
Another idea would be to define throttle on the task.
diff --git a/tasks/borg-server.yml b/tasks/borg-server.yml
index e3bafd2..e313fba 100644
--- a/tasks/borg-server.yml
+++ b/tasks/borg-server.yml
@@ -7,7 +7,7 @@
createhome: "yes"
delegate_to: "{{ item.fqdn }}"
with_items: "{{ borgbackup_servers }}"
- run_once: true
+ throttle: 1
when: item.type == 'normal'
This would force the task to run sequentially, therefore I should never hit the race condition described in #12.
anyhow, I would like to have your opinions before submitting a PR.
I try to setup a second borg backup server (normal installation) for our infrastructure. Goal would be that we have our backups on more than one server.
My configuration looks as follows: I have the following inventory:
And then in
group_vars/borgbackup_servers/vars.ymlthe definition for the servers that looks something like this:My issue is that the necessary user on
backup2is never created as the taskserver | create userhasrun_once: truedefined.I'm not quite sure how to fix this or if my configuration is correct. A first idea I have is to just run the entire task once:
This has the drawback that if you have different
borgbackup_serversdefined, let's say a different one in eachhost_vars, that only the first one is executed if you run the playbook with all the hosts at once.Another idea would be to define
throttleon the task.This would force the task to run sequentially, therefore I should never hit the race condition described in #12.
anyhow, I would like to have your opinions before submitting a PR.