Added configuration handler.
This commit is contained in:
parent
8b2e00a5e2
commit
25ee8ba480
7 changed files with 31 additions and 7 deletions
|
@ -1,5 +1,22 @@
|
||||||
{%- from slspath + '/map.jinja' import fabio with context -%}
|
{%- from slspath + '/map.jinja' import fabio with context -%}
|
||||||
|
|
||||||
|
fabio-config:
|
||||||
|
file.managed:
|
||||||
|
- name: {{ fabio.config_file }}
|
||||||
|
- source: salt://{{ slspath }}/files/fabio.cfg
|
||||||
|
- context:
|
||||||
|
config: {{ fabio.config }}
|
||||||
|
- template: jinja
|
||||||
|
- user: {{ fabio.user}}
|
||||||
|
- group: {{ fabio.group }}
|
||||||
|
- mode: 0640
|
||||||
|
- require:
|
||||||
|
- user: fabio-user
|
||||||
|
{%- if fabio.service %}
|
||||||
|
- watch_in:
|
||||||
|
- service: fabio
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
{#
|
{#
|
||||||
fabio-config:
|
fabio-config:
|
||||||
file.serialize:
|
file.serialize:
|
||||||
|
|
|
@ -8,6 +8,9 @@ fabio:
|
||||||
user: fabio
|
user: fabio
|
||||||
group: fabio
|
group: fabio
|
||||||
|
|
||||||
|
config_file: /etc/fabio/fabio.cfg
|
||||||
|
consul_address: localhost:8500
|
||||||
|
data_dir: /var/fabio
|
||||||
|
|
||||||
config:
|
config:
|
||||||
consul_address: localhost:8500
|
proxy.addr: :80,:9999
|
||||||
data_dir: /var/fabio
|
|
||||||
|
|
3
fabio/files/fabio.cfg
Normal file
3
fabio/files/fabio.cfg
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{%- for key, val in config.iteritems() %}
|
||||||
|
{{ key }} = {{ val }}
|
||||||
|
{%- endfor %}
|
|
@ -5,7 +5,7 @@ After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
EnvironmentFile=-/etc/{% if grains['os_family'] == 'Debian' %}default{% else %}sysconfig{% endif %}/fabio
|
EnvironmentFile=-/etc/{% if grains['os_family'] == 'Debian' %}default{% else %}sysconfig{% endif %}/fabio
|
||||||
ExecStart=/usr/local/bin/fabio -registry.consul.addr {{ consul_address }}
|
ExecStart=/usr/local/bin/fabio -cfg {{ config_file }} -registry.consul.addr {{ consul_address }}
|
||||||
ExecReload=/bin/kill -HUP $MAINPID
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
User={{ user }}
|
User={{ user }}
|
||||||
Group={{ group }}
|
Group={{ group }}
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- {{ slspath }}.install
|
- {{ slspath }}.install
|
||||||
{# - {{ slspath }}.config #}
|
- {{ slspath }}.config
|
||||||
- {{ slspath }}.service
|
- {{ slspath }}.service
|
||||||
|
|
|
@ -15,7 +15,7 @@ fabio-user:
|
||||||
- name: {{ fabio.user }}
|
- name: {{ fabio.user }}
|
||||||
- groups:
|
- groups:
|
||||||
- {{ fabio.group }}
|
- {{ fabio.group }}
|
||||||
- home: {{ salt['user.info'](fabio.user)['home']|default(fabio.config.data_dir) }}
|
- home: {{ salt['user.info'](fabio.user)['home']|default(fabio.data_dir) }}
|
||||||
- createhome: False
|
- createhome: False
|
||||||
- system: True
|
- system: True
|
||||||
- require:
|
- require:
|
||||||
|
@ -31,7 +31,7 @@ fabio-config-dir:
|
||||||
|
|
||||||
fabio-data-dir:
|
fabio-data-dir:
|
||||||
file.directory:
|
file.directory:
|
||||||
- name: {{ fabio.config.data_dir }}
|
- name: {{ fabio.data_dir }}
|
||||||
- makedirs: True
|
- makedirs: True
|
||||||
- user: {{ fabio.user }}
|
- user: {{ fabio.user }}
|
||||||
- group: {{ fabio.group }}
|
- group: {{ fabio.group }}
|
||||||
|
|
|
@ -26,7 +26,8 @@ fabio-init-file:
|
||||||
- context:
|
- context:
|
||||||
user: {{ fabio.user }}
|
user: {{ fabio.user }}
|
||||||
group: {{ fabio.group }}
|
group: {{ fabio.group }}
|
||||||
consul_address: {{ fabio.config.consul_address }}
|
config_file: {{ fabio.config_file }}
|
||||||
|
consul_address: {{ fabio.consul_address }}
|
||||||
- mode: 0644
|
- mode: 0644
|
||||||
{%- elif salt['test.provider']('service') == 'upstart' %}
|
{%- elif salt['test.provider']('service') == 'upstart' %}
|
||||||
- source: salt://{{ slspath }}/files/fabio.upstart
|
- source: salt://{{ slspath }}/files/fabio.upstart
|
||||||
|
|
Loading…
Reference in a new issue