Initial molecule WIP
This commit is contained in:
parent
4475c07bc2
commit
3e1b0473cc
86 changed files with 1904 additions and 0 deletions
14
molecule/generic_files/Dockerfile.j2
Normal file
14
molecule/generic_files/Dockerfile.j2
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Molecule managed
|
||||
|
||||
{% if item.registry is defined %}
|
||||
FROM {{ item.registry.url }}/{{ item.image }}
|
||||
{% else %}
|
||||
FROM {{ item.image }}
|
||||
{% endif %}
|
||||
|
||||
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates cron iputils-ping openssh-client openssh-server && apt-get clean; \
|
||||
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
|
||||
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash anacron iputils openssh-clients openssh-server && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
|
||||
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \
|
||||
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
|
||||
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi
|
||||
5
molecule/generic_files/playbook.yml
Normal file
5
molecule/generic_files/playbook.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
roles:
|
||||
- role: borgbackup
|
||||
23
molecule/generic_files/prepare.yml
Normal file
23
molecule/generic_files/prepare.yml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
- name: prepare servers - Debian only
|
||||
hosts: borgbackup_servers
|
||||
gather_facts: true
|
||||
tasks:
|
||||
- name: start ssh - Debian Server
|
||||
command: service ssh start
|
||||
# note: https://forums.docker.com/t/any-simple-and-safe-way-to-start-services-on-centos7-systemd/5695/8
|
||||
# needs to be implemented
|
||||
# - name: start sshd
|
||||
# command: service sshd start
|
||||
|
||||
- name: prepare lamp
|
||||
hosts: lamp
|
||||
tasks:
|
||||
- name: Install required packages
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
state: installed
|
||||
with_items:
|
||||
- apache2
|
||||
- mysql-server
|
||||
- automysqlbackup
|
||||
1
molecule/generic_files/restore.sh.j2
Symbolic link
1
molecule/generic_files/restore.sh.j2
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../restore/restore.sh.j2
|
||||
9
molecule/generic_files/tests/test_all.yml
Normal file
9
molecule/generic_files/tests/test_all.yml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Molecule managed
|
||||
|
||||
---
|
||||
file:
|
||||
/usr/local/bin/borg:
|
||||
exists: true
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
38
molecule/generic_files/tests/test_client.yml
Normal file
38
molecule/generic_files/tests/test_client.yml
Normal 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}.*/"
|
||||
18
molecule/generic_files/tests/test_client_restore.yml
Normal file
18
molecule/generic_files/tests/test_client_restore.yml
Normal 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 %}
|
||||
28
molecule/generic_files/tests/test_server.yml
Normal file
28
molecule/generic_files/tests/test_server.yml
Normal 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 %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue