Skip to content

Commit

Permalink
Merge pull request #590 from Capgemini/573-traefik
Browse files Browse the repository at this point in the history
#573 - traefik - replacement for haproxy and registrator
  • Loading branch information
tayzlor committed Jan 5, 2016
2 parents 6116c46 + f7d77a2 commit 3e6af1f
Show file tree
Hide file tree
Showing 40 changed files with 214 additions and 397 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ tests/spec/*/*runtime_spec.rb
contrib-plugins/*
vault-security.yaml
terraform/*/.terraform
roles/coreos_bootstrap
roles/coreos_timezone
2 changes: 0 additions & 2 deletions group_vars/all
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
mesos_cluster_name: "Cluster01"
haproxy_username: "admin"
haproxy_password: "admin"
zookeeper_client_port: "2181"
zookeeper_server_group: zookeeper_servers
zookeeper_peers_nodes: "
Expand Down
7 changes: 0 additions & 7 deletions group_vars/mesos_slaves
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,3 @@ datadog_checks:
default_timeout: 10
instances:
- url: "http://{{ ansible_default_ipv4.address }}:5051"
haproxy:
init_config:
default_timeout: 10
instances:
- url: "http://{{ ansible_default_ipv4.address }}:9000/haproxy_stats"
username: "{{ haproxy_username }}"
password: "{{ haproxy_password }}"
13 changes: 3 additions & 10 deletions roles/consul/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
---
# handlers file for consul
# @todo - handle restarts properly (choose one approach here)
- name: restart consul
service:
name: consul
state: restarted
sudo: yes
notify:
- wait for consul to listen

- name: wait for consul to listen
wait_for:
host: "{{ consul_bind_addr }}"
port: 8500

- name: restart consul systemd
- name: restart consul
sudo: yes
command: systemctl restart consul
notify:
- wait for consul to listen
3 changes: 2 additions & 1 deletion roles/consul/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ galaxy_info:
#- packaging
- system
#- web
dependencies: []
dependencies:
- role: handlers
# List your role dependencies here, one per line. Only
# dependencies available via galaxy should be listed here.
# Be sure to remove the '[]' above if you add dependencies
Expand Down
19 changes: 19 additions & 0 deletions roles/consul/tasks/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,22 @@
- restart consul
tags:
- consul

- name: deploy consul service
sudo: yes
sudo_user: root
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
with_items:
- src: consul.service.j2
dest: /etc/systemd/system/consul.service
- src: dnsmasq.service.j2
dest: /etc/systemd/system/dnsmasq.service
- src: consul-discovery.service.j2
dest: /etc/systemd/system/consul-discovery.service
notify:
- reload systemd
- restart consul
tags:
- consul
25 changes: 8 additions & 17 deletions roles/consul/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
---
- include: config.yml

- name: deploy consul service
sudo: yes
sudo_user: root
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
with_items:
- src: consul.service.j2
dest: /etc/systemd/system/consul.service
- src: consul-discovery.service.j2
dest: /etc/systemd/system/consul-discovery.service
notify:
- restart consul systemd
tags:
- consul

- name: enable consul
sudo: yes
service:
name: consul
enabled: yes
state: started
notify:
- restart consul systemd
- restart consul
tags:
- consul

- name: enable dnsmasq
sudo: yes
service:
name: dnsmasq
enabled: yes
state: started

#- name: enable consul-discovery
# sudo: yes
# service:
Expand Down
9 changes: 9 additions & 0 deletions roles/consul/templates/consul.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
{% if inventory_hostname in groups[consul_servers_group] %}
"server": true,
"bootstrap_expect": {{ consul_bootstrap_expect }},
"dns_config": {
"allow_stale": false
},
{% else %}
"leave_on_terminate": true,
"dns_config": {
"allow_stale": true,
"max_stale": "1s"
},
{% endif %}
{% if consul_atlas_join|bool %}
"atlas_join": true,
Expand Down
5 changes: 1 addition & 4 deletions roles/consul/templates/consul.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ ExecStart=/usr/bin/bash -c "/usr/bin/docker run --rm --name consul \
-p 8302:8302/udp \
-p 8400:8400 \
-p 8500:8500 \
-p 53:8600/udp \
-p 8600:8600/udp \
{{ consul_image }}"

ExecStartPost=/usr/bin/bash -c 'sleep 1; echo -e "[Resolve]\nDNS=$(docker inspect --format \'{% raw %}{{ .NetworkSettings.IPAddress }}{% endraw %}\' consul)" > /etc/systemd/resolved.conf.d/00-consul-dns.conf && systemctl restart systemd-resolved'

ExecStop=/usr/bin/docker stop consul
ExecStopPost=/usr/bin/bash -c 'rm /etc/systemd/resolved.conf.d/00-consul-dns.conf && systemctl restart systemd-resolved'

[Install]
WantedBy=multi-user.target
31 changes: 31 additions & 0 deletions roles/consul/templates/dnsmasq.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[Unit]
Description=Dnsmasq
PartOf=consul.service
Requires=docker.service
After=consul.service
After=docker.service

[Service]
EnvironmentFile=/etc/environment
Restart=on-failure
ExecStartPre=/usr/bin/mkdir -p /etc/systemd/resolved.conf.d
ExecStartPre=-/bin/sh -c 'rm /etc/systemd/resolved.conf.d/00-consul-dns.conf && systemctl restart systemd-resolved'
ExecStartPre=-/usr/bin/docker kill dnsmasq
ExecStartPre=-/usr/bin/docker rm dnsmasq
ExecStartPre=/usr/bin/docker pull andyshinn/dnsmasq
ExecStart=/bin/sh -c '/usr/bin/docker run --rm \
--name dnsmasq \
--net=host \
--cap-add=NET_ADMIN \
--env SERVICE_IGNORE=true \
andyshinn/dnsmasq -S /consul/${COREOS_PRIVATE_IPV4}#8600'

ExecStartPost=/bin/sh -c '\
echo -e "[Resolve]\nDNS=${COREOS_PRIVATE_IPV4}" > /etc/systemd/resolved.conf.d/00-consul-dns.conf && \
systemctl restart systemd-resolved;'

ExecStop=/usr/bin/docker stop dnsmasq
ExecStopPost=/bin/sh -c 'rm /etc/systemd/resolved.conf.d/00-consul-dns.conf && systemctl restart systemd-resolved'

[Install]
WantedBy=multi-user.target
4 changes: 4 additions & 0 deletions roles/handlers/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
- name: reload systemd
sudo: yes
command: systemctl daemon-reload

- name: restart consul
service:
name: consul
Expand Down
1 change: 0 additions & 1 deletion roles/haproxy/README.md

This file was deleted.

16 changes: 0 additions & 16 deletions roles/haproxy/defaults/main.yml

This file was deleted.

5 changes: 0 additions & 5 deletions roles/haproxy/files/haproxy.cfg

This file was deleted.

2 changes: 0 additions & 2 deletions roles/haproxy/handlers/main.yml

This file was deleted.

65 changes: 0 additions & 65 deletions roles/haproxy/tasks/main.yml

This file was deleted.

2 changes: 0 additions & 2 deletions roles/haproxy/templates/consul.cfg.j2

This file was deleted.

47 changes: 0 additions & 47 deletions roles/haproxy/templates/haproxy.tmpl.j2

This file was deleted.

2 changes: 0 additions & 2 deletions roles/haproxy/vars/main.yml

This file was deleted.

2 changes: 1 addition & 1 deletion roles/marathon/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ marathon_rebuild_container: False
marathon_image: "mesosphere/marathon:v{{ marathon_version }}"
marathon_master_peers: "zk://{{ zookeeper_peers_nodes }}/mesos"
marathon_zk_peers: "zk://{{ zookeeper_peers_nodes }}/marathon"
marathon_command: "--artifact_store {{ marathon_artifact_store }} --hostname {{ marathon_hostname }} --master {{ marathon_master_peers }} --zk {{ marathon_zk_peers }}"
marathon_command: "--event_subscriber http_callback --artifact_store {{ marathon_artifact_store }} --hostname {{ marathon_hostname }} --master {{ marathon_master_peers }} --zk {{ marathon_zk_peers }}"
16 changes: 9 additions & 7 deletions roles/marathon/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@
tags:
- marathon

#- name: Set marathon consul service definition
# sudo: yes
# template:
# src: marathon-consul.j2
# dest: "{{ marathon_consul_dir }}/marathon.json"
# notify:
# - restart consul
- name: Set marathon consul service definition
sudo: yes
template:
src: marathon-consul.j2
dest: "{{ marathon_consul_dir }}/marathon.json"
notify:
- restart consul
tags:
- marathon
2 changes: 1 addition & 1 deletion roles/mesos/tasks/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
sudo_user: root
template:
src: mesos-master.service.j2
dest: "/etc/systemd/system/mesos-master.service"
dest: /etc/systemd/system/mesos-master.service
notify:
- restart mesos master
tags:
Expand Down
2 changes: 1 addition & 1 deletion roles/mesos/tasks/slave.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
sudo_user: root
template:
src: mesos-slave.service.j2
dest: "/etc/systemd/system/mesos-slave.service"
dest: /etc/systemd/system/mesos-slave.service
notify:
- restart mesos slave
tags:
Expand Down
6 changes: 0 additions & 6 deletions roles/registrator/defaults/main.yml

This file was deleted.

1 change: 0 additions & 1 deletion roles/registrator/handlers/main.yml

This file was deleted.

Loading

0 comments on commit 3e6af1f

Please sign in to comment.