run command on several nodes, but run another command on first node

Hi,
I want to use ansible to start MariaDB/GaleraCluster

I need to run

/usr/bin/mysqld_safe --wsrep-new-cluster &

on the one of the nodes first (there is no important it node1, or node4).

  1. next I want to run
    systemctl start mariadb
    on every other node in the cluster (excluding node from previous step).

Can ansible can help me do this, which module?

Best regards,
Kfrydrys

Hi,
I want to use ansible to start MariaDB/GaleraCluster

I need to run

1.
*/usr/bin/mysqld_safe --wsrep-new-cluster &*

Running a program in the background like that is not recommended, and I'm not sure if it will work with Ansible.
Best is to create a init script for it instead.

on the one of the nodes first (there is no important it node1, or node4).

2. next I want to run

*systemctl start mariadb * on every other node in the cluster (excluding
node from previous step).

Can ansible can help me do this, which module?

If all the hosts is in the same Ansible group, lets call the group mysqlcluster, you could do something like this.

Pseudocode

- task1
   when: inventory_hostname == mysqlcluster[0]

- task2
   when: inventory_hostname != mysqlcluster[0]

mysqlcluster[0] is the first host in the group.