Skip to content

Commit c91f8b9

Browse files
Merge pull request #447 from CodeNow/swarm-cloudwatch
Swarm CloudWatch
2 parents 0cd383f + 7eabe34 commit c91f8b9

5 files changed

Lines changed: 68 additions & 3 deletions

File tree

ansible/gamma-hosts/hosts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ gamma-app-services
112112

113113
[gamma:children]
114114
api
115-
api
116115
bastion
117116
charon
118117
consul
@@ -140,7 +139,6 @@ socket-server
140139
socket-server-proxy
141140
swarm-manager
142141
web
143-
web
144142
worker
145143

146144
[local]

ansible/gamma-hosts/variables

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ registry_s3_region=us-east-1
7474
aws_access_key_id=AKIAJ3RCYU6FCULAJP2Q
7575
aws_secret_access_key=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
7676

77+
[swarm-manager:vars]
78+
aws_access_key=AKIAIB5W3E6HR6Q52HEQ
79+
aws_secret_key=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
80+
environment_name=gamma
81+
7782
[vault:vars]
7883
vault_hello_runnable_github_token=88ddc423c2312d02a8bbcaad76dd4c374a30e4af
7984
vault_aws_access_key_id=AKIAJ7R4UIM45KH2WGWQ
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
name: swarm-cloudwatch-reporter
3+
4+
repo: git@github.com:CodeNow/furry-cactus.git
5+
container_image: registry.runnable.com/runnable/{{ name }}
6+
container_tag: "{{ git_branch }}"
7+
node_version: lts
8+
npm_version: 3
9+
do_not_push: true
10+
11+
log_driver: json-file
12+
13+
dockerfile_pre_install_commands:
14+
- npm config set progress false
15+
16+
container_run_opts: >-
17+
--log-driver={{ log_driver }}
18+
-e AWS_ACCESS_KEY={{ aws_access_key }}
19+
-e AWS_SECRET_KEY={{ aws_secret_key }}
20+
-e DOCKER_CERT_PATH=/opt/ssl/docker/swarm-manager
21+
-e ENVIRONMENT={{ environment_name }}
22+
-e SWARM_HOSTNAME={{ ansible_default_ipv4.address }}
23+
-e SWARM_PORT={{ swarm_master_port }}
24+
-v /opt/runnable/get-info.js:/get-info.js:ro
25+
-v /opt/ssl/docker/swarm-manager:/opt/ssl/docker/swarm-manager:ro
26+
-v /var/log:/var/log
27+
28+
container_run_args: npm start >> /var/log/{{ name }}.log 2>&1

ansible/roles/container_start/handlers/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222

2323
- name: stop old containers
2424
tags: deploy
25-
command: sudo docker stop --time={{ stop_time }} {{ item }}
25+
become: yes
26+
command: docker stop --time={{ stop_time }} {{ item }}
2627
with_items: "{{ old_containers_ids.stdout_lines }}"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
- hosts: swarm-manager
3+
vars_files:
4+
- group_vars/alpha-swarm-manager-metrics.yml
5+
roles:
6+
- role: builder
7+
tags: [ build ]
8+
tasks:
9+
- name: run container
10+
tags: test_swarm_stats
11+
when: test_swarm_stats is defined
12+
become: yes
13+
shell: >-
14+
docker run
15+
-e DRY_RUN=true
16+
{{ container_run_opts }}
17+
{{ container_image }}:{{ container_tag }}
18+
{{ container_run_args }}
19+
20+
- name: put script into cron
21+
tags: [ deploy ]
22+
become: yes
23+
cron:
24+
name: swarm-cloudwatch-reporter
25+
cron_file: 10-swarm-cloudwatch
26+
user: root
27+
state: present
28+
job: >-
29+
docker run
30+
--rm
31+
{{ container_run_opts }}
32+
{{ container_image }}:{{ container_tag }}
33+
{{ container_run_args }}

0 commit comments

Comments
 (0)