-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ludovicc/master
Install Chronos from official distribution channel
- Loading branch information
Showing
15 changed files
with
292 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
chronos_version: 2.4.0 | ||
chronos_package_version: 0.1.20150828104228 | ||
|
||
# # == chronos conf == | ||
mesos_zk_chroot: "mesos" | ||
chronos_zk_auth: "" | ||
chronos_zk_dns: "{{ inventory_hostname }}" | ||
chronos_zk_port: 2181 | ||
chronos_zk_chroot: chronos | ||
chronos_zk_connect: "zk://{{ chronos_zk_dns }}:{{ chronos_zk_port }}/{{chronos_zk_chroot}}" | ||
|
||
chronos_zk_mesos_master: "zk://{{ chronos_zk_dns }}:{{ chronos_zk_port }}/{{ mesos_zk_chroot }}" | ||
|
||
chronos_hostname: "{{ inventory_hostname }}" | ||
chronos_port: 4400 | ||
|
||
# TODO chronos_env_java_opts: "-Xmx512m" | ||
|
||
haproxy_script_location: "/usr/local/bin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#!/bin/bash | ||
set -o errexit -o nounset -o pipefail | ||
function -h { | ||
cat <<\USAGE | ||
USAGE: haproxy_cfg <chronos host:port> | ||
haproxy_cfg generates a config file to run HAProxy on localhost and proxy to a number of backend hosts. | ||
To gracefully reload haproxy: | ||
:; haproxy -f /path/to/config -p /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid) | ||
USAGE | ||
}; function --help { -h ;} | ||
export LC_ALL=en_US.UTF-8 | ||
|
||
function header { | ||
cat <<EOF | ||
global | ||
daemon | ||
log 127.0.0.1 local0 | ||
log 127.0.0.1 local1 notice | ||
maxconn 4096 | ||
user haproxy | ||
group haproxy | ||
defaults | ||
log global | ||
retries 3 | ||
maxconn 2000 | ||
contimeout 5000 | ||
clitimeout 50000 | ||
srvtimeout 50000 | ||
stats enable | ||
stats auth admin:admin | ||
stats uri /haproxy | ||
EOF | ||
} | ||
|
||
function marathon_apps { | ||
z="`curl -H "Accept: text/plain" -s "$1/v2/tasks"`" | ||
|
||
frontend "$z" | ||
backend "$z" | ||
} | ||
|
||
function frontend { | ||
cat <<EOF | ||
frontend http-in | ||
bind *:80 | ||
mode http | ||
option httplog | ||
option dontlognull | ||
option forwardfor | ||
option http-server-close | ||
EOF | ||
|
||
while IFS= read | ||
do | ||
set -- $REPLY | ||
local name="$1" | ||
cat <<EOF | ||
acl host_${name} hdr_beg(host) -i ${name} | ||
use_backend ${name}_cluster if host_${name} | ||
EOF | ||
done <<< "$1" | ||
} | ||
|
||
function backend { | ||
while IFS= read | ||
do | ||
set -- $REPLY | ||
local name="$1" | ||
local port="$2" | ||
shift 2 | ||
cat <<EOF | ||
backend ${name}_cluster | ||
option httpclose | ||
option forwardfor | ||
mode http | ||
balance leastconn | ||
EOF | ||
while [[ $# -gt 0 ]] | ||
do | ||
out " server ${name}-$# $1 check" | ||
shift | ||
done | ||
done <<< "$1" | ||
} | ||
|
||
function config { | ||
header | ||
marathon_apps "$@" | ||
} | ||
|
||
function main { | ||
config "$@" | ||
} | ||
|
||
function msg { out "$*" >&2 ;} | ||
function err { local x=$? ; msg "$*" ; return $(( $x == 0 ? 1 : $x )) ;} | ||
function out { printf '%s\n' "$*" ;} | ||
|
||
if [[ ${1:-} ]] && declare -F | cut -d' ' -f3 | fgrep -qx -- "${1:-}" | ||
then "$@" | ||
else main "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
--- | ||
- name: Create Chronos default conf file | ||
template: src=chronos_conf.j2 dest=/etc/default/chronos | ||
owner="root" group="root" mode=0664 | ||
- name: Add apt-key | ||
apt_key: id=E56151BF keyserver=keyserver.ubuntu.com state=present | ||
|
||
- name: Create Chronos default init file | ||
template: src=chronos.j2 dest=/etc/init/chronos.conf | ||
owner="root" group="root" mode=0664 | ||
- name: Add Mesosphere repo | ||
apt_repository: | ||
repo: "{{ chronos_apt_repo }}" | ||
state: present | ||
|
||
- name: Install Chronos package | ||
apt: | ||
pkg: chronos={{chronos_version}}-{{chronos_package_version}}.{{ansible_distribution|lower}}{{ansible_distribution_version.split('.')|join('')}} | ||
state: present | ||
update_cache: yes | ||
cache_valid_time: 600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
- name: Add mesosphere repo | ||
yum: name={{ mesosphere_repo }} state=present | ||
|
||
- name: Install Chronos | ||
yum: name=chronos-{{chronos_version}} state=present |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
--- | ||
|
||
#- name: wait for zookeeper to listen | ||
# command: "/usr/local/bin/zookeeper-wait-for-listen.sh {{ inventory_hostname }}" | ||
# | ||
#- name: create zookeeper acl | ||
# sudo: yes | ||
# command: "{{ chronos_zk_acl_cmd }}" | ||
# notify: | ||
# - restart chronos | ||
# when: zk_chronos_user_secret is defined | ||
# run_once: true | ||
# tags: | ||
# - chronos | ||
|
||
- name: create chronos conf directory | ||
sudo: yes | ||
file: | ||
dest: /etc/chronos/conf | ||
state: directory | ||
tags: | ||
- chronos | ||
|
||
- name: systemd check | ||
stat: path=/usr/lib/systemd/system/ | ||
register: systemd_check | ||
|
||
- name: configure chronos unit file | ||
sudo: yes | ||
replace: | ||
dest: /usr/lib/systemd/system/chronos.service | ||
regexp: "=network.target" | ||
replace: '=mesos-master.service' | ||
when: systemd_check.stat.exists == true | ||
notify: | ||
- reload chronos | ||
- restart chronos | ||
tags: | ||
- chronos | ||
|
||
- name: configure chronos to wait for zookeeper before starting | ||
sudo: yes | ||
lineinfile: | ||
dest: /usr/lib/systemd/system/chronos.service | ||
line: "ExecStartPre=/usr/local/bin/zookeeper-wait-for-listen.sh {{ chronos_zk_dns }}" | ||
insertbefore: "^ExecStart=" | ||
state: present | ||
when: systemd_check.stat.exists == true | ||
notify: | ||
- reload chronos | ||
- restart chronos | ||
tags: | ||
- chronos | ||
|
||
# TODO: feels like a hack | ||
- name: fix chronos bin file | ||
sudo: yes | ||
replace: | ||
dest: /usr/bin/chronos | ||
regexp: '\[\[ -s /etc/mesos/zk \]\]' | ||
replace: 'false' | ||
notify: | ||
- restart chronos | ||
tags: | ||
- chronos | ||
|
||
- name: set key/value options | ||
sudo: yes | ||
when: item.value != "" | ||
copy: | ||
dest: /etc/chronos/conf/{{ item.key }} | ||
content: "{{ item.value }}" | ||
with_items: | ||
- key: zk_hosts | ||
value: "{{ chronos_zk_connect }}" | ||
- key: master | ||
value: "{{ chronos_zk_mesos_master }}" | ||
- key: hostname | ||
value: "{{ chronos_hostname }}" | ||
- key: http_port | ||
value: "{{ chronos_port }}" | ||
#- key: mem_opts | ||
# value: "{{ chronos_env_java_opts }}" | ||
- key: mesos_framework_name | ||
value: "chronos" | ||
notify: | ||
- restart chronos | ||
tags: | ||
- chronos | ||
|
||
- name: enable and start chronos | ||
sudo: yes | ||
service: | ||
enabled: yes | ||
name: chronos | ||
state: started | ||
tags: | ||
- chronos | ||
|
||
- meta: flush_handlers |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
- name: Check HAProxy | ||
stat: path=/etc/haproxy | ||
register: haproxy_dir | ||
|
||
- name: Setup HAProxy script | ||
copy: src=haproxy_dns_cfg dest="{{ haproxy_script_location }}/haproxy_dns_cfg" mode=755 | ||
when: haproxy_dir.stat.exists | ||
|
||
- name: Create HAProxy reload script | ||
template: src=haproxy_reload.j2 dest={{ haproxy_script_location }}/haproxy_reload | ||
owner="root" group="root" mode=0744 | ||
when: haproxy_dir.stat.exists | ||
|
||
- name: Setup cron job for HAProxy | ||
cron: name="reload chronos haproxy" minute="*/1" job="{{ haproxy_script_location }}/haproxy_reload" | ||
when: haproxy_dir.stat.exists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
--- | ||
- include: common.yml | ||
- include_vars: "{{ ansible_os_family }}.yml" | ||
|
||
- include: Debian.yml | ||
when: ansible_os_family == "Debian" | ||
|
||
- include: deploy.yml | ||
- include: RedHat.yml | ||
when: ansible_os_family == "RedHat" | ||
|
||
- include: conf.yml | ||
|
||
- include: haproxy.yml | ||
when: haproxy_script_location != "" | ||
|
||
- name: Delete old slave info to ensure clean startup of Chronos after an upgrade | ||
file: path=/tmp/mesos/meta/slaves/latest state=absent | ||
|
||
- name: Start Chronos service | ||
service: name=chronos state=restarted enabled=yes |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
chronos_apt_repo: "deb http://repos.mesosphere.io/{{ansible_distribution|lower}} {{ansible_distribution_release|lower}} main" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
os_version: "{{ ansible_lsb.release if ansible_lsb is defined else ansible_distribution_version }}" | ||
os_version_major: "{{ os_version | regex_replace('^([0-9]+)[^0-9]*.*', '\\\\1') }}" | ||
|
||
mesosphere_releases: | ||
'6': 'mesosphere-el-repo-6-3.noarch.rpm' | ||
'7': 'mesosphere-el-repo-7-1.noarch.rpm' | ||
|
||
mesosphere_repo: "http://repos.mesosphere.com/el/{{ os_version_major }}/noarch/RPMS/{{ mesosphere_releases[os_version_major] }}" | ||
|
Oops, something went wrong.