Skip to content

create dock with ansible #264

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

Merged
merged 36 commits into from
Jan 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2ef1ea0
fixing stage configs init
Dec 24, 2015
a2ad5ea
set consul host for stage, log vault to docker logs
Dec 24, 2015
3ad9515
new vault secrets
Dec 24, 2015
c1de426
add docker-init role, add git_repo, move vault vars
Dec 26, 2015
f303efb
fix repo pull include
Dec 26, 2015
0768379
split out git repo from git service, remove dock file
Dec 26, 2015
e85414f
add node_service
Dec 26, 2015
7f8a073
remove unused env's
Dec 26, 2015
839affa
fix up configs
Dec 26, 2015
10b5ec1
remove ip tables, add config file back
Dec 26, 2015
637815e
add docker install for dock
Dec 26, 2015
2660a6b
add docker config for docks
Dec 28, 2015
bd90cf9
Merge branch 'master' into fix-stage-configs
Dec 29, 2015
cb3540e
merge with master
Jan 12, 2016
27f4563
add connection local
Jan 12, 2016
bb892f0
remove datadog and sauron
Jan 12, 2016
48ad0a5
Added cert for docker
kaushikanurag Jan 13, 2016
c1ddadd
added aws ec2-metadata and ec2-api-tool
kaushikanurag Jan 15, 2016
455673a
changed aws-package to dock-init meta
kaushikanurag Jan 15, 2016
2a0101f
Modified AWS Package
kaushikanurag Jan 15, 2016
630ed8e
add logic to remove certificate and other security related stuff
kaushikanurag Jan 19, 2016
3bdb751
merge with master
Jan 20, 2016
f502c7e
change for AWS packages
kaushikanurag Jan 21, 2016
413275c
unzip error
kaushikanurag Jan 21, 2016
31aefa8
comment all task in aws package
kaushikanurag Jan 21, 2016
d0377bc
added datadog to dock-init.yml
kaushikanurag Jan 22, 2016
e9488f0
added package, cert for dock ami
kaushikanurag Jan 25, 2016
3ac4955
added get-url and unzip
kaushikanurag Jan 25, 2016
afbb314
add unzip for api tool
kaushikanurag Jan 26, 2016
e176e6e
Update to latest branch and move ec2-api-toool to ec2
kaushikanurag Jan 26, 2016
b522846
correct typo
kaushikanurag Jan 26, 2016
7046c06
changes to rollbar token from file to variable
kaushikanurag Jan 26, 2016
6d59caa
changes to fix errors
kaushikanurag Jan 26, 2016
60cf613
Delete.
Jan 26, 2016
98c6811
move datadog above git_repo
kaushikanurag Jan 26, 2016
41a6233
Merge branch 'fix-stage-configs' of github.com:CodeNow/devops-scripts…
kaushikanurag Jan 26, 2016
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
5 changes: 3 additions & 2 deletions ansible/charon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
- hosts: redis
- hosts: consul

- hosts: docks
- hosts: "{{ dock | default('docks') }}"
vars_files:
- group_vars/alpha-charon.yml
roles:
- { role: notify, tags: [notify] }
- { role: git_node_service, tags: [deploy] }
- { role: git_repo, tags: [deploy] }
- { role: node_service, tags: [deploy] }
- { role: loggly-rotate }
- { role: consul_value, tags: [deploy, consul_value] }
3 changes: 3 additions & 0 deletions ansible/delta-hosts/hosts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ delta-api-worker

[docks]

[dock]

[eru]
delta-services

Expand Down Expand Up @@ -113,6 +115,7 @@ sauron
shiva
metis
swarm-manager
dock

[local]
127.0.0.1
Expand Down
12 changes: 8 additions & 4 deletions ansible/delta-hosts/variables
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ api_s3_context_bucket=runnable.context.resources.production

[docks:vars]
docker_config=docks
docks_rollbar_key=d1af6567ed0f464fb1d676f38fd31751

[dock:vars]
docks_rollbar_key=d1af6567ed0f464fb1d676f38fd31751

[eru:vars]
eru_github_id=46a23f5f99f0aa9460f8
Expand Down Expand Up @@ -48,10 +52,6 @@ aws_secret_access_key=GrOO85hfoc7+bwT2GjoWbLyzyNbOKb2/XOJbCJsv
shiva_rollbar_key=0526a90faec845d796e1ef5361a00526

[vault:vars]
vault_auth_token=578c9767-5af8-8490-0954-5d330f27b088
vault_token_01=0d324dc7d4cbd94790fd08809d06fb1e28e21e185910081c7646e3e49924f6ed01
vault_token_02=42dc8a69df174e77eb47a63b6ef4709bec57101cb1bff11a71c91b73b8bc046102
vault_token_03=47f3cb74f5374fa3c51c90fd25e3d4cc851034de97584995fce5fc5382342f1f03
vault_hello_runnable_github_token=88ddc423c2312d02a8bbcaad76dd4c374a30e4af
vault_aws_access_key_id=AKIAJ7R4UIM45KH2WGWQ
vault_aws_secret_key=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
Expand All @@ -74,6 +74,10 @@ rabbit_password=wKK7g7NWKpQXEeSzyWB7mIpxZIL8H2mDSf3Q6czR3Vk
rabbit_username=o2mdLh9N9Ke2GzhoK8xsruYPhIQFN7iEL44dQJoq7OM
registry_host=10.8.4.126
user_content_domain=runnableapp.com
vault_auth_token=578c9767-5af8-8490-0954-5d330f27b088
vault_token_01=0d324dc7d4cbd94790fd08809d06fb1e28e21e185910081c7646e3e49924f6ed01
vault_token_02=42dc8a69df174e77eb47a63b6ef4709bec57101cb1bff11a71c91b73b8bc046102
vault_token_03=47f3cb74f5374fa3c51c90fd25e3d4cc851034de97584995fce5fc5382342f1f03

[ec2:vars]
aws_custid=437258487404
Expand Down
8 changes: 8 additions & 0 deletions ansible/dock-init.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
---
- hosts: consul

- hosts: "{{ dock }}"
vars_files:
- group_vars/alpha-dock-init.yml
roles:
- { role: notify, tags: [notify] }
- { role: package-dock, tags: [dock, package] }
- { role: package-aws, tags: [dock, package] }
- { role: docker, tags: [docker] }
- { role: datadog, tags: [deploy, datadog] }
- { role: git_repo, tags: [deploy] }
- { role: dock-init, tags: [deploy] }
- { role: consul_value, tags: [deploy, consul_value] }
16 changes: 16 additions & 0 deletions ansible/dock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- hosts: localhost
connection: local
tasks:
- fail: msg="`dock` (target dock) needs to be defined to run this role"
when: dock is not defined
- add_host:
name={{ dock }}
groups=dock

- include: dock-init.yml git_branch=v6.0.0
- include: krain.yml git_branch=v0.1.1
- include: filibuster.yml git_branch=v0.1.7
- include: charon.yml git_branch=v3.2.0
- include: image-builder.yml git_branch=v4.0.1
- include: docker-listener.yml git_branch=v4.3.0
5 changes: 3 additions & 2 deletions ansible/docker-listener.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
- hosts: redis
- hosts: consul

- hosts: docks
- hosts: "{{ dock | default('docks') }}"
vars_files:
- group_vars/alpha-docker-listener.yml
roles:
- { role: notify, tags: [notify] }
- { role: build_essential }
- { role: docker_client }
- { role: git_node_service, tags: [deploy] }
- { role: git_repo, tags: [deploy] }
- { role: node_service, tags: [deploy] }
- { role: loggly-rotate }
- { role: consul_value, tags: [deploy, consul_value] }
19 changes: 0 additions & 19 deletions ansible/docks.yml

This file was deleted.

5 changes: 3 additions & 2 deletions ansible/filibuster.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
- hosts: consul

- hosts: docks
- hosts: "{{ dock | default('docks') }}"
vars_files:
- group_vars/alpha-filibuster.yml
roles:
- { role: notify, tags: [notify] }
- { role: git_node_service, tags: [deploy] }
- { role: git_repo, tags: [deploy] }
- { role: node_service, tags: [deploy] }
- { role: loggly-rotate }
- { role: consul_value, tags: [deploy, consul_value] }
23 changes: 14 additions & 9 deletions ansible/gamma-hosts/hosts
Original file line number Diff line number Diff line change
Expand Up @@ -90,28 +90,33 @@ gamma-services

[docks]

[dock]

[gamma:children]
api
bastion
charon
dock
docks
eru
hipache
khronos
mavis
mongodb
navi
neo4j
optimus
rabbitmq
api
worker
web
redis
redis-slave
docks
registry
neo4j
navi
charon
khronos
mavis
optimus
rabbitmq
eru
sauron
shiva
swarm-manager
web
metis

[ec2]
Expand Down
10 changes: 6 additions & 4 deletions ansible/gamma-hosts/variables
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ api_s3_context_bucket=runnable.context.resources.production-beta

[docks:vars]
docker_config=docks
docks_rollbar_key=d1af6567ed0f464fb1d676f38fd31751

[eru:vars]
eru_github_id=8abb08f83f6d1c52bd1a
Expand Down Expand Up @@ -48,10 +49,6 @@ aws_secret_access_key=GrOO85hfoc7+bwT2GjoWbLyzyNbOKb2/XOJbCJsv
shiva_rollbar_key=0526a90faec845d796e1ef5361a00526

[vault:vars]
vault_auth_token=e22c3ebc-11cf-653b-7df0-79d78a499458
vault_token_01=71d7b4754686013c8b9cfb22bafae79c661849dcd67c483c89efba12c0466aa201
vault_token_02=794d6f7a3459c332a1fd2bbcc9230a7f84f1639806039ee8be547828cd7ab03a02
vault_token_03=2e67faeffe4343c038d0f3210bdb83f3d3a5bc468975cf13e977ce9b5922aefe03
vault_hello_runnable_github_token=88ddc423c2312d02a8bbcaad76dd4c374a30e4af
vault_aws_access_key_id=AKIAJ7R4UIM45KH2WGWQ
vault_aws_secret_key=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
Expand All @@ -74,6 +71,11 @@ registry_host=10.4.4.82
swarm_token=d363b783f03a845a2c82b081bfe8443e
user_content_domain=runnable.ninja
api_hello_runnable_github_token=88ddc423c2312d02a8bbcaad76dd4c374a30e4af
no_dd_monitoring=false
vault_auth_token=e22c3ebc-11cf-653b-7df0-79d78a499458
vault_token_01=71d7b4754686013c8b9cfb22bafae79c661849dcd67c483c89efba12c0466aa201
vault_token_02=794d6f7a3459c332a1fd2bbcc9230a7f84f1639806039ee8be547828cd7ab03a02
vault_token_03=2e67faeffe4343c038d0f3210bdb83f3d3a5bc468975cf13e977ce9b5922aefe03

[ec2:vars]
env=gamma
Expand Down
4 changes: 4 additions & 0 deletions ansible/group_vars/alpha-dock-init.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: dock-init
app_name: "{{ name }}"
app_repo: git@github.com:CodeNow/{{ name }}.git

# for docker role
docker_config: dock

# consul values
consul_values:
Expand Down
2 changes: 0 additions & 2 deletions ansible/group_vars/alpha-docker-listener.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ enviroment_vars:
RABBITMQ_PASSWORD: "{{ rabbit_password }}"
RABBITMQ_PORT: "{{ rabbit_port }}"
RABBITMQ_USERNAME: "{{ rabbit_username }}"
REDIS_IPADDRESS: "{{ redis_host_address }}"
REDIS_PORT: "{{ redis_port }}"

# consul values
consul_values:
Expand Down
3 changes: 2 additions & 1 deletion ansible/group_vars/alpha-vault.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ db_path: /opt/runnable/vault
container_image: runnable/vault
container_tag: v0.3.1

log_driver: json-file

container_run_opts: >
-d
-h {{ inventory_hostname }}
Expand All @@ -19,7 +21,6 @@ container_run_args: >
vault server
-log-level=warn
-config=/vault.hcl
> /var/log/vault.log 2>&1

# vault seed data
# pulled 2015/16/12 - Bryan
Expand Down
2 changes: 1 addition & 1 deletion ansible/image-builder.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- hosts: consul

- hosts: docks
- hosts: "{{ dock | default('docks') }}"
vars_files:
- group_vars/alpha-image-builder.yml
roles:
Expand Down
5 changes: 3 additions & 2 deletions ansible/krain.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
- hosts: consul

- hosts: docks
- hosts: "{{ dock | default('docks') }}"
vars_files:
- group_vars/alpha-krain.yml
roles:
- { role: notify, tags: [notify] }
- { role: build_essential }
- { role: git_node_service, tags: [deploy] }
- { role: git_repo, tags: [deploy] }
- { role: node_service, tags: [deploy] }
- { role: loggly-rotate }
- { role: consul_value, tags: [deploy, consul_value] }
1 change: 1 addition & 0 deletions ansible/roles/base_ubuntu/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
- name: ensure registry.runnable in /etc/hosts
sudo: yes
when: dock is not defined
lineinfile:
dest=/etc/hosts
line="{{ registry_host }} registry.runnable.com"
Expand Down
25 changes: 25 additions & 0 deletions ansible/roles/dock-init/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- fail: msg="value tokens need to be defined for this role"
when: vault_auth_token is not defined or vault_token_01 is not defined or vault_token_02 is not defined or vault_token_03 is not defined

- name: copy vault auth files
tags: vault_files
lineinfile:
dest="/opt/runnable/dock-init/consul-resources/vault/{{ node_env }}/{{ item.file_name }}"
line="{{ item.value }}"
create=yes
with_items:
- { 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 }}" }

- fail: msg="value tokens need to be defined for this role"
when: docks_rollbar_key is not defined

- name: copy rollbar token
tags: rollbar
Copy link
Author

Choose a reason for hiding this comment

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

why not make this lineinfile line above? that way we can maintain just variables, not the files

Copy link
Author

Choose a reason for hiding this comment

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

ping

Copy link
Contributor

Choose a reason for hiding this comment

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

variable are les secured than file. We can put files in vault. So we don't to put the variables file in vault. The whole purpose of vault is security, if we give the things that secure in form of variable. Is it secure?
If you still think that the way you me to code, I have no problem

lineinfile:
dest="/opt/runnable/dock-init/key/rollbar.token"
line="{{ docks_rollbar_key }}"
create=yes
2 changes: 1 addition & 1 deletion ansible/roles/docker/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
docker_package_name: lxc-docker-1.6.2
docker_package_name: docker-engine=1.9.1-0~trusty
22 changes: 18 additions & 4 deletions ansible/roles/docker/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
---
- name: create docker cert directory
sudo: yes
file:
path=/etc/ssl/docker
state=directory

- name: copy docker certs
sudo: yes
copy:
src=certs/
dest=/etc/ssl/docker
mode=0440
owner=root
group=root

- name: change core dump path
sudo: yes
when: docker_config == "runnable"
Expand Down Expand Up @@ -36,13 +51,12 @@
- name: add docker repository
sudo: yes
apt_repository:
repo: "deb https://get.docker.com/ubuntu docker main"
repo: "deb https://apt.dockerproject.org/repo ubuntu-{{ ansible_distribution_release }} main"
state: present
update_cache: yes

- name: copy docker config file
sudo: yes
when: docker_config == "runnable"
template:
src={{ docker_config }}
dest=/etc/default/docker
Expand All @@ -51,7 +65,7 @@

- name: install docker
sudo: yes
when: restart is defined
when: restart is defined or dock is defined
apt:
pkg="{{ docker_package_name }}"
state=present
Expand All @@ -60,5 +74,5 @@
cache_valid_time=604800

- name: restart docker
when: copied_config.changed and restart is defined
when: (copied_config.changed and restart is defined) or dock is defined
command: sudo service docker restart
6 changes: 6 additions & 0 deletions ansible/roles/docker/templates/dock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DOCKER_OPTS="-H=unix:///var/run/docker.sock -H=0.0.0.0:4242"
DOCKER_OPTS="$DOCKER_OPTS --tlsverify --tlscacert=/etc/ssl/docker/ca.pem"
DOCKER_OPTS="$DOCKER_OPTS --tlscert=/etc/ssl/docker/cert.pem --tlskey=/etc/ssl/docker/key.pem"
DOCKER_OPTS="$DOCKER_OPTS -g /docker --insecure-registry registry.runnable.com --icc=false"
DOCKER_OPTS="$DOCKER_OPTS --bip 172.17.42.1/16"
DOCKER_OPTS="$DOCKER_OPTS --dns=172.17.42.1 --dns=8.8.8.8"
Loading