Better folder structure

This commit is contained in:
Bahadır Kandemir 2015-10-22 20:53:33 +03:00
parent f1fecea83e
commit 047e3d7e5c
3 changed files with 113 additions and 31 deletions

View file

@ -1,12 +1,19 @@
consul: consul:
version: 0.5.2 version: 0.5.2
hash: b3ae610c670fc3b81737d44724ebde969da66ebf hash: b3ae610c670fc3b81737d44724ebde969da66ebf
ui_version: 0.5.2
ui_hash: 67a2665e3c6aa6ca95c24d6176641010a1002cd6
template_version: 0.11.0
template_hash: 3894617dfa7d9ccdd4b754023e528b46a13423a6
service: false service: false
config: config:
server: false server: false
bind_addr: 0.0.0.0 bind_addr: 0.0.0.0
data_dir: /var/consul data_dir: /var/consul
ui_dir: /opt/consul/dist ui_dir: /usr/local/share/consul/ui
enable_debug: false enable_debug: false
log_level: info log_level: info
encrypt: "" encrypt: ""

View file

@ -5,8 +5,40 @@ unzip:
/usr/local/bin: /usr/local/bin:
file.directory: file.directory:
- recuse: True - makedirs: True
consul_user:
group.present:
- name: consul
user.present:
- name: consul
- createhome: false
- system: true
- groups:
- consul
- require:
- group: consul
consul_config_dir:
file.directory:
- name: /etc/consul.d
- user: consul
- group: consul
consul_runtime_dir:
file.directory:
- name: /var/consul
- user: consul
- group: consul
consul_data_dir:
file.directory:
- name: /usr/share/local/consul
- user: consul
- group: consul
- makedirs: True
# Consul agent
consul_download: consul_download:
file.managed: file.managed:
- name: /tmp/{{ consul.version }}_linux_amd64.zip - name: /tmp/{{ consul.version }}_linux_amd64.zip
@ -42,17 +74,77 @@ consul_link:
- watch: - watch:
- file: consul_install - file: consul_install
consul_user: # Consul template engine
group.present: consul_template_download:
- name: consul file.managed:
user.present: - name: /tmp/consul_template_{{ consul.template_version }}_linux_amd64.zip
- name: consul - source: https://github.com/hashicorp/consul-template/releases/download/v{{ consul.template_version }}/consul_template_{{ consul.template_version }}_linux_amd64.zip
- createhome: false - source_hash: sha1={{ consul.template_hash }}
- system: true - unless: test -f /usr/local/bin/consul-template-{{ consul.template_version }}
- groups:
- consul consul_template_extract:
cmd.wait:
- name: unzip /tmp/consul_template_{{ consul.template_version }}_linux_amd64.zip -d /tmp
- watch:
- file: consul_template_download
consul_template_install:
file.rename:
- name: /usr/local/bin/consul-template-{{ consul.template_version }}
- source: /tmp/consul-template
- require: - require:
- group: consul - file: /usr/local/bin
- watch:
- cmd: consul_template_extract
consul_template_clean:
file.absent:
- name: /tmp/consul_template_{{ consul.template_version }}_linux_amd64.zip
- watch:
- file: consul_template_install
consul_template_link:
file.symlink:
- target: consul-template-{{ consul.version }}
- name: /usr/local/bin/consul-template
- watch:
- file: consul_template_install
# Consul UI
consul_ui_download:
file.managed:
- name: /tmp/{{ consul.ui_version }}_web_ui.zip
- source: https://dl.bintray.com/mitchellh/consul/{{ consul.ui_version }}_web_ui.zip
- source_hash: sha1={{ consul.ui_hash }}
- unless: test -f /usr/local/share/consul/ui-{{ consul.ui_version }}
consul_ui_extract:
cmd.wait:
- name: unzip /tmp/{{ consul.ui_version }}_web_ui.zip -d /tmp/
- watch:
- file: consul_ui_download
consul_ui_install:
file.rename:
- name: /usr/local/share/consul/ui-{{ consul.template_version }}
- source: /tmp/dist
- require:
- file: /usr/local/share/consul
- watch:
- cmd: consul_ui_extract
consul_ui_clean:
file.absent:
- name: /tmp/{{ consul.ui_version }}_web_ui.zip
- watch:
- file: consul_ui_install
consul_ui_link:
file.symlink:
- target: ui-{{ consul.version }}
- name: /usr/local/share/consul/ui
- watch:
- file: consul_ui_install
consul_init_script: consul_init_script:
file.managed: file.managed:
@ -70,23 +162,6 @@ consul_init_script:
- service: consul - service: consul
{% endif %} {% endif %}
consul_config_dir:
file.directory:
- name: /etc/consul.d
- user: consul
- group: consul
consul_data_dir:
file.directory:
- name: /var/consul
- user: consul
- group: consul
consul_script_dir:
file.directory:
- name: /opt/consul/scripts
- user: consul
- group: consul
consul_config: consul_config:
file.managed: file.managed:

View file

@ -14,8 +14,8 @@ consul:
register: register:
- name: Redis - name: Redis
checks: checks:
- script: /opt/consul/check_redis.py - script: /usr/share/local/consul/check_redis.py
interval: 10s interval: 10s
scripts: scripts:
- source: salt://files/consul/check_redis.py - source: salt://files/consul/check_redis.py
name: /opt/consul/check_redis.py name: /usr/share/local/consul/check_redis.py