Last active
April 11, 2016 20:57
-
-
Save stenius/38581d80a3ebb047f820d9c0113c158d to your computer and use it in GitHub Desktop.
Salt Stack state file for setting up a Consul agent that binds to a VPN tunnel
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
/etc/consul.d: | |
file.directory: | |
- user: root | |
- group: adm | |
- mode: 0755 | |
/etc/consul.d/client: | |
file.directory: | |
- user: root | |
- group: adm | |
- mode: 0755 | |
- require: | |
- file: /etc/consul.d | |
consul: | |
user.present: | |
- fullname: Consul User | |
- shell: /bin/bash | |
- home: /var/consul | |
service.running: | |
- enable: True | |
- require: | |
- file: /var/consul | |
- watch: | |
- file: /etc/consul.d/client/config.json | |
- file: /etc/consul.d/client/services.json | |
- file: /usr/local/bin/consul | |
/var/consul: | |
file.directory: | |
- user: consul | |
- group: consul | |
- mode: 0750 | |
- require: | |
- user: consul | |
/usr/local/bin/consul: | |
file.managed: | |
{% if grains['cpuarch'] == 'x86_64' %} | |
- source: salt://consul/consul.amd64.bin | |
{% else %} | |
- source: salt://consul/consul.x86.bin | |
{% endif %} | |
- user: root | |
- group: adm | |
- mode: 0755 | |
/etc/consul.d/client/config.json: | |
file.managed: | |
- source: salt://consul/config.json | |
- user: root | |
- group: adm | |
- mode: 0644 | |
- require: | |
- file: /etc/consul.d/client | |
/etc/consul.d/client/services.json: | |
file.managed: | |
- template: py | |
- defaults: | |
bind_addr: {{grains['ip4_interfaces']['tun0'][0]}} | |
- source: salt://consul/services.json.sls | |
- user: root | |
- group: adm | |
- mode: 0644 | |
- require: | |
- file: /etc/consul.d/client | |
/etc/init/consul.conf: | |
file.managed: | |
- template: jinja | |
- defaults: | |
bind_addr: {{grains['ip4_interfaces']['tun0'][0]}} | |
- source: salt://consul/consul.init | |
- user: root | |
- group: adm | |
- mode: 0640 | |
- require: | |
- file: /etc/consul.d/client |
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
{ | |
"server": false, | |
"datacenter": "dc1", | |
"data_dir": "/var/consul", | |
"ui_dir": "/home/consul/dist", | |
"log_level": "INFO", | |
"enable_syslog": true | |
} |
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
description "Consul client process" | |
start on (local-filesystems and net-device-up IFACE=eth0) | |
stop on runlevel [!12345] | |
respawn | |
setuid consul | |
setgid consul | |
exec consul agent -data-dir=/var/consul -config-dir /etc/consul.d/client -bind {{bind_addr}} |
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
consul: | |
services: | |
- tags: | |
- "prod" | |
- "master" | |
address: "127.0.0.1" | |
name: "solr" | |
port: 8983 | |
checks: | |
- http: "http://localhost:8983/" | |
interval: "10s" |
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
#! py | |
import json as json | |
def run(): | |
consul_data = pillar.get('consul', {}) | |
data = json.dumps(consul_data, indent=2) | |
return data | |
# vim: ft=python ts=4 sts=4 sw=4 et |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment