Skip to content

Conversation

@thejsj
Copy link
Member

@thejsj thejsj commented Mar 13, 2017

What this PR does

  • Makes AMIs environment/customer agnostic (does not bake certs to AMI or any environment variables)
  • Create script to automatically generate launch configurations
  • Add new tags that don't need to be run when creating docks
  • Remove presumption that Rollbar key has to be present
  • Updates vault port to a variable.
  • Remove registrly.runnable.com for image-builder
  • Upgrades krain

Bugs/Things that need to be fixed

  • Docker needs to be run without TLS when pulling images because default docker (from service) does not have the necessary certs to run. You might need to manually deal start it.

How to create environment agnostic AMI

  1. Run base.yml with these flags.
ansible-playbook
  --vault-password-file /Users/hiphipjorge/.vaultpass
  --extra-vars "host=$DOCK_IP"
  --skip-tags=ensure_registry,loggly
  -e restart=true
  base.yml
  1. Run through mounting docker as you normally would. Because docker needs to be setup for the next step, you need to go into /etc/default/docker and remove TLS from it. In the future this should be done automatically.

  2. Run dock.yml with following arguments:

ansible-playbook 
  --vault-password-file /Users/hiphipjorge/.vaultpass
  --extra-vars "dock=$DOCK_IP"
  --skip-tags vault_files,consul_values,render_node_service_config,ensure_registry,loggly
  dock.yml
  1. Create launch configuration for environment:
ansible-playbook -i delta-hosts/ dock-generate-launch-config.yml

Tests

Create new AMI and launch configuration in gamma

  • Make sure there are no errors in /var/log/cloud-init-output.log
  • Make sure there are no errors in user-script-dock-init.log
  • Make sure Docker comes up docker ps
  • Make sure Krain comes up curl localhost:3100 -v and files show up
  • Make sure Charon is up (C2C works in environment)
  • Deploy docker-listener with changes to make sure it works

Create new AMI and launch configuration in hot grizzly

  • Make sure there are no errors in /var/log/cloud-init-output.log
  • Make sure there are no errors in user-script-dock-init.log
  • Make sure Docker comes up docker ps
  • Make sure Krain comes up curl localhost:3100 -v and files show up
  • Make sure Charon is up (C2C works in environment)
  • Deploy docker-listener with changes to make sure it works

Deployment (post-merge)

Ensure that all environments have the given changes.

  • deployed to gamma
  • deployed to delta

TODO for the future

  • Tag image builder with both runnable/image-builder and registry.runnable.com/runnable/image-buidler
  • Add mounting of /docker volume to script in order for everything to live in this script
  • Add base.yml to dock.yml in order to be able to build dock with one command
  • Handle installation of Loggly without keys (optional running)

@thejsj
Copy link
Member Author

thejsj commented Mar 13, 2017

Requires running command in following way:

ansible-playbook 
  --vault-password-file /Users/hiphipjorge/.vaultpass
  --extra-vars "dock=10.4.190.15" 
  --skip-tags vault_files,loggly,consul_values,render_node_service_config,ensure_registry
  dock.yml

@thejsj
Copy link
Member Author

thejsj commented Mar 13, 2017

Requires running base.yml the following way:

ansible-playbook
  --vault-password-file /Users/hiphipjorge/.vaultpass
  --extra-vars "host=10.4.172.205"
  --skip-tags=ensure_registry,loggly
  base.yml

@@ -0,0 +1,10 @@
---
- hosts: cream

Choose a reason for hiding this comment

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

should be localhost

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that the whole reason we're doing this is to have access to variables tied to an environment, but I don't know how to run this on localhost while getting the variables for another environment...

Choose a reason for hiding this comment

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

add localhost to [grizzly:children] in hosts file

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -0,0 +1,39 @@
---
- name: create new config file for krain

Choose a reason for hiding this comment

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

doesn't dock-init do this?

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Choose a reason for hiding this comment

The 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

- app_name: "krain"

- name: encode krain config to base64
shell: cat ~/{{ app_name }}.conf | base64 -w 0

Choose a reason for hiding this comment

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

are you encoding this for a reason?

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Choose a reason for hiding this comment

The 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

echo {{ krain_base64['stdout'] }} | base64 --decode >> /etc/init/krain.conf

no transform just a decode?

# Set ENV files
export CONSUL_PORT={{ consul_api_port }}
export CONSUL_HOSTNAME={{ ansible_default_ipv4.address }}
export VAULT_PORT=65240

Choose a reason for hiding this comment

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

should be {{ vault_port }}

echo {{ charon_base64['stdout'] }} | base64 --decode >> /etc/init/charon.conf
# Start services
start amazon-ssm-agent

Choose a reason for hiding this comment

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

not needed for dock (only for hot pool)

@@ -0,0 +1,10 @@
---
- hosts: cream

Choose a reason for hiding this comment

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

add localhost to [grizzly:children] in hosts file

insertafter: EOF
block: |
{{ registry_address }} registry.runnable.com
command: docker login -u {{ docker_hub_username }} -p {{ docker_hub_password }}

Choose a reason for hiding this comment

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

what is this too?

@@ -0,0 +1,39 @@
---
- name: create new config file for krain

Choose a reason for hiding this comment

The 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

- app_name: "krain"

- name: encode krain config to base64
shell: cat ~/{{ app_name }}.conf | base64 -w 0

Choose a reason for hiding this comment

The 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

echo {{ krain_base64['stdout'] }} | base64 --decode >> /etc/init/krain.conf

no transform just a decode?

command: sudo docker build --no-cache --tag="registry.runnable.com/{{ image_builder_docker_namespace }}:{{ git_branch }}" /opt/runnable/image-builder
command: sudo docker build --no-cache --tag="{{ image_builder_docker_namespace }}:{{ git_branch }}" /opt/runnable/image-builder

- name: push image-builder

Choose a reason for hiding this comment

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

delete we no longer need to do this

Copy link
Member Author

Choose a reason for hiding this comment

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

FYI, this requires a change in docker-listener for whitelisted image inspect list.

thejsj added 8 commits March 14, 2017 16:28
…ripts into create-shared-dock-ami

* 'create-shared-dock-ami' of github.com:CodeNow/devops-scripts:
  Remove psad from dock (#613)
  Added s3 log bucket to ansible
…e-shared-dock-ami

* 'master' of github.com:CodeNow/devops-scripts:
  Add aws host for API
  Moved cmd order
  Updated url
  Added clio port.
  Revert "Revert "Added clio http url env var""
  Revert "Added clio http url env var"
  Added clio http url env var
  Remove mongo certs to run pheidi
  Added deploy song
  Added new DB users in gamma/delta
  Updated to point clio to the same DB as everyone else :(
  Removed quotes
  Fixed host
  Added mongo hosts.
  Point to api's db
  Removed extra host
  Removed dep on mongo-clio
  Downgraded to node 4
  Add mongo-clio and clio to services.
@thejsj thejsj force-pushed the create-shared-dock-ami branch from e6f671f to 15fee45 Compare March 24, 2017 21:44
…e-shared-dock-ami

* 'master' of github.com:CodeNow/devops-scripts:
  add clio to worker and socket (#622)
  Remove khronos mongo certs (#621)
  remove redis tls (#620)
  split out delta-app to 2 boxes. remove unused configs (#619)
@thejsj thejsj force-pushed the create-shared-dock-ami branch from ce64411 to cbd2587 Compare March 24, 2017 22:12
-e DATADOG_HOST={{ datadog_host_address }}
-e DATADOG_PORT={{ datadog_port }}
-e DOCKER_CERT_PATH=/etc/ssl/docker
-e IMAGE_INSPECT_LIST=localhost,registry.runnable.com,runnable

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 remove registry.runnable.com

Copy link
Member Author

@thejsj thejsj Mar 25, 2017

Choose a reason for hiding this comment

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

Changed.

@@ -0,0 +1,41 @@
#!upstart
description "{{ app_name }}"
author "Anandkumar Patel"

Choose a reason for hiding this comment

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

you made this, I am not taking the blame for its bugs

Copy link
Member Author

Choose a reason for hiding this comment

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

haha No problem!

msg: "application Installed: {{ app_name }}, branch : {{ git_branch }} "

- name: create repository dir
become: true

Choose a reason for hiding this comment

The 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

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Choose a reason for hiding this comment

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

yea, because the /opts dir was made with sudo. its ok

@@ -1,6 +1,7 @@
---
- name: ensure registry.runnable in /etc/hosts

Choose a reason for hiding this comment

The 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

Choose a reason for hiding this comment

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

ok

@thejsj
Copy link
Member Author

thejsj commented Mar 25, 2017

Missing before merge:

  • Deploy docker-listener with changes to make sure it works

thejsj added 3 commits April 4, 2017 11:18
…e-shared-dock-ami

* 'master' of github.com:CodeNow/devops-scripts:
  Sorted
  Updated vars for deploy
become: true
command: docker pull {{ item }}
with_items:
- "registry.runnable.com/runnable/image-builder:v4.3.0"
Copy link
Member Author

Choose a reason for hiding this comment

The 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 image-builder into docker hub as a public image.

thejsj added 2 commits April 6, 2017 21:31
image-builder twice

Had a problem with starting up Docker and having it use the config with
the keys vs it not using it, so change the order for this in order for
the first part to use insecure docker for pulling images and then switch
to docker with certs + keys.
@thejsj thejsj merged commit bebf0e0 into master Apr 7, 2017
@thejsj thejsj deleted the create-shared-dock-ami branch April 7, 2017 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants