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
2 changes: 0 additions & 2 deletions ansible/gamma-hosts/hosts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ gamma-app-services

[gamma:children]
api
api
bastion
charon
consul
Expand Down Expand Up @@ -140,7 +139,6 @@ socket-server
socket-server-proxy
swarm-manager
web
web
worker

[local]
Expand Down
5 changes: 5 additions & 0 deletions ansible/gamma-hosts/variables
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ registry_s3_region=us-east-1
aws_access_key_id=AKIAJ3RCYU6FCULAJP2Q
aws_secret_access_key=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

[swarm-manager:vars]
aws_access_key=AKIAIB5W3E6HR6Q52HEQ
aws_secret_key=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
environment_name=gamma

[vault:vars]
vault_hello_runnable_github_token=88ddc423c2312d02a8bbcaad76dd4c374a30e4af
vault_aws_access_key_id=AKIAJ7R4UIM45KH2WGWQ
Expand Down
28 changes: 28 additions & 0 deletions ansible/group_vars/alpha-swarm-manager-metrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

+1 for containerization!!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

containerization on a budget haha

name: swarm-cloudwatch-reporter

repo: git@github.com:CodeNow/furry-cactus.git
container_image: registry.runnable.com/runnable/{{ name }}
container_tag: "{{ git_branch }}"
node_version: lts
npm_version: 3
do_not_push: true

log_driver: json-file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this works for you?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

of course it does. I don't have things going to loggly. I could send them to loggly. if I just pipe my random json-ish output to standard out, would it just show up in loggly under my application's name as a tag? /cc @und1sk0

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.

it should, yes

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OOO my bad, I missed that you are not using the start* roles, LGTM


dockerfile_pre_install_commands:
- npm config set progress false
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this seems like we want it for everything, add it to the base dockerfile :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this seems like we want it for everything, add it to the base dockerfile

nope. others could be using a version of npm that doesn't support that for w/e reason.


container_run_opts: >-
--log-driver={{ log_driver }}
-e AWS_ACCESS_KEY={{ aws_access_key }}
-e AWS_SECRET_KEY={{ aws_secret_key }}
-e DOCKER_CERT_PATH=/opt/ssl/docker/swarm-manager
-e ENVIRONMENT={{ environment_name }}
-e SWARM_HOSTNAME={{ ansible_default_ipv4.address }}
-e SWARM_PORT={{ swarm_master_port }}
-v /opt/runnable/get-info.js:/get-info.js:ro
-v /opt/ssl/docker/swarm-manager:/opt/ssl/docker/swarm-manager:ro
-v /var/log:/var/log

container_run_args: npm start >> /var/log/{{ name }}.log 2>&1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

we don't do this anymore?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

see other comment about logging...

3 changes: 2 additions & 1 deletion ansible/roles/container_start/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@

- name: stop old containers
tags: deploy
command: sudo docker stop --time={{ stop_time }} {{ item }}
become: yes
command: docker stop --time={{ stop_time }} {{ item }}
with_items: "{{ old_containers_ids.stdout_lines }}"
33 changes: 33 additions & 0 deletions ansible/swarm-cloudwatch-reporter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
- hosts: swarm-manager
vars_files:
- group_vars/alpha-swarm-manager-metrics.yml
roles:
- role: builder
tags: [ build ]
tasks:
- name: run container
tags: test_swarm_stats
when: test_swarm_stats is defined
become: yes
shell: >-
docker run
-e DRY_RUN=true
{{ container_run_opts }}
{{ container_image }}:{{ container_tag }}
{{ container_run_args }}

- name: put script into cron
tags: [ deploy ]
become: yes
cron:
name: swarm-cloudwatch-reporter
cron_file: 10-swarm-cloudwatch
user: root
state: present
job: >-
docker run
--rm
{{ container_run_opts }}
{{ container_image }}:{{ container_tag }}
{{ container_run_args }}