Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions ansible/group_vars/alpha-khronos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ npm_version: 2

# for cron job
# this is the list of queues we want to enqueue a job into
cron_queues: khronos:containers:orphan:prune khronos:context-versions:prune-expired khronos:images:prune khronos:weave:prune
main_cron_queues: "\
khronos:containers:orphan:prune \
khronos:context-versions:prune-expired \
khronos:images:prune \
khronos:weave:prune"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah! this is easier to do like this:

main_cron_queues: |
  queue
  queue

turns into "queue\nqueue\n"


canary_cron_queues: "\
khronos:canary:build \
khronos:canary:github-branch \
khronos:canary:log \
khronos:canary:network \
khronos:metrics:container-status"

# a nice version of the rabbitmq host
cron_rabbit_host_address: "{{ rabbit_host_address }}:{{ rabbit_port }}"
# a quick version of authentication for rabbit for cron
cron_rabbit_auth: --username {{ rabbit_username }} --password {{ rabbit_password }}
# this is the command we want to run in the container.
cron_command: "bash -c \"for QUEUE in {{ cron_queues }}; do /khronos/bin/cli.js --queue \\$QUEUE --job '{}' --host {{ cron_rabbit_host_address }} {{ cron_rabbit_auth }}; done\""
# This is the build canary cron command
cron_build_canary_command: "/khronos/bin/cli.js --queue khronos:canary:build --job '{}' --host {{ cron_rabbit_host_address }} {{ cron_rabbit_auth }}"
# This is the log canary cron command
cron_log_canary_command: "/khronos/bin/cli.js --queue khronos:canary:log --job '{}' --host {{ cron_rabbit_host_address }} {{ cron_rabbit_auth }}"
# This is the github-branch canary cron command
cron_github_branch_canary_command: "/khronos/bin/cli.js --queue khronos:canary:github-branch --job '{}' --host {{ cron_rabbit_host_address }} {{ cron_rabbit_auth }}"
cron_container_metrics_command: "/khronos/bin/cli.js --queue khronos:metrics:container-status --job '{}' --host {{ cron_rabbit_host_address }} {{ cron_rabbit_auth }}"

# for container settings
container_envs: >
Expand Down Expand Up @@ -61,5 +64,3 @@ container_run_opts: >
-v /opt/ssl/mongo-client:/opt/ssl/mongo-client:ro
--memory=1500m
{{container_envs}}

npm_start_command: run start-json-output
27 changes: 6 additions & 21 deletions ansible/roles/khronos/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
become: yes
tags: cron
template:
src: "{{ item }}"
src: "khronos-cron.sh"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need quotes here

mode: 0744
dest: /opt/runnable/{{ item }}
dest: /opt/runnable/{{ item.script }}
with_items:
- khronos-cron.sh
- build-canary.sh
- log-canary.sh
- github-branch-canary.sh
- container-metrics.sh
- { cron_queues: "{{ main_cron_queues }}", script: "main-cron.sh"}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need quotes around the script name

- { cron_queues: "{{ canary_cron_queues }}", script: "canary-cron.sh"}

- name: Put Khronos script into crontab
become: yes
Expand All @@ -25,22 +22,10 @@
- name: Khronos CLI - Daily Cleanup
minute: 13
hour: 1,7,13,19
script: khronos-cron.sh
script: main-cron.sh
- name: Khronos CLI - Canary
minute: "*/5"
script: build-canary.sh
state: "{% if node_env == 'production-delta' %}present{% else %}absent{% endif %}"
- name: Khronos CLI - Github Branch Canary
minute: "*/5"
script: github-branch-canary.sh
state: "{% if node_env == 'production-delta' %}present{% else %}absent{% endif %}"
- name: Khronos CLI - Log Canary
minute: "*/5"
script: log-canary.sh
state: "{% if node_env == 'production-delta' %}present{% else %}absent{% endif %}"
- name: Container Metrics
minute: "*/5"
script: container-metrics.sh
script: canary-cron.sh
state: "{% if node_env == 'production-delta' %}present{% else %}absent{% endif %}"

- name: make directory for mongo certificates
Expand Down
5 changes: 0 additions & 5 deletions ansible/roles/khronos/templates/build-canary.sh

This file was deleted.

5 changes: 0 additions & 5 deletions ansible/roles/khronos/templates/container-metrics.sh

This file was deleted.

5 changes: 0 additions & 5 deletions ansible/roles/khronos/templates/github-branch-canary.sh

This file was deleted.

5 changes: 4 additions & 1 deletion ansible/roles/khronos/templates/khronos-cron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
# THIS FILE IS MANAGED BY ANSIBLE. PLEASE DO NOT MODIFY. MODIFICATIONS WILL NOT BE SAVED.
# AUTHOR: BRYAN KENDALL

docker run --rm {{ container_image }}:{{ container_tag }} {{ cron_command }}
docker run --rm {{ container_image }}:{{ container_tag }} bash -c " \
for QUEUE in {{ item.cron_queues }}; do \
/khronos/bin/cli.js --queue \$QUEUE --job '{}' --host {{ cron_rabbit_host_address }} {{ cron_rabbit_auth }}; \
done"
5 changes: 0 additions & 5 deletions ansible/roles/khronos/templates/log-canary.sh

This file was deleted.