diff --git a/ansible/group_vars/alpha-khronos.yml b/ansible/group_vars/alpha-khronos.yml index 461852d8..6dbee149 100644 --- a/ansible/group_vars/alpha-khronos.yml +++ b/ansible/group_vars/alpha-khronos.yml @@ -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" + +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: > @@ -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 diff --git a/ansible/roles/khronos/tasks/main.yml b/ansible/roles/khronos/tasks/main.yml index 9d923b20..9cb34b8e 100644 --- a/ansible/roles/khronos/tasks/main.yml +++ b/ansible/roles/khronos/tasks/main.yml @@ -2,15 +2,12 @@ become: yes tags: cron template: - src: "{{ item }}" + src: "khronos-cron.sh" 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"} + - { cron_queues: "{{ canary_cron_queues }}", script: "canary-cron.sh"} - name: Put Khronos script into crontab become: yes @@ -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 diff --git a/ansible/roles/khronos/templates/build-canary.sh b/ansible/roles/khronos/templates/build-canary.sh deleted file mode 100644 index 41555219..00000000 --- a/ansible/roles/khronos/templates/build-canary.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# 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_build_canary_command }} diff --git a/ansible/roles/khronos/templates/container-metrics.sh b/ansible/roles/khronos/templates/container-metrics.sh deleted file mode 100644 index 99e76f7e..00000000 --- a/ansible/roles/khronos/templates/container-metrics.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# 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_container_metrics_command }} diff --git a/ansible/roles/khronos/templates/github-branch-canary.sh b/ansible/roles/khronos/templates/github-branch-canary.sh deleted file mode 100644 index b4b659d7..00000000 --- a/ansible/roles/khronos/templates/github-branch-canary.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# 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_github_branch_canary_command }} diff --git a/ansible/roles/khronos/templates/khronos-cron.sh b/ansible/roles/khronos/templates/khronos-cron.sh index 64dace14..fc0f8262 100755 --- a/ansible/roles/khronos/templates/khronos-cron.sh +++ b/ansible/roles/khronos/templates/khronos-cron.sh @@ -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" diff --git a/ansible/roles/khronos/templates/log-canary.sh b/ansible/roles/khronos/templates/log-canary.sh deleted file mode 100644 index f333ce9f..00000000 --- a/ansible/roles/khronos/templates/log-canary.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# 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_log_canary_command }}