Skip to content

Commit

Permalink
fix: timeout replaced,pipes replaced when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelmamula committed Apr 4, 2024
1 parent 34f455c commit b81da67
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 34 deletions.
12 changes: 6 additions & 6 deletions tasks/shell_crmsh/cluster-start-and-reload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@
changed_when: false
register: __ha_cluster_crm_output_nodes
until: __ha_cluster_crm_output_nodes.stdout is regex(__ha_cluster_node_count)
# 2 minutes retry loop for cluster to initialize
retries: 12
# Retry loop for cluster to initialize
retries: 20
delay: 10
timeout: 120
# timeout: 120

- name: Wait for the cluster to show Online nodes
ansible.builtin.command:
Expand All @@ -85,10 +85,10 @@
changed_when: false
register: __ha_cluster_crm_output_online
until: __ha_cluster_crm_output_online.stdout is regex("Online:")
# 2 minutes retry loop for cluster nodes to come up
retries: 12
# Retry loop for cluster to initialize
retries: 20
delay: 10
timeout: 120
# timeout: 120

- name: Output current cluster status
ansible.builtin.debug:
Expand Down
6 changes: 4 additions & 2 deletions tasks/shell_crmsh/crm-cib-constraint-colocation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
check_mode: false
changed_when: not ansible_check_mode

# Expect module is used to combat crmsh freezing when asking for user prompt
# Expect module is used to combat crmsh freezing when asking for user input
- name: Configure colocation constraint {{ __ha_cluster_constraint_id }}
ansible.builtin.expect:
command: |
Expand Down Expand Up @@ -77,8 +77,10 @@
{% for option in constraint.options | d([]) if option.name != 'score' %}
{{ option.name | quote }}={{ option.value | quote }}
{% endfor %}
# ERROR and "Do you still want to commit (y/n)?" trigger response "n".
responses:
".*Do you still want to commit.*": "n"
".*ERROR.*": "n"
".*y/n*": "n"
check_mode: false
changed_when: not ansible_check_mode
ignore_errors: true
Expand Down
6 changes: 4 additions & 2 deletions tasks/shell_crmsh/crm-cib-constraint-location.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
check_mode: false
changed_when: not ansible_check_mode

# Expect module is used to combat crmsh freezing when asking for user prompt
# Expect module is used to combat crmsh freezing when asking for user input
- name: Configure location constraint {{ __ha_cluster_constraint_id }}
ansible.builtin.expect:
command: |
Expand Down Expand Up @@ -73,8 +73,10 @@
{% for option in constraint.options | d([]) if option.name != 'score' %}
{{ option.name | quote }}={{ option.value | quote }}
{% endfor %}
# ERROR and "Do you still want to commit (y/n)?" trigger response "n".
responses:
".*Do you still want to commit.*": "n"
".*ERROR.*": "n"
".*y/n*": "n"
check_mode: false
changed_when: not ansible_check_mode
ignore_errors: true
Expand Down
6 changes: 4 additions & 2 deletions tasks/shell_crmsh/crm-cib-constraint-order.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
check_mode: false
changed_when: not ansible_check_mode

# Expect module is used to combat crmsh freezing when asking for user prompt
# Expect module is used to combat crmsh freezing when asking for user input
- name: Configure order constraint {{ __ha_cluster_constraint_id }}
ansible.builtin.expect:
command: |
Expand All @@ -67,8 +67,10 @@
if option.name != 'score' and option.name != 'kind'%}
{{ option.name | quote }}={{ option.value | quote }}
{% endfor %}
# ERROR and "Do you still want to commit (y/n)?" trigger response "n".
responses:
".*Do you still want to commit.*": "n"
".*ERROR.*": "n"
".*y/n*": "n"
check_mode: false
changed_when: not ansible_check_mode
ignore_errors: true
Expand Down
6 changes: 4 additions & 2 deletions tasks/shell_crmsh/crm-cib-constraint-set.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
check_mode: false
changed_when: not ansible_check_mode

# Expect module is used to combat crmsh freezing when asking for user prompt
# Expect module is used to combat crmsh freezing when asking for user input
- name: Configure {{ constraint_type }} constraint set '{{
__ha_cluster_constraint_id }}' # noqa name[template]
ansible.builtin.expect:
Expand Down Expand Up @@ -82,8 +82,10 @@
{% for option in constraint.options | d([]) %}
{{ option.name | quote }}={{ option.value | quote }}
{% endfor %}
# ERROR and "Do you still want to commit (y/n)?" trigger response "n".
responses:
".*Do you still want to commit.*": "n"
".*ERROR.*": "n"
".*y/n*": "n"
check_mode: false
changed_when: not ansible_check_mode
ignore_errors: true
Expand Down
20 changes: 16 additions & 4 deletions tasks/shell_crmsh/crm-cib-constraint-ticket.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@
check_mode: false
changed_when: not ansible_check_mode

# Expect module is used to combat crmsh freezing when asking for user input
- name: Configure ticket constraint {{ __ha_cluster_constraint_id }}
ansible.builtin.command:
cmd: |
ansible.builtin.expect:
command: |
crm -c {{ __ha_cluster_crm_shadow }}
configure rsc_ticket {{ __ha_cluster_constraint_id }}
{{ constraint.ticket | quote }}:
Expand All @@ -54,7 +55,18 @@
{% for option in constraint.options | d([]) %}
{{ option.name | quote }}={{ option.value | quote }}
{% endfor %}
# crm can get stuck if it encounters error and expects prompt response.
timeout: 60
# ERROR and "Do you still want to commit (y/n)?" trigger response "n".
responses:
".*ERROR.*": "n"
".*y/n*": "n"
check_mode: false
changed_when: not ansible_check_mode
ignore_errors: true
register: __ha_cluster_crmsh_output

- name: Display crm command error details
ansible.builtin.fail:
msg: "{{ __ha_cluster_crmsh_output.stdout_lines }}"
when:
- __ha_cluster_crmsh_output is defined
- __ha_cluster_crmsh_output.rc != 0
20 changes: 16 additions & 4 deletions tasks/shell_crmsh/crm-cib-resource-clone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@
# Clone is default resource type, unless attribute ms: true is specified
# Pacemaker 2.0 deprecated use of ms, but it is still valid and supported
# solution for SAP Hana clusters on SUSE using SAPHanaSR.
# Expect module is used to combat crmsh freezing when asking for user input
- name: Configure resource clone {{ __ha_cluster_resource_id }}
ansible.builtin.command:
cmd: |
ansible.builtin.expect:
command: |
crm -c {{ __ha_cluster_crm_shadow }}
configure {% if resource_clone.ms is defined and
resource_clone.ms %} ms {% else %} clone {% endif %}
Expand All @@ -55,7 +56,18 @@
{{ attr.name | quote }}={{ attr.value | quote }}
{% endfor %}
{% endif %}
# crm can get stuck if it encounters error and expects prompt response.
timeout: 60
# ERROR and "Do you still want to commit (y/n)?" trigger response "n".
responses:
".*ERROR.*": "n"
".*y/n*": "n"
check_mode: false
changed_when: not ansible_check_mode
ignore_errors: true
register: __ha_cluster_crmsh_output

- name: Display crm command error details
ansible.builtin.fail:
msg: "{{ __ha_cluster_crmsh_output.stdout_lines }}"
when:
- __ha_cluster_crmsh_output is defined
- __ha_cluster_crmsh_output.rc != 0
20 changes: 16 additions & 4 deletions tasks/shell_crmsh/crm-cib-resource-group.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
check_mode: false
changed_when: not ansible_check_mode

# Expect module is used to combat crmsh freezing when asking for user input
- name: Configure resource group {{ resource_group.id }}
ansible.builtin.command:
cmd: |
ansible.builtin.expect:
command: |
crm -c {{ __ha_cluster_crm_shadow }} configure group
{{ resource_group.id | quote }}
{% for resource in resource_group.resource_ids %}
Expand All @@ -47,7 +48,18 @@
{{ attr.name | quote }}={{ attr.value | quote }}
{% endfor %}
{% endif %}
# crm can get stuck if it encounters error and expects prompt response.
timeout: 60
# ERROR and "Do you still want to commit (y/n)?" trigger response "n".
responses:
".*ERROR.*": "n"
".*y/n*": "n"
check_mode: false
changed_when: not ansible_check_mode
ignore_errors: true
register: __ha_cluster_crmsh_output

- name: Display crm command error details
ansible.builtin.fail:
msg: "{{ __ha_cluster_crmsh_output.stdout_lines }}"
when:
- __ha_cluster_crmsh_output is defined
- __ha_cluster_crmsh_output.rc != 0
20 changes: 16 additions & 4 deletions tasks/shell_crmsh/crm-cib-resource-primitive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
check_mode: false
changed_when: not ansible_check_mode

# Expect module is used to combat crmsh freezing when asking for user input
- name: Configure resource primitive {{ resource.id }}
ansible.builtin.command: # noqa jinja[spacing]
cmd: |
ansible.builtin.expect: # noqa jinja[spacing]
command: |
crm -c {{ __ha_cluster_crm_shadow }} configure primitive
{{ resource.id | quote }} {{ resource.agent | quote }} \
{% if resource.instance_attrs[0].attrs | default(False) %}
Expand Down Expand Up @@ -49,7 +50,18 @@
{% endif %}
{% endfor %}
{% endif %}
# crm can get stuck if it encounters error and expects prompt response.
timeout: 60
# ERROR and "Do you still want to commit (y/n)?" trigger response "n".
responses:
".*ERROR.*": "n"
".*y/n*": "n"
check_mode: false
changed_when: not ansible_check_mode
ignore_errors: true
register: __ha_cluster_crmsh_output

- name: Display crm command error details
ansible.builtin.fail:
msg: "{{ __ha_cluster_crmsh_output.stdout_lines }}"
when:
- __ha_cluster_crmsh_output is defined
- __ha_cluster_crmsh_output.rc != 0
20 changes: 17 additions & 3 deletions tasks/shell_crmsh/crm-cib-stonith-level.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
# Delete fencing_topology in Shadow CIB to avoid errors during cibadmin patch.
- name: Delete clone if it is already present
ansible.builtin.command:
cmd: |
cmd: >-
crm --force -c {{ __ha_cluster_crm_shadow }}
configure delete fencing_topology
when: __ha_cluster_resource_status.rc == 0
check_mode: false
changed_when: not ansible_check_mode

# Expect module is used to combat crmsh freezing when asking for user input
- name: Configure fencing_topology
ansible.builtin.command:
cmd: >
ansible.builtin.expect:
command: >-
crm -c {{ __ha_cluster_crm_shadow }} configure fencing_topology
{% for stonith_level in ha_cluster_stonith_levels -%}
{% if stonith_level.target | d() %}
Expand All @@ -34,5 +35,18 @@
{{ resource_id | quote }}
{% endfor %}
{% endfor %}
# ERROR and "Do you still want to commit (y/n)?" trigger response "n".
responses:
".*ERROR.*": "n"
".*y/n*": "n"
check_mode: false
changed_when: not ansible_check_mode
ignore_errors: true
register: __ha_cluster_crmsh_output

- name: Display crm command error details
ansible.builtin.fail:
msg: "{{ __ha_cluster_crmsh_output.stdout_lines }}"
when:
- __ha_cluster_crmsh_output is defined
- __ha_cluster_crmsh_output.rc != 0
2 changes: 1 addition & 1 deletion tasks/shell_crmsh/crm-cluster-properties.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
---
- name: Configure cluster properties set
ansible.builtin.command:
cmd: |
cmd: >-
crm -c {{ __ha_cluster_crm_shadow }}
configure property {{ item.name | quote }}={{ item.value | quote }}
loop: "{{ properties_set.attrs }}"
Expand Down

0 comments on commit b81da67

Please sign in to comment.