Updated consul formula from upstream, added bin_dir for configurable install
This commit is contained in:
parent
c0b672206e
commit
cc56227f4e
13 changed files with 60 additions and 24 deletions
|
@ -12,6 +12,7 @@ consul-template-tmpl-file-{{ loop.index }}:
|
||||||
file.managed:
|
file.managed:
|
||||||
- source: {{ tmpl.source }}
|
- source: {{ tmpl.source }}
|
||||||
- name: /etc/consul-template/tmpl-source/{{ tmpl.name }}.ctmpl
|
- name: /etc/consul-template/tmpl-source/{{ tmpl.name }}.ctmpl
|
||||||
|
- template: {{ tmpl.template_engine }}
|
||||||
|
|
||||||
consul-template.d-tmpl-{{ loop.index }}:
|
consul-template.d-tmpl-{{ loop.index }}:
|
||||||
file.serialize:
|
file.serialize:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
consul_template:
|
consul_template:
|
||||||
version: 0.14.0
|
version: 0.20.0
|
||||||
hash: 7c70ea5f230a70c809333e75fdcff2f6f1e838f29cfb872e1420a63cdf7f3a78
|
hash: 500fe023c89517f959175eb79e21c33df0acf7733d3f3681ec8c5238863caf86
|
||||||
|
|
||||||
service: false
|
service: false
|
||||||
config:
|
config:
|
||||||
|
@ -9,6 +9,7 @@ consul_template:
|
||||||
tmpl:
|
tmpl:
|
||||||
- name: example
|
- name: example
|
||||||
source: salt://consul-template/files/example.ctmpl
|
source: salt://consul-template/files/example.ctmpl
|
||||||
|
template_engine: null # None in Python
|
||||||
config:
|
config:
|
||||||
template:
|
template:
|
||||||
source: /etc/consul-template/tmpl-source/example.ctmpl
|
source: /etc/consul-template/tmpl-source/example.ctmpl
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=consul-template
|
Description=consul-template
|
||||||
Wants=network.target
|
Documentation=https://github.com/hashicorp/consul-template
|
||||||
After=network.target
|
Wants=network-online.target
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Environment="GOMAXPROCS=2" "PATH=/usr/local/bin:/usr/bin:/bin"
|
Environment="GOMAXPROCS=2" "PATH=/usr/local/bin:/usr/bin:/bin"
|
||||||
ExecStart=/usr/local/bin/consul-template -config /etc/consul-template.d
|
ExecStart=/usr/local/bin/consul-template -config /etc/consul-template.d
|
||||||
ExecReload=/bin/kill -HUP $MAINPID
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
KillSignal=TERM
|
KillMode=process
|
||||||
|
KillSignal=SIGTERM
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=42s
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
@ -20,6 +20,7 @@ consul-template-init-script:
|
||||||
consul-template-service:
|
consul-template-service:
|
||||||
service.running:
|
service.running:
|
||||||
- name: consul-template
|
- name: consul-template
|
||||||
|
- enable: True
|
||||||
- watch:
|
- watch:
|
||||||
- file: /etc/consul-template.d/*
|
- file: /etc/consul-template.d/*
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
consul-config:
|
consul-config:
|
||||||
file.serialize:
|
file.serialize:
|
||||||
- name: /etc/consul.d/config.json
|
- name: /etc/consul.d/config.json
|
||||||
|
- encoding: utf-8
|
||||||
- formatter: json
|
- formatter: json
|
||||||
- dataset: {{ consul.config }}
|
- dataset: {{ consul.config | json }}
|
||||||
- user: {{ consul.user }}
|
- user: {{ consul.user }}
|
||||||
- group: {{ consul.group }}
|
- group: {{ consul.group }}
|
||||||
- mode: 0640
|
- mode: 0640
|
||||||
|
@ -40,4 +41,4 @@ consul-script-config:
|
||||||
- user: consul-user
|
- user: consul-user
|
||||||
- formatter: json
|
- formatter: json
|
||||||
- dataset:
|
- dataset:
|
||||||
services: {{ consul.register }}
|
services: {{ consul.register | json }}
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
consul:
|
consul:
|
||||||
version: 1.4.0
|
version: 1.4.0
|
||||||
download_host: releases.hashicorp.com
|
download_host: releases.hashicorp.com
|
||||||
|
bin_dir: /usr/local/bin
|
||||||
|
|
||||||
service: false
|
service: false
|
||||||
|
|
||||||
user: consul
|
user: consul
|
||||||
|
user_uid:
|
||||||
group: consul
|
group: consul
|
||||||
|
group_gid:
|
||||||
ui_beta: false
|
|
||||||
|
|
||||||
config:
|
config:
|
||||||
server: false
|
server: false
|
||||||
|
@ -16,6 +17,7 @@ consul:
|
||||||
ui: true
|
ui: true
|
||||||
enable_debug: false
|
enable_debug: false
|
||||||
log_level: info
|
log_level: info
|
||||||
|
encrypt: ""
|
||||||
retry_join: []
|
retry_join: []
|
||||||
retry_interval: 30s
|
retry_interval: 30s
|
||||||
datacenter: "main"
|
datacenter: "main"
|
||||||
|
|
|
@ -1,15 +1,20 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=consul
|
Description="HashiCorp Consul - A service mesh solution"
|
||||||
Wants=network.target
|
Documentation=https://www.consul.io/
|
||||||
After=network.target
|
Requires=network-online.target
|
||||||
|
After=network-online.target
|
||||||
|
ConditionFileNotEmpty=/etc/consul.d/config.json
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
EnvironmentFile=-/etc/{% if grains['os_family'] == 'Debian' %}default{% else %}sysconfig{% endif %}/consul
|
EnvironmentFile=-/etc/{% if grains['os_family'] == 'Debian' %}default{% else %}sysconfig{% endif %}/consul
|
||||||
ExecStart=/opt/consul/bin/consul agent -config-dir=/etc/consul.d
|
|
||||||
ExecReload=/bin/kill -HUP $MAINPID
|
|
||||||
KillSignal=TERM
|
|
||||||
User={{ user }}
|
User={{ user }}
|
||||||
Group={{ group }}
|
Group={{ group }}
|
||||||
|
ExecStart={{ bin_dir }}/consul agent -config-dir=/etc/consul.d
|
||||||
|
ExecReload={{ bin_dir }}/consul reload
|
||||||
|
KillMode=process
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=42s
|
||||||
|
LimitNOFILE=65536
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
. /etc/rc.d/init.d/functions
|
. /etc/rc.d/init.d/functions
|
||||||
|
|
||||||
prog="consul"
|
prog="consul"
|
||||||
exec="/opt/consul/bin/$prog"
|
exec="{{ bin_dir }}/$prog"
|
||||||
pidfile="/var/run/$prog.pid"
|
pidfile="/var/run/$prog.pid"
|
||||||
lockfile="/var/lock/subsys/$prog"
|
lockfile="/var/lock/subsys/$prog"
|
||||||
logfile="/var/log/$prog"
|
logfile="/var/log/$prog"
|
||||||
|
|
|
@ -18,7 +18,7 @@ script
|
||||||
|
|
||||||
exec start-stop-daemon --start \
|
exec start-stop-daemon --start \
|
||||||
--chuid ${CONSUL_USER:-consul}:${CONSUL_GROUP:-consul} \
|
--chuid ${CONSUL_USER:-consul}:${CONSUL_GROUP:-consul} \
|
||||||
--exec /opt/consul/bin/consul agent -- \
|
--exec {{ bin_dir }}/consul agent -- \
|
||||||
-config-dir="/etc/consul.d" \
|
-config-dir="/etc/consul.d" \
|
||||||
${CONSUL_FLAGS} \
|
${CONSUL_FLAGS} \
|
||||||
>> /var/log/consul.log 2>&1
|
>> /var/log/consul.log 2>&1
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
{%- if pillar.get('consul', {}).get('enabled', True) %}
|
||||||
{% from slspath+"/map.jinja" import consul with context %}
|
{% from slspath+"/map.jinja" import consul with context %}
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- {{ slspath }}.install
|
- {{ slspath }}.install
|
||||||
- {{ slspath }}.config
|
- {{ slspath }}.config
|
||||||
- {{ slspath }}.service
|
- {{ slspath }}.service
|
||||||
|
|
||||||
|
{%- endif %}
|
|
@ -6,7 +6,7 @@ consul-dep-unzip:
|
||||||
|
|
||||||
consul-bin-dir:
|
consul-bin-dir:
|
||||||
file.directory:
|
file.directory:
|
||||||
- name: /opt/consul/bin
|
- name: {{ consul.bin_dir }}
|
||||||
- makedirs: True
|
- makedirs: True
|
||||||
|
|
||||||
# Create consul user
|
# Create consul user
|
||||||
|
@ -14,6 +14,9 @@ consul-group:
|
||||||
group.present:
|
group.present:
|
||||||
- name: {{ consul.group }}
|
- name: {{ consul.group }}
|
||||||
- system: True
|
- system: True
|
||||||
|
{% if consul.get('group_gid', None) != None -%}
|
||||||
|
- gid: {{ consul.group_gid }}
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
consul-user:
|
consul-user:
|
||||||
user.present:
|
user.present:
|
||||||
|
@ -23,6 +26,9 @@ consul-user:
|
||||||
- home: {{ salt['user.info'](consul.user)['home']|default(consul.config.data_dir) }}
|
- home: {{ salt['user.info'](consul.user)['home']|default(consul.config.data_dir) }}
|
||||||
- createhome: False
|
- createhome: False
|
||||||
- system: True
|
- system: True
|
||||||
|
{% if consul.get('user_uid', None) != None -%}
|
||||||
|
- uid: {{ consul.user_uid }}
|
||||||
|
{%- endif %}
|
||||||
- require:
|
- require:
|
||||||
- group: consul-group
|
- group: consul-group
|
||||||
|
|
||||||
|
@ -48,7 +54,7 @@ consul-download:
|
||||||
- name: /tmp/consul_{{ consul.version }}_linux_{{ consul.arch }}.zip
|
- name: /tmp/consul_{{ consul.version }}_linux_{{ consul.arch }}.zip
|
||||||
- source: https://{{ consul.download_host }}/consul/{{ consul.version }}/consul_{{ consul.version }}_linux_{{ consul.arch }}.zip
|
- source: https://{{ consul.download_host }}/consul/{{ consul.version }}/consul_{{ consul.version }}_linux_{{ consul.arch }}.zip
|
||||||
- source_hash: https://releases.hashicorp.com/consul/{{ consul.version }}/consul_{{ consul.version }}_SHA256SUMS
|
- source_hash: https://releases.hashicorp.com/consul/{{ consul.version }}/consul_{{ consul.version }}_SHA256SUMS
|
||||||
- unless: test -f /opt/consul/bin/consul-{{ consul.version }}
|
- unless: test -f {{ consul.bin_dir }}-{{ consul.version }}
|
||||||
|
|
||||||
consul-extract:
|
consul-extract:
|
||||||
cmd.wait:
|
cmd.wait:
|
||||||
|
@ -58,10 +64,10 @@ consul-extract:
|
||||||
|
|
||||||
consul-install:
|
consul-install:
|
||||||
file.rename:
|
file.rename:
|
||||||
- name: /opt/consul/bin/consul-{{ consul.version }}
|
- name: {{ consul.bin_dir }}/consul-{{ consul.version }}
|
||||||
- source: /tmp/consul
|
- source: /tmp/consul
|
||||||
- require:
|
- require:
|
||||||
- file: /opt/consul/bin
|
- file: {{ consul.bin_dir }}
|
||||||
- watch:
|
- watch:
|
||||||
- cmd: consul-extract
|
- cmd: consul-extract
|
||||||
|
|
||||||
|
@ -74,6 +80,6 @@ consul-clean:
|
||||||
consul-link:
|
consul-link:
|
||||||
file.symlink:
|
file.symlink:
|
||||||
- target: consul-{{ consul.version }}
|
- target: consul-{{ consul.version }}
|
||||||
- name: /opt/consul/bin/consul
|
- name: {{ consul.bin_dir }}/consul
|
||||||
- watch:
|
- watch:
|
||||||
- file: consul-install
|
- file: consul-install
|
||||||
|
|
|
@ -14,27 +14,31 @@ consul-init-env:
|
||||||
- contents:
|
- contents:
|
||||||
- CONSUL_USER={{ consul.user }}
|
- CONSUL_USER={{ consul.user }}
|
||||||
- CONSUL_GROUP={{ consul.group }}
|
- CONSUL_GROUP={{ consul.group }}
|
||||||
- CONSUL_UI_BETA={{ consul.ui_beta }}
|
|
||||||
- GOMAXPROCS=2
|
- GOMAXPROCS=2
|
||||||
- PATH=/usr/local/bin:/usr/bin:/bin
|
- PATH=/usr/local/bin:/usr/bin:/bin
|
||||||
|
|
||||||
consul-init-file:
|
consul-init-file:
|
||||||
file.managed:
|
file.managed:
|
||||||
{%- if salt['test.provider']('service') == 'systemd' %}
|
{%- if salt['test.provider']('service').startswith('systemd') %}
|
||||||
- source: salt://{{ slspath }}/files/consul.service
|
- source: salt://{{ slspath }}/files/consul.service
|
||||||
- name: /etc/systemd/system/consul.service
|
- name: /etc/systemd/system/consul.service
|
||||||
- template: jinja
|
- template: jinja
|
||||||
- context:
|
- context:
|
||||||
user: {{ consul.user }}
|
user: {{ consul.user }}
|
||||||
group: {{ consul.group }}
|
group: {{ consul.group }}
|
||||||
|
bin_dir: {{ consul.bin_dir }}
|
||||||
- mode: 0644
|
- mode: 0644
|
||||||
{%- elif salt['test.provider']('service') == 'upstart' %}
|
{%- elif salt['test.provider']('service') == 'upstart' %}
|
||||||
- source: salt://{{ slspath }}/files/consul.upstart
|
- source: salt://{{ slspath }}/files/consul.upstart
|
||||||
- name: /etc/init/consul.conf
|
- name: /etc/init/consul.conf
|
||||||
|
- context:
|
||||||
|
bin_dir: {{ consul.bin_dir }}
|
||||||
- mode: 0644
|
- mode: 0644
|
||||||
{%- else %}
|
{%- else %}
|
||||||
- source: salt://{{ slspath }}/files/consul.sysvinit
|
- source: salt://{{ slspath }}/files/consul.sysvinit
|
||||||
- name: /etc/init.d/consul
|
- name: /etc/init.d/consul
|
||||||
|
- context:
|
||||||
|
bin_dir: {{ consul.bin_dir }}
|
||||||
- mode: 0755
|
- mode: 0755
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,10 @@ consul:
|
||||||
# Set user and group for Consul config files and running service
|
# Set user and group for Consul config files and running service
|
||||||
user: consul
|
user: consul
|
||||||
group: consul
|
group: consul
|
||||||
|
bin_dir: /opt/consul/bin
|
||||||
|
|
||||||
|
version: 0.7.0
|
||||||
|
download_host: releases.hashicorp.com
|
||||||
|
|
||||||
config:
|
config:
|
||||||
server: True
|
server: True
|
||||||
|
@ -22,6 +26,10 @@ consul:
|
||||||
- 1.1.1.1
|
- 1.1.1.1
|
||||||
- 2.2.2.2
|
- 2.2.2.2
|
||||||
|
|
||||||
|
ui: true
|
||||||
|
log_level: info
|
||||||
|
data_dir: /var/consul
|
||||||
|
|
||||||
register:
|
register:
|
||||||
- name: Redis
|
- name: Redis
|
||||||
checks:
|
checks:
|
||||||
|
|
Loading…
Reference in a new issue