mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-04-19 03:33:17 +02:00
Update to 2022-08-09 13:00
This commit is contained in:
parent
62cd35b3cc
commit
e0ae369ed1
@ -1,5 +1,7 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
- name: Deploy consul configuration
|
||||||
|
block:
|
||||||
- name: Deploy consul configuration
|
- name: Deploy consul configuration
|
||||||
template:
|
template:
|
||||||
src: consul.hcl.j2
|
src: consul.hcl.j2
|
||||||
@ -7,6 +9,54 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: "{{ consul_user }}"
|
group: "{{ consul_user }}"
|
||||||
mode: 0640
|
mode: 0640
|
||||||
validate: consul validate -config-format=hcl %s
|
backup: True
|
||||||
|
register: consul_main_conf
|
||||||
notify: restart consul
|
notify: restart consul
|
||||||
|
|
||||||
|
- name: Deploy consul reloadable configuration
|
||||||
|
template:
|
||||||
|
src: reload.hcl.j2
|
||||||
|
dest: "{{ consul_root_dir }}/etc/reload.hcl"
|
||||||
|
owner: root
|
||||||
|
group: "{{ consul_user }}"
|
||||||
|
mode: 0640
|
||||||
|
backup: True
|
||||||
|
register: consul_reload_conf
|
||||||
|
notify: reload consul
|
||||||
|
|
||||||
|
- name: Validate configuration
|
||||||
|
command: consul validate {{ consul_root_dir }}/etc
|
||||||
|
changed_when: False
|
||||||
|
become_user: "{{ consul_user }}"
|
||||||
|
register: consul_conf_validation
|
||||||
|
|
||||||
|
rescue:
|
||||||
|
- block:
|
||||||
|
- name: Restore main configuration
|
||||||
|
copy:
|
||||||
|
src: "{{ consul_main_conf.backup_file }}"
|
||||||
|
dest: "{{ consul_root_dir }}/etc/consul.hcl"
|
||||||
|
remote_src: True
|
||||||
|
owner: root
|
||||||
|
group: "{{ consul_user }}"
|
||||||
|
mode: 0640
|
||||||
|
when: consul_main_conf.backup_file is defined
|
||||||
|
|
||||||
|
- name: Restore reloadable configuration
|
||||||
|
copy:
|
||||||
|
src: "{{ consul_reload_conf.backup_file }}"
|
||||||
|
dest: "{{ consul_root_dir }}/etc/reload.hcl"
|
||||||
|
remote_src: True
|
||||||
|
owner: root
|
||||||
|
group: "{{ consul_user }}"
|
||||||
|
mode: 0640
|
||||||
|
when: consul_reload_conf.backup_file is defined
|
||||||
|
|
||||||
tags: consul
|
tags: consul
|
||||||
|
|
||||||
|
- name: Fail if configuration validation failed
|
||||||
|
fail:
|
||||||
|
msg: "Failed to validate configuration: {{ consul_conf_validation.stdout }}"
|
||||||
|
when: consul_conf_validation.rc != 0
|
||||||
|
tags: consul
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
data_dir = "{{ consul_root_dir }}/data"
|
data_dir = "{{ consul_root_dir }}/data"
|
||||||
log_level = "{{ consul_conf.log_level }}"
|
|
||||||
bind_addr = "0.0.0.0"
|
bind_addr = "0.0.0.0"
|
||||||
client_addr = "0.0.0.0"
|
client_addr = "0.0.0.0"
|
||||||
|
|
||||||
@ -13,12 +12,6 @@ datacenter = "{{ consul_conf.datacenter }}"
|
|||||||
node_name = {{ consul_conf.node_name }}
|
node_name = {{ consul_conf.node_name }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
node_meta {
|
|
||||||
{% for meta in consul_conf.node_meta.keys() | list %}
|
|
||||||
{{ meta }} = "{{ consul_conf.node_meta[meta] }}"
|
|
||||||
{% endfor %}
|
|
||||||
}
|
|
||||||
|
|
||||||
ports {
|
ports {
|
||||||
{% for service in consul_services.keys() | list %}
|
{% for service in consul_services.keys() | list %}
|
||||||
{% if service not in ['sidecar', 'expose'] and consul_services[service].port is defined %}
|
{% if service not in ['sidecar', 'expose'] and consul_services[service].port is defined %}
|
||||||
|
@ -10,7 +10,7 @@ Type=notify
|
|||||||
EnvironmentFile=-{{ consul_root_dir }}/etc/consul.env
|
EnvironmentFile=-{{ consul_root_dir }}/etc/consul.env
|
||||||
User={{ consul_user }}
|
User={{ consul_user }}
|
||||||
Group={{ consul_user }}
|
Group={{ consul_user }}
|
||||||
ExecStart={{ consul_root_dir }}/bin/consul agent -config-file={{ consul_root_dir }}/etc/consul.hcl
|
ExecStart={{ consul_root_dir }}/bin/consul agent -config-dir={{ consul_root_dir }}/etc/
|
||||||
ExecReload=/bin/kill --signal HUP $MAINPID
|
ExecReload=/bin/kill --signal HUP $MAINPID
|
||||||
SuccessExitStatus=1
|
SuccessExitStatus=1
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
8
roles/consul/templates/reload.hcl.j2
Normal file
8
roles/consul/templates/reload.hcl.j2
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
log_level = "{{ consul_conf.log_level }}"
|
||||||
|
|
||||||
|
node_meta {
|
||||||
|
{% for meta in consul_conf.node_meta.keys() | list %}
|
||||||
|
{{ meta }} = "{{ consul_conf.node_meta[meta] }}"
|
||||||
|
{% endfor %}
|
||||||
|
}
|
||||||
|
|
BIN
roles/nomad/tasks/.conf.yml.swp
Normal file
BIN
roles/nomad/tasks/.conf.yml.swp
Normal file
Binary file not shown.
@ -1,5 +1,7 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
- name: Deploy nomad configuration
|
||||||
|
block:
|
||||||
- name: Deploy nomad configuration
|
- name: Deploy nomad configuration
|
||||||
template:
|
template:
|
||||||
src: nomad.hcl.j2
|
src: nomad.hcl.j2
|
||||||
@ -7,6 +9,54 @@
|
|||||||
owner: root
|
owner: root
|
||||||
group: "{{ nomad_user }}"
|
group: "{{ nomad_user }}"
|
||||||
mode: 0640
|
mode: 0640
|
||||||
validate: nomad config validate %s
|
backup: True
|
||||||
|
register: nomad_main_conf
|
||||||
notify: restart nomad
|
notify: restart nomad
|
||||||
|
|
||||||
|
- name: Deploy nomad reloadable configuration
|
||||||
|
template:
|
||||||
|
src: reload.hcl.j2
|
||||||
|
dest: "{{ nomad_root_dir }}/etc/reload.hcl"
|
||||||
|
owner: root
|
||||||
|
group: "{{ nomad_user }}"
|
||||||
|
mode: 0640
|
||||||
|
backup: True
|
||||||
|
register: nomad_reload_conf
|
||||||
|
notify: reload nomad
|
||||||
|
|
||||||
|
- name: Validate configuration
|
||||||
|
command: nomad config validate {{ nomad_root_dir }}/etc/nomad.hcl {{ nomad_root_dir }}/etc/reload.hcl
|
||||||
|
changed_when: False
|
||||||
|
become_user: "{{ nomad_user }}"
|
||||||
|
register: nomad_conf_validation
|
||||||
|
|
||||||
|
rescue:
|
||||||
|
- block:
|
||||||
|
- name: Restore main configuration
|
||||||
|
copy:
|
||||||
|
src: "{{ nomad_main_conf.backup_file }}"
|
||||||
|
dest: "{{ nomad_root_dir }}/etc/nomad.hcl"
|
||||||
|
remote_src: True
|
||||||
|
owner: root
|
||||||
|
group: "{{ nomad_user }}"
|
||||||
|
mode: 0640
|
||||||
|
when: nomad_main_conf.backup_file is defined
|
||||||
|
|
||||||
|
- name: Restore reloadable configuration
|
||||||
|
copy:
|
||||||
|
src: "{{ nomad_reload_conf.backup_file }}"
|
||||||
|
dest: "{{ nomad_root_dir }}/etc/reload.hcl"
|
||||||
|
remote_src: True
|
||||||
|
owner: root
|
||||||
|
group: "{{ nomad_user }}"
|
||||||
|
mode: 0640
|
||||||
|
when: nomad_reload_conf.backup_file is defined
|
||||||
|
|
||||||
tags: nomad
|
tags: nomad
|
||||||
|
|
||||||
|
- name: Fail if configuration validation failed
|
||||||
|
fail:
|
||||||
|
msg: "Failed to validate configuration: {{ nomad_conf_validation.stdout }}"
|
||||||
|
when: nomad_conf_validation.rc != 0
|
||||||
|
tags: nomad
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
data_dir = "{{ nomad_root_dir }}/data"
|
data_dir = "{{ nomad_root_dir }}/data"
|
||||||
plugin_dir = "{{ nomad_root_dir }}/plugins"
|
plugin_dir = "{{ nomad_root_dir }}/plugins"
|
||||||
log_level = "{{ nomad_conf.log_level }}"
|
|
||||||
bind_addr = "0.0.0.0"
|
bind_addr = "0.0.0.0"
|
||||||
|
|
||||||
{% if nomad_conf.datacenter is defined %}
|
{% if nomad_conf.datacenter is defined %}
|
||||||
|
@ -9,7 +9,7 @@ ConditionFileNotEmpty={{ nomad_root_dir }}/etc/nomad.hcl
|
|||||||
EnvironmentFile=-{{ nomad_root_dir }}/etc/nomad.env
|
EnvironmentFile=-{{ nomad_root_dir }}/etc/nomad.env
|
||||||
User={{ nomad_user }}
|
User={{ nomad_user }}
|
||||||
Group={{ nomad_user }}
|
Group={{ nomad_user }}
|
||||||
ExecStart={{ nomad_root_dir }}/bin/nomad agent -config={{ nomad_root_dir }}/etc/nomad.hcl
|
ExecStart={{ nomad_root_dir }}/bin/nomad agent -config={{ nomad_root_dir }}/etc/
|
||||||
ExecReload=/bin/kill --signal HUP $MAINPID
|
ExecReload=/bin/kill --signal HUP $MAINPID
|
||||||
SuccessExitStatus=1
|
SuccessExitStatus=1
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
1
roles/nomad/templates/reload.hcl.j2
Normal file
1
roles/nomad/templates/reload.hcl.j2
Normal file
@ -0,0 +1 @@
|
|||||||
|
log_level = "{{ nomad_conf.log_level }}"
|
Loading…
x
Reference in New Issue
Block a user