Run pcs command only if the pacemaker service is active

This patch checks first if the pacemaker service is active on the Controller
before to run 'pcs status xml' command. This will avoid the validation to fail
miserably on a non-HA deployment.

Change-Id: I10e5d11f929f3b0fce02d5e82437aca9d35cf271
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
This commit is contained in:
Gael Chamoulaud 2018-11-27 17:40:10 +01:00
parent b9eedacdb6
commit 216788c320
1 changed files with 15 additions and 6 deletions

View File

@ -12,10 +12,19 @@
groups:
- post-deployment
tasks:
- name: Get pacemaker status
become: true
command: pcs status xml
register: pcs_status
- name: Check pacemaker service is running
become: True
command: "/usr/bin/systemctl show pacemaker --property ActiveState"
register: check_service
changed_when: False
- name: Check pacemaker status
pacemaker: status="{{ pcs_status.stdout }}"
ignore_errors: True
- when: "check_service.stdout == 'ActiveState=active'"
block:
- name: Get pacemaker status
become: true
command: pcs status xml
register: pcs_status
changed_when: False
- name: Check pacemaker status
pacemaker: status="{{ pcs_status.stdout }}"