Ansible - task serial 1 reverse order -
i'd create 2 playbooks, 1 stop environment, start it.
part of environment rabbitmq cluster, stop/start order quite important, last node stopped needs first node started.
i wondering if there way specify reverse order running task against group. way apply stop serial 1, , start serial 1 , reverse group order.
i haven't found way define rabbitmq host group twice (under different names), in inverted order, seems bit distasteful.
also attempted following:
- hosts: "{ myhostsgroup | sort(reverse=false) }" serial: 1
and
- hosts: "{ myhostsgroup | reverse }" serial: 1
but result stays same, whichever case , variation (reverse=true, reverse|list) attempted
any appreciated.
you can create dynamic groups in runtime:
--- - hosts: localhost gather_facts: no tasks: - add_host: name: "{{ item }}" group: forward with_items: "{{ groups['mygroup'] }}" - add_host: name: "{{ item }}" group: backward with_items: "{{ groups['mygroup'] | reverse | list }}" - hosts: forward gather_facts: no serial: 1 tasks: - debug: - hosts: backward gather_facts: no serial: 1 tasks: - debug:
Comments
Post a Comment