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

41 views
Skip to first unread message

kfrydrys ILIM

unread,
Jul 28, 2016, 2:32:43 PM7/28/16
to Ansible Project
Hi,
I want to use ansible to start MariaDB/GaleraCluster

I need to run

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

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?

Best regards,
Kfrydrys

Kai Stian Olstad

unread,
Jul 29, 2016, 3:59:58 AM7/29/16
to ansible...@googlegroups.com
On 28.07.2016 16:55, kfrydrys ILIM wrote:
> 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.


--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages