Skip to content

Commit

Permalink
Fix 1.1.1 (#45)
Browse files Browse the repository at this point in the history
* fix-1.1.1: test to use shell to be able to react on several scenarios

* fix-1.3.1: test to differ return codes for status changed and fail

* fix-1.3.2: test to differ return codes for status changed and fail

* fix-1.3.6: added beng-bash

* fix-1.3.6: fixed indentation of beng-bash (hopefully fixes failed-gitgub-test)
  • Loading branch information
fmherschel authored Apr 28, 2022
1 parent f92a353 commit 168d45c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 16 deletions.
35 changes: 27 additions & 8 deletions runner/ansible/roles/checks/1.1.1/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
---

- name: "{{ name }}.check"
lineinfile:
path: /etc/corosync/corosync.conf
regexp: '^(\s*){{ key_name }}:(\s*)\S*(\s)*$'
line: '\g<1>{{ key_name }}:\g<2>{{ expected[name] }}\g<3>'
backrefs: yes
#insertafter: 'totem {'
shell: |
#!/usr/bin/bash
# test fails, if corosync.conf file is even missing
[ -f /etc/corosync/corosync.conf ] || exit 1
TOKEN=$(
perl -n -e '
while (<>) {
# filter out lines beginnig with hash sign (optionally after whitespace)
if (! /^\W*#/ ) {
$cont .= $_;
}
}
# search for all directives totem { ... }
while ($cont =~ m/\btotem\W*{[^}]*}/gs) {
my $totemStr=$&;
# filter for key value pairs for token
if ($totemStr =~ /token:\s*(\S*)\s*/g) {
print "$1";
}
}
printf "\n"' < /etc/corosync/corosync.conf
)
[[ "$TOKEN" == "{{ expected[name] }}" ]] && exit 0
exit 1
check_mode: false
register: config_updated
when:
- ansible_check_mode
changed_when: config_updated.rc != 0
failed_when: config_updated.rc > 1

- block:
- name: Post results
Expand Down
7 changes: 4 additions & 3 deletions runner/ansible/roles/checks/1.3.1/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
---

- name: "{{ name }}.check"
check_mode: false
shell: |
#!/bin/bash
[ '{{ expected[name] }}' == '@@skip@@' ] && exit 0
source /etc/sysconfig/sbd || exit 1
[ "${SBD_PACEMAKER}" == '{{ expected[name] }}' ] || exit 1
exit 0
register: config_updated
when:
- ansible_check_mode
check_mode: false
changed_when: config_updated.rc != 0
failed_when: config_updated.rc > 1

- block:
- name: Post results
Expand Down
6 changes: 4 additions & 2 deletions runner/ansible/roles/checks/1.3.2/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
source /etc/sysconfig/sbd || exit 1
[ "${SBD_STARTMODE}" == '{{ expected[name] }}' ] || exit 1
exit 0
register: config_updated
when:
- ansible_check_mode
check_mode: false
changed_when: config_updated.rc != 0
failed_when: config_updated.rc > 1

- block:
- name: Post results
Expand Down
4 changes: 1 addition & 3 deletions runner/ansible/roles/checks/1.3.6/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- name: "{{ name }}.check"
shell: |
#!/bin/bash
[ '{{ expected[name] }}' == '@@skip@@' ] && { echo '@@skip@@'; exit 0; }
if [ -f /etc/sysconfig/sbd ]; then
source /etc/sysconfig/sbd
Expand Down Expand Up @@ -38,6 +39,3 @@
- ansible_check_mode
vars:
status: "{{ config_updated is not changed }}"



0 comments on commit 168d45c

Please sign in to comment.