Skip to content
Snippets Groups Projects
Commit 92f6e967 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Role for lvm-snapshots

parent a1fb07a1
No related branches found
No related tags found
No related merge requests found
---
# file: roles/lvm-snapshots/defaults/main.yml
program_dir: /opt/lvm-snapshots
snapshot_cron_minutes: 15
snapshot_volumes:
- volume_group: exports
name: pub
path: .snapshots
keep:
- number: 4
interval: 15M
- number: 24
interval: 1H
- number: 31
interval: 1d
- number: 6
interval: 1m
Host git.fsmpi.rwth-aachen.de
HostName git.fsmpi.rwth-aachen.de
User git
IdentityFile lvm-snapshots.key
---
# file: roles/lvm-snapshots/tasks/main.yml
- name: ensure we have the target folder
file: path="{{program_dir}}" state=directory owner=root group=root mode=0755
tags:
- lvm-snapshots
- directory
- name: ensure we know our deploy key
local_action: pass name="deploy-key/lvm-snapshots" state=present store=FSMPI_PASSWORD_STORE_DIR limit=no
register: deploy_key
no_log: True
tags:
- lvm-snapshots
- password
- name: ensure we know our public deploy key
local_action: pass name="deploy-key/lvm-snapshots-public" state=present store=FSMPI_PASSWORD_STORE_DIR limit=no
register: deploy_key_public
no_log: True
tags:
- lvm-snapshots
- password
- name: ensure our deploy key is present
copy:
content: "{{deploy_key.password}}\n"
dest: /root/.ssh/lvm-snapshots.key
owner: root
group: root
mode: 0600
no_log: True
tags:
- lvm-snapshots
- ssh
- name: ensure our public deploy key is present
copy:
content: "{{deploy_key_public.password}}\n"
dest: /root/.ssh/lvm-snapshots.pub
owner: root
group: root
mode: 0644
no_log: True
tags:
- lvm-snapshots
- ssh
- name: ensure we have our lvm-snapshots ssh config
copy:
src: ssh-config.lvm-snapshots
dest: /root/.ssh/config.lvm-snapshots
owner: root
group: root
mode: 0644
tags:
- lvm-snapshots
- ssh
- config
- name: ensure our lvm-snapshots ssh config is included
lineinfile:
dest: /root/.ssh/config
line: "Include config.lvm-snapshots"
create: yes
owner: root
group: root
mode: 0644
tags:
- lvm-snapshots
- ssh
- config
- name: ensure we have the program
git:
repo: git@git.fsmpi.rwth-aachen.de:infra/lvm-snapshots.git
dest: "{{program_dir}}"
tags:
- git
- lvm-snapshots
- name: ensure the necessary programs are installed
apt: name="{{item}}" state=present
with_items:
- python3
- virtualenv
tags:
- packages
- lvm-snapshots
- name: ensure we have a virtualenv
pip:
requirements: "{{program_dir}}/requirements.txt"
virtualenv: "{{program_dir}}"
virtualenv_python: python3
tags:
- pip
- python
- lvm-snapshots
- name: ensure we have a frontend script
template:
src: script.sh
dest: /usr/local/sbin/lvm-snapshots
owner: root
group: root
mode: 0755
tags:
- lvm-snapshots
- config
- name: ensure we have our config
template:
src: config.toml
dest: /etc/lvm-snapshots.toml
owner: root
group: root
mode: 0644
tags:
- lvm-snapshots
- config
- name: ensure we have a cron job
cron:
name: "lvm-snapshots"
minute: "*/{{snapshot_cron_minutes}}"
job: "/usr/local/sbin/lvm-snapshots update"
tags:
- lvm-snapshots
- cron
{% for volume in snapshot_volumes %}
[[volume]]
volume_group = "{{volume.volume_group}}"
name = "{{volume.name}}"
path = "{{volume.path}}"
{% for keep in volume.keep %}
[[volume.keep]]
number = {{keep.number}}
interval = "{{keep.interval}}"
{% endfor %}
{% endfor %}
#!/bin/bash
{{program_dir}}/bin/python {{program_dir}}/lvmsnapshot.py "$@"
exit $?
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment