e764a59877
Add the cron job that existed in puppet-graphite to cleanup old, un-updated stats and directories. Change-Id: Iac4676ae0ea1d5f1b96b6214ab6ab193c71a2d20
74 lines
1.8 KiB
YAML
74 lines
1.8 KiB
YAML
- name: Ensure docker-compose directory exists
|
|
file:
|
|
state: directory
|
|
path: /etc/graphite-docker
|
|
|
|
- name: Write settings file
|
|
template:
|
|
src: docker-compose.yaml.j2
|
|
dest: /etc/graphite-docker/docker-compose.yaml
|
|
|
|
- name: Write storage config file
|
|
template:
|
|
src: storage-schemas.conf.j2
|
|
dest: /etc/graphite-docker/storage-schemas.conf
|
|
|
|
- name: Write nginx override config
|
|
template:
|
|
src: graphite-statsd.conf.j2
|
|
dest: /etc/graphite-docker/graphite-statsd.conf
|
|
|
|
- name: Write statsd override config
|
|
template:
|
|
src: statsd.js.j2
|
|
dest: /etc/graphite-docker/statsd.js
|
|
|
|
- name: Ensure storage directory exists
|
|
file:
|
|
state: directory
|
|
path: /opt/graphite/storage
|
|
|
|
- name: Ensure log directory exists
|
|
file:
|
|
state: directory
|
|
path: /var/log/graphite
|
|
|
|
- name: Run docker-compose pull
|
|
shell:
|
|
cmd: docker-compose pull
|
|
chdir: /etc/graphite-docker/
|
|
|
|
- name: Run docker-compose up
|
|
shell:
|
|
cmd: docker-compose up -d
|
|
chdir: /etc/graphite-docker/
|
|
|
|
- name: Run docker prune to cleanup unneeded images
|
|
shell:
|
|
cmd: docker image prune -f
|
|
|
|
# This is handy to have on the host for checking stat ingestion
|
|
- name: Install netcat
|
|
package:
|
|
name:
|
|
- netcat
|
|
state: present
|
|
|
|
# Removes files not updated for ~9 months, and clears out empty directories
|
|
- name: Run periodic cleanup
|
|
cron:
|
|
name: "Graphite cleanup"
|
|
minute: "0"
|
|
hour: "2"
|
|
job: >
|
|
bash -c 'echo "--- $(date) ---";
|
|
find /opt/graphite/storage/whisper -type f -mtime +270 -name "*.wsp" -delete -print;
|
|
find /opt/graphite/storage/whisper -depth -type d -empty -delete -print'
|
|
>> /var/log/graphite-cleanup.log 2>&1
|
|
|
|
- name: Rotate cleanup logs
|
|
include_role:
|
|
name: logrotate
|
|
vars:
|
|
logrotate_file_name: '/var/log/graphite-cleanup.log'
|