-
Notifications
You must be signed in to change notification settings - Fork 0
Create shared dock ami #611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 31 commits
3b1b007
392f95e
96d9044
ffd27ad
be570dd
eeca2c8
e4db52b
55f3ff6
a7b1a87
e5f2fcb
c41a0b5
425548c
8df4393
982098d
9400c65
936f71b
60bd667
3b27d32
e0023b2
b44c6c6
76ec750
b1468d0
c4ebcba
15fee45
d1c5bd3
41afba3
0cb5bfd
cbd2587
ed929f7
df930de
23dda55
6d18554
ee5737c
be0ec5f
e56c257
d2b5e7b
e632e45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| - hosts: redis | ||
| - hosts: consul | ||
|
|
||
| - hosts: user-local | ||
| connection: local | ||
| roles: | ||
| - { role: dock_launch_config } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| --- | ||
| - name: ensure registry.runnable in /etc/hosts | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wait why do you still have this? we can remove this now right There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| become: true | ||
| tags: ensure_registry | ||
| when: dock is not defined | ||
| lineinfile: | ||
| dest=/etc/hosts | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,19 +5,10 @@ | |
| name=docker | ||
| state=started | ||
|
|
||
| - name: add runnable registry to /etc/hosts | ||
| become: true | ||
| blockinfile: | ||
| dest: /etc/hosts | ||
| insertafter: EOF | ||
| block: | | ||
| {{ registry_address }} registry.runnable.com | ||
|
|
||
| - name: pulling docker images | ||
| become: true | ||
| command: docker pull {{ item }} | ||
| with_items: | ||
| - "registry.runnable.com/runnable/image-builder:v4.3.0" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @anandkumarpatel and I talked about this. We DO want to bake this image into the AMI in order to make first builds fast, but we have to push |
||
| - "swarm:1.2.5" | ||
| - "registry:2.3.1" | ||
| - "google/cadvisor:v0.24.1" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| --- | ||
| - name: load variables | ||
| include_vars: "group_vars/alpha-krain.yml" | ||
|
|
||
| - name: create new config file for krain | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't dock-init do this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not right now, no. Seems like it should though. Do we want to move it there? Would need some guidance on how to do this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, we can't do that because we start the services (krain and charon) before running dock-init. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where did you get these files from? why not just use/update the regular roles to install this? scared of something new |
||
| template: | ||
| src=upstart.conf | ||
| dest=~/{{ app_name }}.conf | ||
| backup=yes | ||
| vars: | ||
| - app_name: "krain" | ||
| - enviroment_vars: enviroment_vars | ||
|
|
||
| - name: encode krain config to base64 | ||
| shell: cat ~/{{ app_name }}.conf | base64 -w 0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are you encoding this for a reason? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So that we don't have to deal with weird formatting/spacing issues, since we're just adding this to a file to echo it into a file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are we echoing instead of copying it directly to host? does not look like you are transforming this file at all no transform just a decode? |
||
| register: krain_base64 | ||
| vars: | ||
| - app_name: "krain" | ||
|
|
||
| - name: load variables | ||
| include_vars: "group_vars/alpha-charon.yml" | ||
|
|
||
| - name: create new config file for charon | ||
| template: | ||
| src=upstart.conf | ||
| dest=~/{{ app_name }}.conf | ||
| backup=yes | ||
| vars: | ||
| - app_name: "charon" | ||
| - enviroment_vars: enviroment_vars | ||
|
|
||
| - name: encode krain config to base64 | ||
| shell: cat ~/{{ app_name }}.conf | base64 -w 0 | ||
| register: charon_base64 | ||
| vars: | ||
| - app_name: "charon" | ||
|
|
||
| - name: register tokens | ||
| set_fact: | ||
| vault_tokens: | ||
| - { file_name: 'auth-token', value: "{{ vault_auth_token }}" } | ||
| - { file_name: 'token-01', value: "{{ vault_token_01 }}" } | ||
| - { file_name: 'token-02', value: "{{ vault_token_02 }}" } | ||
| - { file_name: 'token-03', value: "{{ vault_token_03 }}" } | ||
|
|
||
| - name: encode ca.pem to base64 | ||
| shell: cat ./certs/ca.pem | base64 -w 0 | ||
| register: ca_pem_base64 | ||
|
|
||
| - name: encode ca-key.pem to base64 | ||
| shell: cat ./certs/ca-key.pem | base64 -w 0 | ||
| register: ca_key_pem_base64 | ||
|
|
||
| - name: encode pass to base64 | ||
| shell: cat ./certs/pass | base64 -w 0 | ||
| register: pass_base64 | ||
|
|
||
| - name: Generate dock script | ||
| template: | ||
| src=init.tmpl | ||
| dest=~/dock.sh | ||
| vars: | ||
| tokens: "{{ vault_tokens }}" | ||
| is_dock_pool: false | ||
|
|
||
| - name: Generate dock script | ||
| template: | ||
| src=init.tmpl | ||
| dest=~/dock-pool.sh | ||
| vars: | ||
| tokens: "{{ vault_tokens }}" | ||
| is_dock_pool: true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Set ENV files | ||
| export CONSUL_PORT={{ consul_https_port }} | ||
| export CONSUL_HOSTNAME={{ consul_host_address }} | ||
| export VAULT_PORT={{ vault_port }} | ||
|
|
||
| # Create directory for env | ||
| mkdir -p /opt/runnable/dock-init/consul-resources/vault/{{ node_env }} | ||
| chown ubuntu:ubuntu /opt/runnable/dock-init/consul-resources/vault/{{ node_env }} | ||
| chmod 0711 /opt/runnable/dock-init/consul-resources/vault/{{ node_env }} | ||
|
|
||
| # Set Vault Tokens (Used for fetching templates) | ||
| {% for item in tokens %} | ||
| echo {{ item.value }} > /opt/runnable/dock-init/consul-resources/vault/{{ node_env }}/{{ item.file_name }} | ||
| {% endfor %} | ||
|
|
||
| # Add upstart files for charon and krain | ||
| mkdir -p /docker/app-logs/ | ||
| echo {{ krain_base64['stdout'] }} | base64 --decode > /etc/init/krain.conf | ||
| echo {{ charon_base64['stdout'] }} | base64 --decode > /etc/init/charon.conf | ||
|
|
||
| # Add Certs (Used for genereting Docker client keys + certs) | ||
| mkdir -p /etc/ssl/docker/ | ||
| cho {{ ca_pem_base64['stdout'] }} | base64 --decode > /etc/ssl/docker/ca.pem | ||
| echo {{ ca_key_pem_base64['stdout'] }} | base64 --decode > /etc/ssl/docker/ca-key.pem | ||
| echo {{ pass_base64['stdout'] }} | base64 --decode > /etc/ssl/docker/pass | ||
| chmod -R 0440 /etc/ssl/docker/ | ||
|
|
||
| # Start services | ||
| {% if is_dock_pool %} | ||
| start amazon-ssm-agent | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not needed for dock (only for hot pool) |
||
| {% endif %} | ||
| service krain start | ||
| service charon start | ||
| {% if not is_dock_pool %} | ||
| CONSUL_HOSTNAME={{ consul_host_address }} CONSUL_PORT={{ consul_https_port }} VAULT_PORT={{ vault_port }} bash /opt/runnable/dock-init/init.sh | tee /var/log/user-script-dock-init.log | ||
| {% endif %} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| #!upstart | ||
| description "{{ app_name }}" | ||
| author "Anandkumar Patel" | ||
|
||
|
|
||
| env NPM_BIN=/usr/local/bin/npm | ||
| env APP_DIR=/opt/runnable/{{ app_name }} | ||
| env LOG_FILE={{ app_log_dir }}/{{ app_name }}.log | ||
| env NODE_ENV={{ node_env }} | ||
|
|
||
| {% if enviroment_vars is defined %} | ||
| {% for name, value in enviroment_vars.iteritems() %} | ||
| env {{ name }}={{ value }} | ||
| {% endfor %} | ||
| {% endif %} | ||
|
|
||
| start on (local-filesystems and net-device-up IFACE=eth0) | ||
| stop on shutdown | ||
|
|
||
| script | ||
| touch $LOG_FILE | ||
| chdir $APP_DIR | ||
| echo $$ > /var/run/{{ app_name }}.pid | ||
| exec $NPM_BIN start >> $LOG_FILE 2>&1 | ||
| end script | ||
|
|
||
| pre-start script | ||
| # Date format same as (new Date()).toISOString() for consistency | ||
| echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> $LOG_FILE | ||
| end script | ||
|
|
||
| pre-stop script | ||
| rm /var/run/{{ app_name }}.pid | ||
| echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> $LOG_FILE | ||
| end script | ||
|
|
||
| post-start script | ||
| echo "===== App restarted =====" >> $LOG_FILE | ||
| end script | ||
|
|
||
| respawn | ||
| respawn limit 5 1 # give up restart after 5 respawns in 1 seconds | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| msg: "application Installed: {{ app_name }}, branch : {{ git_branch }} " | ||
|
|
||
| - name: create repository dir | ||
| become: true | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. worst. we were trying to remove all the places we do this.... but if you have to that is fine There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forget why I had to this... but I feel there was a reason for it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea, because the /opts dir was made with sudo. its ok |
||
| file: | ||
| path=/opt/runnable/{{ app_name }} | ||
| state=directory | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might be bad, we will now inspect all hemindal containers, can you make this
runnable/image-builder? and test it works? also you can removeregistry.runnable.comUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.