-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6816cd
commit 5dd9b84
Showing
15 changed files
with
355 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# OS generated files # | ||
###################### | ||
.DS_Store | ||
.DS_Store? | ||
._* | ||
.Spotlight-V100 | ||
.Trashes | ||
Icon? | ||
ehthumbs.db | ||
Thumbs.db | ||
|
||
# IDE files # | ||
################# | ||
/.settings | ||
/.buildpath | ||
/.project | ||
/nbproject | ||
*.komodoproject | ||
*.kpf | ||
/.idea | ||
|
||
# Vagrant files # | ||
.virtualbox/ | ||
.vagrant/ | ||
vagrant_ansible_inventory_* | ||
ansible.cfg | ||
|
||
# Other files # | ||
############### | ||
!empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
sudo: required | ||
dist: trusty | ||
|
||
language: python | ||
python: "2.7" | ||
|
||
env: | ||
- ANSIBLE_VERSION=latest | ||
- ANSIBLE_VERSION=2.0.2.0 | ||
- ANSIBLE_VERSION=2.0.1.0 | ||
- ANSIBLE_VERSION=2.0.0.2 | ||
- ANSIBLE_VERSION=2.0.0.1 | ||
- ANSIBLE_VERSION=2.0.0.0 | ||
- ANSIBLE_VERSION=1.9.6 | ||
- ANSIBLE_VERSION=1.9.5 | ||
- ANSIBLE_VERSION=1.9.4 | ||
- ANSIBLE_VERSION=1.9.3 | ||
- ANSIBLE_VERSION=1.9.2 | ||
- ANSIBLE_VERSION=1.9.1 | ||
- ANSIBLE_VERSION=1.9.0.1 | ||
- ANSIBLE_VERSION=1.8.4 | ||
- ANSIBLE_VERSION=1.8.3 | ||
- ANSIBLE_VERSION=1.8.2 | ||
- ANSIBLE_VERSION=1.8.1 | ||
- ANSIBLE_VERSION=1.8 | ||
- ANSIBLE_VERSION=1.7.2 | ||
- ANSIBLE_VERSION=1.7.1 | ||
- ANSIBLE_VERSION=1.7 | ||
- ANSIBLE_VERSION=1.6.9 | ||
- ANSIBLE_VERSION=1.6.8 | ||
- ANSIBLE_VERSION=1.6.7 | ||
- ANSIBLE_VERSION=1.6.6 | ||
- ANSIBLE_VERSION=1.6.5 | ||
- ANSIBLE_VERSION=1.6.4 | ||
- ANSIBLE_VERSION=1.6.3 | ||
- ANSIBLE_VERSION=1.6.2 | ||
- ANSIBLE_VERSION=1.6.10 | ||
- ANSIBLE_VERSION=1.6.1 | ||
- ANSIBLE_VERSION=1.6 | ||
|
||
branches: | ||
only: | ||
- master | ||
|
||
before_install: | ||
- sudo apt-get update -qq | ||
|
||
install: | ||
# Install Ansible. | ||
- if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install --no-binary ansible ansible; else pip install --no-binary ansible ansible==$ANSIBLE_VERSION; fi | ||
|
||
script: | ||
# Check the role/playbook's syntax. | ||
- ansible-playbook -i tests/inventory tests/test.yml --syntax-check | ||
|
||
# Run the role/playbook with ansible-playbook. | ||
- ansible-playbook -i tests/inventory tests/test.yml -vvvv | ||
|
||
# Run the role/playbook again, checking to make sure it's idempotent. | ||
- > | ||
ansible-playbook -i tests/inventory tests/test.yml | ||
| grep -q 'changed=0.*failed=0' | ||
&& (echo 'Idempotence test: pass' && exit 0) | ||
|| (echo 'Idempotence test: fail' && exit 1) | ||
notifications: | ||
email: false | ||
hipchat: | ||
rooms: | ||
secure: HUjf9K0xYcIzvIrqyz7OgzoEx5PX7PoUeEWBnI+7vpC0rneP3wijqNcsjLoDVHDqzmPp7Snm7Q3/cVGbspqRvFHMmdfMF5DYYD0eQMPBcJnLvV+LkvUA+cSuuzr52ktLx7Y+UDFNuYXX/68XnEBndEiu7gtcjHOXTPniA116j94rdntLiU5zXFbVDg2rQRR8nOHOFuBZ3tU41x/jQZbUmZM36gAd+GnrygE9/kyUdv1vs4F5yLlhkii5yT54X63cV4gvfiB6yYwiGooYYW8guY0P84FkXpvibLt3XDdWTS6ikOcmdpnFbAryzpQI1KNn49WhDoBN3nVWEBRQ8NplWqHBNFBvURTarOICOEAhWIJHTYIMfSVYlfKloBNf6fwm3ZSQ26VL56h2NlGNCSaZU0rj/5Kab7VbVcdX1nAXE5DNrTaIc0rK+SRvjIVdJ81bS0pdcKm0xeZtppqdtm4bqiUxeWKO2PbwDcgc/FtlFHOiqT4JLRSDOtwli/t+mSiyuMvGMIuqmNbvSSQtXvTeiCNojfDambI1HWxtwtdzg61hJVjzlicr/h1l2H5HL2T9TTPYBQ3D/s9pFj1nfUrtswuSXLfGAWRRRWnrrtuKxpeYKwMk1H5TFx2CWhqxMLAF+RrIoi3Rx5+87noed7GZOh9dpCt015Aayqz69/rLH5U= | ||
webhooks: https://galaxy.ansible.com/api/v1/notifications/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
## cacti-rrd-backup | ||
|
||
[![Build Status](https://travis-ci.org/Oefenweb/ansible-cacti-rrd-backup.svg?branch=master)](https://travis-ci.org/Oefenweb/ansible-cacti-rrd-backup) [![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-cacti--rrd--backup-blue.svg)](https://galaxy.ansible.com/Oefenweb/ansible-cacti-rrd-backup) | ||
|
||
Perform Cacti RRD backups using [rrdtool](http://oss.oetiker.ch/rrdtool/). | ||
|
||
#### Requirements | ||
|
||
* `rrdtool` (will be installed) | ||
|
||
#### Variables | ||
|
||
* `cacti_rrd_backup_install_path`: [default: `/usr/local/bin`]: Install directory | ||
|
||
* `cacti_rrd_backup_rra_path`: [default: `/var/lib/cacti/rra`]: The source path (cacti `rra` path) | ||
* `cacti_rrd_backup_backup_path`: [default: `/tmp/cacti-rrd-backup`]: The destination path | ||
|
||
* `cacti_rrd_backup_rrd_file_mode`: [default: `0664`]: The mode of rrd files (after restore) | ||
* `cacti_rrd_backup_rrd_file_owner`: [default: `www-data`]: The owner of rrd files (after restore) | ||
* `cacti_rrd_backup_rrd_file_group`: [default: `cacti_rrd_backup_rrd_file_owner`]: The group of rrd files (after restore) | ||
|
||
#### Dependencies | ||
|
||
None | ||
|
||
#### Example | ||
|
||
```yaml | ||
--- | ||
- hosts: all | ||
roles: | ||
- cacti-rrd-backup | ||
``` | ||
#### License | ||
MIT | ||
#### Author Information | ||
Mischa ter Smitten | ||
#### Feedback, bug-reports, requests, ... | ||
Are [welcome](https://github.com/Oefenweb/ansible-cacti-rrd-backup/issues)! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby ts=2 sw=2 tw=0 et : | ||
|
||
role = File.basename(File.expand_path(File.dirname(__FILE__))) | ||
|
||
boxes = [ | ||
{ | ||
:name => "ubuntu-1204", | ||
:box => "opscode-ubuntu-12.04", | ||
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-12.04_chef-provisionerless.box", | ||
:ip => '10.0.0.11', | ||
:cpu => "50", | ||
:ram => "256" | ||
}, | ||
{ | ||
:name => "ubuntu-1404", | ||
:box => "opscode-ubuntu-14.04", | ||
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box", | ||
:ip => '10.0.0.12', | ||
:cpu => "50", | ||
:ram => "256" | ||
}, | ||
{ | ||
:name => "ubuntu-1604", | ||
:box => "opscode-ubuntu-16.04", | ||
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-16.04_chef-provisionerless.box", | ||
:ip => '10.0.0.13', | ||
:cpu => "50", | ||
:ram => "256" | ||
}, | ||
{ | ||
:name => "debian-710", | ||
:box => "opscode-debian-7.10", | ||
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-7.10_chef-provisionerless.box", | ||
:ip => '10.0.0.14', | ||
:cpu => "50", | ||
:ram => "256" | ||
}, | ||
{ | ||
:name => "debian-84", | ||
:box => "opscode-debian-8.4", | ||
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_debian-8.4_chef-provisionerless.box", | ||
:ip => '10.0.0.15', | ||
:cpu => "50", | ||
:ram => "256" | ||
}, | ||
] | ||
|
||
Vagrant.configure("2") do |config| | ||
boxes.each do |box| | ||
config.vm.define box[:name] do |vms| | ||
vms.vm.box = box[:box] | ||
vms.vm.box_url = box[:url] | ||
vms.vm.hostname = "ansible-#{role}-#{box[:name]}" | ||
|
||
vms.vm.provider "virtualbox" do |v| | ||
v.customize ["modifyvm", :id, "--cpuexecutioncap", box[:cpu]] | ||
v.customize ["modifyvm", :id, "--memory", box[:ram]] | ||
end | ||
|
||
vms.vm.network :private_network, ip: box[:ip] | ||
|
||
vms.vm.provision :ansible do |ansible| | ||
ansible.playbook = "tests/vagrant.yml" | ||
ansible.verbose = "vv" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# defaults file for cacti-rrd-backup | ||
--- | ||
cacti_rrd_backup_install_path: /usr/local/bin | ||
|
||
cacti_rrd_backup_rra_path: /var/lib/cacti/rra | ||
cacti_rrd_backup_backup_path: /tmp/cacti-rrd-backup | ||
|
||
cacti_rrd_backup_rrd_file_mode: '0664' | ||
cacti_rrd_backup_rrd_file_owner: www-data | ||
cacti_rrd_backup_rrd_file_group: "{{ cacti_rrd_backup_rrd_file_owner }}" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# handlers file for cacti-rrd-backup | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# meta file for cacti-rrd-backup | ||
--- | ||
galaxy_info: | ||
author: Mischa ter Smitten | ||
company: Oefenweb.nl B.V. | ||
description: Perform Cacti RRD backups using rrdtool | ||
license: MIT | ||
min_ansible_version: 1.6 | ||
platforms: | ||
- name: Ubuntu | ||
versions: | ||
- precise | ||
- trusty | ||
- xenial | ||
- name: Debian | ||
versions: | ||
- wheezy | ||
- jessie | ||
galaxy_tags: | ||
- system | ||
- monitoring | ||
dependencies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# tasks file for cacti-rrd-backup | ||
--- | ||
- name: install dependencies | ||
apt: | ||
name: "{{ item }}" | ||
state: latest | ||
update_cache: true | ||
cache_valid_time: "{{ apt_update_cache_valid_time | default(3600) }}" | ||
with_items: "{{ cacti_rrd_backup_dependencies }}" | ||
tags: | ||
- configuration | ||
- cacti-rrd-backup | ||
- cacti-rrd-backup-install | ||
- cacti-rrd-backup-install-dependencies | ||
|
||
- name: generate (backup) script | ||
template: | ||
src: usr/local/bin/cacti-rrd-backup.j2 | ||
dest: "{{ cacti_rrd_backup_install_path }}/cacti-rrd-backup" | ||
owner: root | ||
group: root | ||
mode: 0750 | ||
validate: '/usr/bin/env bash -n %s' | ||
tags: | ||
- configuration | ||
- cacti-rrd-backup | ||
- cacti-rrd-backup-configuration | ||
|
||
- name: generate (restore) script | ||
template: | ||
src: usr/local/bin/cacti-rrd-restore.j2 | ||
dest: "{{ cacti_rrd_backup_install_path }}/cacti-rrd-restore" | ||
owner: root | ||
group: root | ||
mode: 0750 | ||
validate: '/usr/bin/env bash -n %s' | ||
tags: | ||
- configuration | ||
- cacti-rrd-backup | ||
- cacti-rrd-backup-configuration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# {{ ansible_managed }} | ||
# | ||
# set -x; | ||
set -e; | ||
set -o pipefail; | ||
# | ||
thisFile="$(readlink -f "${0}")"; | ||
thisFilePath="$(dirname "${thisFile}")"; | ||
|
||
test -d '{{ cacti_rrd_backup_rra_path }}'; | ||
mkdir -p -m {{ cacti_rrd_backup_backup_path_mode }} '{{ cacti_rrd_backup_backup_path }}'; | ||
|
||
cd {{ cacti_rrd_backup_rra_path }}; | ||
for rrdFile in *.rrd; do | ||
rrdtool dump "${rrdFile}" "{{ cacti_rrd_backup_backup_path}}/${rrdFile}.xml"; | ||
done; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# {{ ansible_managed }} | ||
# | ||
# set -x; | ||
set -e; | ||
set -o pipefail; | ||
# | ||
thisFile="$(readlink -f "${0}")"; | ||
thisFilePath="$(dirname "${thisFile}")"; | ||
|
||
test -d '{{ cacti_rrd_backup_rra_path }}'; | ||
test -d '{{ cacti_rrd_backup_backup_path }}'; | ||
|
||
cd {{ cacti_rrd_backup_backup_path }}; | ||
for xmlFile in *.xml; do | ||
rrdFile="$(echo "${xmlFile}" | sed 's/.xml//')"; | ||
rrdtool restore -f "${xmlFile}" "{{ cacti_rrd_backup_rra_path}}/${rrdFile}"; | ||
done; | ||
|
||
find '{{ cacti_rrd_backup_rra_path}}' -type f -name "*.rrd" -print0 | xargs --no-run-if-empty -0 \ | ||
chmod {{ cacti_rrd_backup_rrd_file_mode }} \ | ||
; | ||
find '{{ cacti_rrd_backup_rra_path}}' -type f -name "*.rrd" -print0 | xargs --no-run-if-empty -0 \ | ||
chown {{ cacti_rrd_backup_rrd_file_owner }}:{{ cacti_rrd_backup_rrd_file_group }} \ | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# test file for cacti-rrd-backup | ||
--- | ||
- hosts: localhost | ||
connection: local | ||
sudo: true | ||
roles: | ||
- ../../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# test file for cacti-rrd-backup | ||
--- | ||
- hosts: all | ||
remote_user: vagrant | ||
sudo: true | ||
roles: | ||
- ../../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# vars file for cacti-rrd-backup | ||
--- | ||
cacti_rrd_backup_dependencies: | ||
- rrdtool | ||
|
||
cacti_rrd_backup_backup_path_mode: '0750' |