From 238449904f0ef2bd158cab917f323ca6e9d69bdb Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Thu, 13 May 2021 10:14:57 -0400 Subject: [PATCH] Move some other tasks to bootstrap role Avoids an issue where the pvcnoded service is stopped on non-bootstrap runs. --- roles/pvc/handlers/main.yml | 5 ++++ roles/pvc/tasks/pvc/bootstrap.yml | 19 ++++++++++++++++ roles/pvc/tasks/pvc/main.yml | 38 +++++++++++++++---------------- 3 files changed, 42 insertions(+), 20 deletions(-) diff --git a/roles/pvc/handlers/main.yml b/roles/pvc/handlers/main.yml index e03c411..e920d0e 100644 --- a/roles/pvc/handlers/main.yml +++ b/roles/pvc/handlers/main.yml @@ -44,3 +44,8 @@ shell: "{% if is_coordinator %}sleep {{ 15 * (hostvars[inventory_hostname].ansible_local.host_id|int - 1) }} &&{% endif %} systemctl restart pvcnoded.service" ignore_errors: true when: bootstrap is not defined + +- name: restart pvcapid + shell: "{% if is_coordinator %}sleep {{ 15 * (hostvars[inventory_hostname].ansible_local.host_id|int - 1) }} &&{% endif %} systemctl restart pvcapid.service" + ignore_errors: true + when: bootstrap is not defined diff --git a/roles/pvc/tasks/pvc/bootstrap.yml b/roles/pvc/tasks/pvc/bootstrap.yml index 800e317..ef8a27c 100644 --- a/roles/pvc/tasks/pvc/bootstrap.yml +++ b/roles/pvc/tasks/pvc/bootstrap.yml @@ -30,3 +30,22 @@ - name: remove floating IP address to upstream interface command: ip address delete {{ pvc_upstream_floatingip }}/{{ pvc_upstream_netmask }} dev {{ pvc_upstream_device }} ignore_errors: yes + +- name: stop and disable unneccessary services + service: + name: "{{item }}" + state: stopped + enabled: no + with_items: + - pdns.service + - dnsmasq.service + +- name: ensure services are enabled but stopped pending reboot + service: + name: "{{ item }}" + state: stopped + enabled: yes + with_items: + - pvc-flush.service + - pvcnoded.service + - pvc.target diff --git a/roles/pvc/tasks/pvc/main.yml b/roles/pvc/tasks/pvc/main.yml index f4bb22e..52ed79f 100644 --- a/roles/pvc/tasks/pvc/main.yml +++ b/roles/pvc/tasks/pvc/main.yml @@ -11,7 +11,7 @@ - jq state: latest -- name: install pvc configurations +- name: install pvc node daemon configuration template: src: pvc/{{ item }}.j2 dest: /etc/pvc/{{ item }} @@ -19,6 +19,14 @@ - restart pvcnoded with_items: - pvcnoded.yaml + +- name: install pvc api daemon configuration + template: + src: pvc/{{ item }}.j2 + dest: /etc/pvc/{{ item }} + notify: + - restart pvcapid + with_items: - pvcapid.yaml - name: install API SSL certificate file @@ -37,29 +45,10 @@ no_log: True when: pvc_api_enable_ssl and not pvc_api_ssl_key_path -- name: stop and disable unneccessary services - service: - name: "{{item }}" - state: stopped - enabled: no - with_items: - - pdns.service - - dnsmasq.service - - include: pvc/bootstrap.yml run_once: yes when: bootstrap is defined and bootstrap and is_coordinator -- name: enable daemon services but don't start them - service: - name: "{{ item }}" - state: stopped - enabled: yes - with_items: - - pvc-flush.service - - pvcnoded.service - - pvc.target - - name: install daily vacuum script template: src: pvc/pvc-vacuum.j2 @@ -67,3 +56,12 @@ mode: 0755 - meta: flush_handlers + +- name: ensure services are started and running + service: + name: "{{ item }}" + state: started + enabled: yes + with_items: + - pvcnoded + when: bootstrap is not defined or not bootstrap