Hello guys !

I have the following role created:

- name: Recover
  block:
    - name: Starts the first node of the cluster in bootstrap mode
      shell: /etc/init.d/mysql bootstrap-pxc
      when: inventory_hostname == groups.CD5525[0]
      become: yes
      register: return_out

    - name: Start the rest of nodes
      systemd:
        state: started
        name: mysql
      when: inventory_hostname != groups.CD5525[0]
      become: yes
      register: screen_out

    - name: Stop the bootstrapped node to restart it in normal state
      shell: service mysql bootstrap-stop
      when: inventory_hostname == groups.CD5525[0]
      become: yes
      register: screen_out

    - name: Start the first node in normal status
      systemd:
        state: started
        name: mysql
      when: inventory_hostname == groups.CD5525[0]
      become: yes
      register: screen_out

  rescue:
    - name: Print when errors
      debug:
        msg: "Found an error, can not continue ! {{ansible_failed_task}}"

  any_errors_fatal: true


I have three nodes. 
I need to control the failure on the first node but the rescue section is 
not executed until I receive failures from all the nodes.

Went through the documentation and different posts but did not find a 
conclusion about how this works with more than one node or, perhaps, I'm 
doing something wrong.

Your comments are welcome, thank you.

This is the output:

TASK [CD-5525 : Starts the first node of the cluster in bootstrap mode] 
************************************************************
skipping: [xxx.xx.xxx.xx]
skipping: [xxx.xx.xxx.xx]
fatal: [xxx.xx.xxx.xx]: FAILED! => {"ansible_facts": 
{"discovered_interpreter_python": "/usr/bin/python"}, "changed": true, 
"cmd": "/etc/init.d/mysql bootstrap-pxc", "delta": "0:00:10.059969", "end": 
"2022-04-08 04:45:07.890197", "msg": "non-zero return code", "rc": 1, 
"start": "2022-04-08 04:44:57.830228", "stderr": "", "stderr_lines": [], 
"stdout": " * Bootstrapping Percona XtraDB Cluster database server mysqld\n 
* The server quit without updating PID file (/var/run/mysqld/mysqld.pid).\n 
  ...fail!", "stdout_lines": [" * Bootstrapping Percona XtraDB Cluster 
database server mysqld", " * The server quit without updating PID file 
(/var/run/mysqld/mysqld.pid).", "   ...fail!"]}

TASK [CD-5525 : Start the rest of nodes] 
*******************************************************************************************
fatal: [xxx.xx.xxx.xx]: FAILED! => {"ansible_facts": 
{"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, 
"msg": "Unable to start service mysql: Job for mysql.service failed because 
the control process exited with error code.\nSee \"systemctl status 
mysql.service\" and \"journalctl -xe\" for details.\n"}
fatal: [xxx.xx.xxx.xx]: FAILED! => {"ansible_facts": 
{"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, 
"msg": "Unable to start service mysql: Job for mysql.service failed because 
the control process exited with error code.\nSee \"systemctl status 
mysql.service\" and \"journalctl -xe\" for details.\n"}

TASK [CD-5525 : Print when errors] 
*************************************************************************************************
ok: [xxx.xx.xxx.xx] => {
...
...

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/bc1296f5-a4f8-4761-91c7-27e197a02f55n%40googlegroups.com.

Reply via email to