Skip to content

Commit

Permalink
Amended backup and restore playbooks
Browse files Browse the repository at this point in the history
  • Loading branch information
arodier committed Sep 22, 2023
1 parent abe052d commit 709e168
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 37 deletions.
25 changes: 12 additions & 13 deletions playbooks/backup.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
---

## Call the backup tasks on a role
## Call the backup tasks on one or more role

# export the role you want to run in the ‘ROLE’ environment variable
# and run the playbook.

- name: Run the backup tasks of one role
hosts: homebox
vars_files:
- '{{ playbook_dir }}/../config/system.yml'
- '{{ playbook_dir }}/../config/defaults.yml'
roles:
- role: common-init
tags: always

- name: Load the roles to run
hosts: homebox
tags: always
Expand All @@ -22,13 +13,21 @@
set_fact:
roles_list: '{{ lookup("env", "ROLE").split(",") }}'

- name: Run all the roles selected
- name: Run the backup tasls on the roles selected
hosts: homebox
vars:
debug: '{{ system.debug }}'
backup_directory: '{{ playbook_dir }}/../backup/{{ network.domain }}/'
vars_files:
- '{{ playbook_dir }}/../config/defaults/common-security.yml'
- '{{ playbook_dir }}/../config/defaults/version-{{ version | default("small") }}.yml'
- '{{ playbook_dir }}/../config/system.yml'
- '{{ playbook_dir }}/../config/defaults.yml'
tasks:
- name: Run the role selected
- name: Load common settings
tags: always
include_role:
name: common-init
- name: Run the roles selected
tags: always
include_role:
name: '{{ role }}'
Expand Down
5 changes: 1 addition & 4 deletions playbooks/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@
- '{{ playbook_dir }}/../config/defaults/version-{{ version | default("small") }}.yml'
- '{{ playbook_dir }}/../config/system.yml'
tasks:
- name: Reset the SSH connection
meta: reset_connection
tags: always
- name: Run common initialisation tasks
include_role:
name: common-init
tasks_from: check/main.yml
tasks_from: install/main.yml
tags: always
- name: Run the roles selected
include_role:
Expand Down
23 changes: 11 additions & 12 deletions playbooks/restore.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---

## Call the restore tasks on a role
## Call the restore tasks on a or more role

# export the role you want to run in the ‘ROLE’ environment variable
# and run the playbook.
Expand All @@ -13,21 +13,20 @@
set_fact:
roles_list: '{{ lookup("env", "ROLE").split(",") }}'

- name: Run the install tasks of one role
- name: Run the restore tasks on the roles selected
hosts: homebox
vars:
debug: '{{ system.debug }}'
backup_directory: '{{ playbook_dir }}/../backup/{{ network.domain }}/'
vars_files:
- '{{ playbook_dir }}/../config/defaults/common-security.yml'
- '{{ playbook_dir }}/../config/defaults/version-{{ version | default("small") }}.yml'
- '{{ playbook_dir }}/../config/system.yml'
- '{{ playbook_dir }}/../config/defaults.yml'
roles:
- role: common-init
tags: always

- name: Run all the roles selected
hosts: homebox
vars_files:
- '{{ playbook_dir }}/../config/system.yml'
- '{{ playbook_dir }}/../config/defaults.yml'
tasks:
- name: Load common settings
tags: always
include_role:
name: common-init
- name: Run the role selected
tags: always
include_role:
Expand Down
7 changes: 0 additions & 7 deletions roles/common-init/tasks/check/main.yml

This file was deleted.

17 changes: 17 additions & 0 deletions roles/dns-pdns/tasks/backup/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---

- name: Stop the DNS server
systemd:
name: pdns
state: stopped

- name: Retrieve the database
fetch:
src: /var/lib/powerdns/default.db
dest: '{{ backup_directory }}/pdns/default.db'
flat: true

- name: Start the DNS server
systemd:
name: pdns
state: started
16 changes: 16 additions & 0 deletions roles/dns-pdns/tasks/restore/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---

- name: Stop the DNS server
systemd:
name: pdns
state: stopped

- name: Copy the database
copy:
src: '{{ backup_directory }}/pdns/default.db'
dest: /var/lib/powerdns/default.db

- name: Start the DNS server
systemd:
name: pdns
state: started
2 changes: 1 addition & 1 deletion roles/dns-pdns/templates/pdns.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ webserver-allow-from=127.0.0.0/8,::1
# Secondary servers settings
master=yes
allow-axfr-ips={{ dns.replication.axfr_ips | join(", ") }}
# also-notify={{ dns.replication.notify | join(", ")}}
also-notify={{ dns.replication.notify | join(", ")}}
{% endif %}

{% if debug %}
Expand Down

0 comments on commit 709e168

Please sign in to comment.