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