Ansible - task serial 1 reverse order

Viewed 7273

I'd like to create two playbooks, one to stop an environment, another to start it.

Part of the environment is a RabbitMQ cluster, for which stop/start order is quite important, specifically the last node stopped needs to be the first node started.

I was wondering if there is a way to specify a reverse order for running a task against a group. That way I could apply the stop with serial 1, and the start with serial 1 and reverse group order.

I haven't found a way to do that but to define the rabbitmq host group twice (under different names), in inverted order, which seems a bit distasteful.

Also attempted following:

- hosts: "{ myhostsgroup | sort(reverse=False) }"
  serial: 1

And

- hosts: "{ myhostsgroup | reverse }"
  serial: 1

But result stays the same, whichever case and its variation (reverse=True, reverse|list) is attempted

Any help would be greatly appreciated.

1 Answers
Related