Skip to content

Commit 15099a9

Browse files
author
anandkumarpatel
committed
Merge pull request #192 from CodeNow/SAN-2841
San 2841
2 parents db91a15 + fdfd1ef commit 15099a9

5 files changed

Lines changed: 36 additions & 0 deletions

File tree

ansible/group_vars/alpha-khronos.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ npm_version: "2.1.18"
88

99
mongo_hosts: "{% for host in groups['mongodb'] %}{{ hostvars[host]['ansible_default_ipv4']['address'] }}:27000{% if not loop.last %},{% endif %}{% endfor %}"
1010

11+
# for cron job
12+
# this is the list of queues we want to enqueue a job into
13+
cron_queues: khronos:containers:image-builder:prune khronos:containers:orphan:prune khronos:context-versions:prune-expired khronos:images:prune khronos:weave:prune
14+
# a nice version of the rabbitmq host
15+
cron_rabbit_host: "{{ rabbit_host | default(hostvars[groups['rabbitmq'][0]]['ansible_default_ipv4']['address']) }}:{{ rabbit_port }}"
16+
# a quick version of authentication for rabbit for cron
17+
cron_rabbit_auth: --username {{ rabbit_username }} --password {{ rabbit_password }}
18+
# this is the command we want to run in the container.
19+
cron_command: "bash -c \"for QUEUE in {{ cron_queues }}; do /khronos/bin/cli.js --queue \\$QUEUE --job '{}' --host {{ cron_rabbit_host }} {{ cron_rabbit_auth }}; done\""
20+
1121
# for container settings
1222
container_envs: >
1323
-h khronos

ansible/khronos.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
- { role: docker_client }
1010
- { role: builder, tags: "build" }
1111
- { role: container_kill_start, tags: "deploy" }
12+
- { role: khronos, tags: ["deploy"] }

ansible/roles/khronos/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Run Khronos CLI tool out of cron once daily.
2+
3+
`tasks/main.yml` - install cron entry to run `/khronos/bin/cli.js` and output to `/var/log/khonos_cron.log`
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
- name: Put khronos cron script in place
2+
sudo: yes
3+
tags: cron
4+
template:
5+
src="khronos-cron.sh"
6+
mode=0744
7+
dest="/opt/runnable/khronos-cron.sh"
8+
9+
# Run Cronjob once every day at UTC 0400.
10+
- name: Put Khronos CLI job in place
11+
sudo: yes
12+
tags: cron
13+
cron:
14+
name="Khronos CLI Daily"
15+
minute="0"
16+
hour="4"
17+
job="/opt/runnable/khronos-cron.sh >> /var/log/khronos_cron.log 2>&1"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
# THIS FILE IS MANAGED BY ANSIBLE. PLEASE DO NOT MODIFY. MODIFICATIONS WILL NOT BE SAVED.
3+
# AUTHOR: BRYAN KENDALL
4+
5+
docker run --rm {{ container_image }}:{{ container_tag }} {{ cron_command }}

0 commit comments

Comments
 (0)