Initial molecule WIP

This commit is contained in:
Dieter Verhelst 2018-08-30 23:34:04 +02:00
parent 4475c07bc2
commit 3e1b0473cc
86 changed files with 1904 additions and 0 deletions

View file

@ -0,0 +1,9 @@
# Molecule managed
---
file:
/usr/local/bin/borg:
exists: true
owner: root
group: root
mode: "0755"

View file

@ -0,0 +1,38 @@
# Molecule managed
---
file:
/var/log/borg-backup.log:
exists: true
owner: root
group: root
contains:
- "Backup succeeded"
/root/.borg.passphrase:
exists: true
owner: root
group: root
contains:
- 'export BORG_PASSPHRASE="{{ borgbackup_passphrase }}"'
/root/.ssh/config:
exists: true
owner: root
group: root
contains:
{% for item in borgbackup_servers %}
- 'ANSIBLE MANAGED BLOCK {{ item.fqdn }}'
{% endfor %}
/usr/local/bin/borg-backup:
exists: true
owner: root
group: root
mode: "0744"
command:
bash /usr/local/bin/borg-backup list:
exit-status: 0
stdout:
{% for item in borgbackup_servers %}
- "Archives on {{ item.fqdn }}"
{% endfor %}
- "/[[:digit:]]{8}-[[:digit:]]{4}.*/"

View file

@ -0,0 +1,18 @@
---
file:
/root/sample.txt:
exists: true
command:
{% for item in borgbackup_servers %}
diff -s /root/sample.txt /root/restore/{{ item.fqdn }}/root/sample.txt:
exit-status: 0
stdout:
- "Files /root/sample.txt and /root/restore/{{ item.fqdn }}/root/sample.txt are identical"
{% endfor %}
/root/restore.sh verify:
exit-status: 0
stdout:
{% for item in borgbackup_servers %}
- "verifying on {{ item.fqdn }}"
{% endfor %}

View file

@ -0,0 +1,28 @@
# Molecule managed
---
file:
{% for item in borgbackup_servers %}
{% if item.fqdn == inventory_hostname %}
{{ item.home }}:
exists: true
owner: "{{ item.user }}"
group: "{{ item.user }}"
{% for host in groups.all|difference(groups.borgbackup_servers) %}
{{ item.home }}/repos/{{ host }}:
exists: true
{% endfor %}
{% endif %}
{% endfor %}
{% for item in borgbackup_servers %}
{% if item.fqdn == inventory_hostname %}
{{ item.home }}/.ssh/authorized_keys:
exists: true
owner: "{{ item.user }}"
group: "{{ item.user }}"
contains:
{% for host in groups.all|difference(groups.borgbackup_servers) %}
- "{{ host }};borg serve"
{% endfor %}
{% endif %}
{% endfor %}