Skip to content

Commit

Permalink
Merge pull request #10 from Rheinwerk/PT-185542031-consul-etc-default…
Browse files Browse the repository at this point in the history
…-config-migration

[#185542031] Migration von `/etc/default` Parametern
  • Loading branch information
eifelmicha authored Jul 7, 2023
2 parents 501e901 + c002152 commit 2ca4cdd
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 14 deletions.
8 changes: 3 additions & 5 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ _consul:
user: "root"
group: "root"
config_dir: "{{ CONSUL_CONFIG_DIR }}"
daemon_args:
- "-config-dir={{ CONSUL_CONFIG_DIR }}"
- "-bind=0.0.0.0"
- "-client=127.0.0.1"
- "-node={{ ansible_fqdn }}"
bind_addr: 0.0.0.0
client_addr: 127.0.0.1
node_name: "{{ ansible_fqdn }}"
service_name: "consul"
flags:
- "-syslog"
Expand Down
3 changes: 3 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- name: Reload SystemD configs
ansible.builtin.systemd:
daemon_reload: true
10 changes: 7 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
group: "root"
mode: "0755"

- name: Create Consul Defaults File
- name: Create Consul env File
ansible.builtin.template:
src: "etc/default/consul.j2"
dest: "/etc/default/{{ _consul.service_name }}"
src: "etc/consul.d/{{ item }}.j2"
dest: "{{ _consul.config_dir }}/{{ item }}"
owner: "root"
group: "root"
mode: "0755"
with_items:
- "consul.env"

- name: Create Consul Configuration Files ... Main
ansible.builtin.template:
Expand Down Expand Up @@ -130,3 +132,5 @@
line: "OOMScoreAdjust={{ _consul.oom_score_adj }}"
insertafter: "^[Service]"
when: _consul.oom_score_adj is defined
notify:
- Reload SystemD configs
1 change: 1 addition & 0 deletions templates/etc/consul.d/consul.env.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONSUL_FLAGS="{{ _consul.flags|join(" ") }}"
18 changes: 18 additions & 0 deletions templates/etc/consul.d/main.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@
"datacenter": "{{ _consul.datacenter }}",
"domain": "{{ _consul.domain }}",
"data_dir": "{{ _consul.data_dir }}",
{% if _consul.bind_addr is defined %}
"bind_addr": "{{ _consul.bind_addr }}",
{% endif %}
{% if _consul.client_addr is defined %}
"client_addr": "{{ _consul.client_addr }}",
{% endif %}
{% if _consul.node_name is defined %}
"node_name": "{{ _consul.node_name }}",
{% endif %}
{% if _consul.server is defined %}
"server": {{ _consul.server | lower }},
{% endif %}
{% if _consul.raft_protocol is defined %}
"raft_protocol": {{ _consul.raft_protocol }},
{% endif %}
{% if _consul.ui is defined %}
"ui": {{ _consul.ui | lower }},
{% endif %}
"enable_local_script_checks": true,
"dns_config": {
"enable_additional_node_meta_txt": false
Expand Down
6 changes: 0 additions & 6 deletions templates/etc/default/consul.j2

This file was deleted.

0 comments on commit 2ca4cdd

Please sign in to comment.