Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Story 10070: Deliver Consul systemd script with ansible. #1462

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions deployment/roles/consul/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
---

- name: restart consul
service:
- name: "consul - restart service"
systemd:
name: "{{ consul.service_name | default('vitam-consul') }}"
state: restarted

- name: reload consul
service:
name: "{{ consul.service_name | default('vitam-consul') }}"
state: reloaded
daemon_reload: yes
35 changes: 23 additions & 12 deletions deployment/roles/consul/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,16 @@
retries: "{{ packages_install_retries_number }}"
until: result is succeeded
delay: "{{ packages_install_retries_delay }}"
notify:
- restart consul
notify: "consul - restart service"

- name: Deploy systemd service file for vitam-consul
template:
src: vitam-consul.service.j2
dest: "{{ '/lib/systemd/system' if ansible_os_family == 'Debian' else '/usr/lib/systemd/system' }}/vitam-consul.service"
owner: root
group: root
mode: "0644"
notify: "consul - restart service"

- name: rustine VITAMUI ensure vitam user is member of vitamui group
user:
Expand All @@ -37,20 +45,25 @@
- log
- data
- tmp
notify:
- restart consul
notify: "consul - restart service"

- name: Deploy consul sysconfig file
template:
src: sysconfig.j2
dest: "{{ consul_folder_conf }}/sysconfig"
owner: "{{ vitam_defaults.users.vitam }}"
group: "{{ vitam_defaults.users.group }}"
mode: "{{ vitam_defaults.folder.conf_permission }}"
notify: "consul - restart service"

- name: Deploy consul common configuration files
template:
src: "{{ item }}.j2"
dest: "{{ consul.conf_folder | default('/vitam/conf/consul') }}/{{ item }}"
src: consul.json.j2
dest: "{{ consul.conf_folder | default('/vitam/conf/consul') }}/consul.json"
owner: "{{ vitam_defaults.users.vitam }}"
group: "{{ vitamui_defaults.users.group | default('vitamui') }}"
mode: "{{ vitamui_defaults.folder.conf_permission | default('0440') }}"
with_items:
- "consul.json"
notify:
- reload consul
notify: "consul - restart service"

# Ensure that the installation is complete and consul up before setting up the system-wide dns resolver...
- meta: flush_handlers
Expand All @@ -72,8 +85,6 @@
nameserver 127.0.0.1
when: inventory_hostname not in single_vm_hostnames

- meta: flush_handlers

- name: Wait for consul port to be open
wait_for:
host: "127.0.0.1"
Expand Down
3 changes: 3 additions & 0 deletions deployment/roles/consul/templates/sysconfig.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CMD_OPTS="agent -config-dir={{ vitam_defaults.folder.root_path }}/conf/consul -data-dir={{ vitam_defaults.folder.root_path }}/data/consul"
CONSUL_UI_BETA=true
#GOMAXPROCS=4
18 changes: 18 additions & 0 deletions deployment/roles/consul/templates/vitam-consul.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Unit]
Description=Consul is a distributed, highly-available, and multi-datacenter aware tool for service discovery, configuration, and orchestration.
Documentation=http://www.consul.io
After=network-online.target
Wants=network-online.target

[Service]
User={{ vitam_defaults.users.vitam }}
Group={{ vitam_defaults.users.group }}
EnvironmentFile=-{{ vitam_defaults.folder.root_path }}/conf/consul/sysconfig
ExecStart={{ vitam_defaults.folder.root_path }}/bin/consul/consul $CMD_OPTS
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGINT
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE #KWA: doesn't seem to do anything...
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target