mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-04-16 10:13:26 +02:00
Update to 2022-08-11 11:00
This commit is contained in:
parent
617c1583eb
commit
9d4a3e4947
@ -13,6 +13,10 @@ consul_user: consul
|
|||||||
# Root directory where consul will be installed
|
# Root directory where consul will be installed
|
||||||
consul_root_dir: /opt/consul
|
consul_root_dir: /opt/consul
|
||||||
|
|
||||||
|
# If ACL are enabled, you need to set a management token for ansible
|
||||||
|
# to be able to manage Consul (eg snapshot before upgrades)
|
||||||
|
# consul_mgm_token: XXXXXXXXX
|
||||||
|
|
||||||
# List of consul servers name or IP
|
# List of consul servers name or IP
|
||||||
consul_servers: []
|
consul_servers: []
|
||||||
|
|
||||||
@ -41,6 +45,10 @@ consul_base_conf:
|
|||||||
# You can define the datacenter in which this agent is running. The default value is dc1
|
# You can define the datacenter in which this agent is running. The default value is dc1
|
||||||
# datacenter: dc1
|
# datacenter: dc1
|
||||||
|
|
||||||
|
# When several DC are used, one must be set as the primary. This DC will be used as the
|
||||||
|
# source for ACL replication
|
||||||
|
# primary_datacenter: dc1
|
||||||
|
|
||||||
# Node name, which should be uniq in the region. Default is the hostname
|
# Node name, which should be uniq in the region. Default is the hostname
|
||||||
# node_name: consule-fr-zone-c
|
# node_name: consule-fr-zone-c
|
||||||
|
|
||||||
|
@ -4,7 +4,22 @@
|
|||||||
file: path={{ consul_root_dir }}/archives/{{ consul_current_version }} state=directory
|
file: path={{ consul_root_dir }}/archives/{{ consul_current_version }} state=directory
|
||||||
tags: consul
|
tags: consul
|
||||||
|
|
||||||
- name: Backup previous version
|
- name: Snapshot consul data
|
||||||
copy: src={{ consul_root_dir }}/bin/consul dest={{ consul_root_dir }}/archives/{{ consul_current_version }}/ remote_src=True
|
command: "{{ consul_root_dir }}/bin/consul snapshot save {{ consul_root_dir }}/archives/{{ consul_current_version }}/consul.snap"
|
||||||
|
args:
|
||||||
|
creates: "{{ consul_root_dir }}/archives/{{ consul_current_version }}/consul.snap"
|
||||||
|
failed_when: False # If consul is not running, it'll fail, just continue
|
||||||
|
environment:
|
||||||
|
CONSUL_TOKEN: "{{ consul_mgm_token | default(omit) }}"
|
||||||
|
tags: consul
|
||||||
|
|
||||||
|
- name: Backup previous version
|
||||||
|
synchronize:
|
||||||
|
src: "{{ consul_root_dir }}/{{ item }}"
|
||||||
|
dest: "{{ consul_root_dir }}/archives/{{ consul_current_version }}/"
|
||||||
|
compress: False
|
||||||
|
delegate_to: "{{ inventory_hostname }}"
|
||||||
|
loop:
|
||||||
|
- bin
|
||||||
tags: consul
|
tags: consul
|
||||||
|
|
||||||
|
@ -60,3 +60,15 @@
|
|||||||
when: consul_conf_validation.rc != 0
|
when: consul_conf_validation.rc != 0
|
||||||
tags: consul
|
tags: consul
|
||||||
|
|
||||||
|
# Now we remove the backup config to prevent consul warning about invalid config files
|
||||||
|
- name: List backup conf
|
||||||
|
shell: ls -1 {{ consul_root_dir }}/etc/*.hcl.*
|
||||||
|
failed_when: False
|
||||||
|
changed_when: False
|
||||||
|
register: consul_backup_configs
|
||||||
|
tags: consul
|
||||||
|
|
||||||
|
- name: Remove backup configs
|
||||||
|
file: path={{ item }} state=absent
|
||||||
|
loop: "{{ consul_backup_configs.stdout_lines }}"
|
||||||
|
tags: consul
|
||||||
|
@ -23,4 +23,5 @@
|
|||||||
|
|
||||||
- when: consul_bin.stat.exists and consul_current_version != consul_version
|
- when: consul_bin.stat.exists and consul_current_version != consul_version
|
||||||
set_fact: consul_install_mode='upgrade'
|
set_fact: consul_install_mode='upgrade'
|
||||||
|
tags: consul
|
||||||
|
|
||||||
|
@ -8,6 +8,10 @@ advertise_addr = "{{ consul_conf.advertise_addr }}"
|
|||||||
datacenter = "{{ consul_conf.datacenter }}"
|
datacenter = "{{ consul_conf.datacenter }}"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if consul_conf.primary_datacenter is defined %}
|
||||||
|
primary_datacenter = "{{ consul_conf.primary_datacenter }}"
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if consul_conf.node_name is defined %}
|
{% if consul_conf.node_name is defined %}
|
||||||
node_name = {{ consul_conf.node_name }}
|
node_name = {{ consul_conf.node_name }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -156,6 +156,15 @@ nomad_base_conf:
|
|||||||
publish_allocation_metrics: True
|
publish_allocation_metrics: True
|
||||||
publish_node_metrics: True
|
publish_node_metrics: True
|
||||||
|
|
||||||
|
# Consul integration
|
||||||
|
# See https://www.nomadproject.io/docs/configuration/consul
|
||||||
|
consul:
|
||||||
|
# address: http://localhost:8500
|
||||||
|
# allow_unauthenticated: True
|
||||||
|
# tags: []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# You can override part of the default config without rewriting everything else
|
# You can override part of the default config without rewriting everything else
|
||||||
# the dict will get merged
|
# the dict will get merged
|
||||||
nomad_extra_conf: {}
|
nomad_extra_conf: {}
|
||||||
|
Binary file not shown.
@ -60,3 +60,16 @@
|
|||||||
when: nomad_conf_validation.rc != 0
|
when: nomad_conf_validation.rc != 0
|
||||||
tags: nomad
|
tags: nomad
|
||||||
|
|
||||||
|
# Now we remove the backup config to prevent nomad warning about invalid config files
|
||||||
|
- name: List backup conf
|
||||||
|
shell: ls -1 {{ nomad_root_dir }}/etc/*.hcl.*
|
||||||
|
failed_when: False
|
||||||
|
changed_when: False
|
||||||
|
register: nomad_backup_configs
|
||||||
|
tags: nomad
|
||||||
|
|
||||||
|
- name: Remove backup configs
|
||||||
|
file: path={{ item }} state=absent
|
||||||
|
loop: "{{ nomad_backup_configs.stdout_lines }}"
|
||||||
|
tags: nomad
|
||||||
|
|
||||||
|
@ -164,3 +164,19 @@ telemetry {
|
|||||||
publish_allocation_metrics = {{ nomad_conf.telemetry.publish_allocation_metrics | ternary('true', 'false') }}
|
publish_allocation_metrics = {{ nomad_conf.telemetry.publish_allocation_metrics | ternary('true', 'false') }}
|
||||||
publish_node_metrics = {{ nomad_conf.telemetry.publish_node_metrics | ternary('true', 'false') }}
|
publish_node_metrics = {{ nomad_conf.telemetry.publish_node_metrics | ternary('true', 'false') }}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
consul {
|
||||||
|
{% if nomad_conf.consul.address is defined %}
|
||||||
|
address = "{{ nomad_conf.consul.address }}"
|
||||||
|
{% endif %}
|
||||||
|
{% if nomad_conf.consul.allow_unauthenticated is defined %}
|
||||||
|
allow_unauthenticated = {{ nomad_conf.consul.allow_unauthenticated | ternary('true', 'false') }}
|
||||||
|
{% endif %}
|
||||||
|
{% if nomad_conf.consul.tags is defined and nomad_conf.consul.tags is iterable %}
|
||||||
|
tags = [
|
||||||
|
{% for tag in nomad_conf.consul.tags %}
|
||||||
|
"{{ tag }}"
|
||||||
|
]
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user