============================
- name: Create/Destroy instance
hosts: localhost
vars:
cmd_sequence: [ "projects.yml", "members.yml", "groups.yml", "rules.yml", "networks.yml", "subnets.yml", "ports.yml", "servers.yml", "router.yml", "properties.yml" ]
tasks:
- name: DESTROY Instance from the Cloud
vars:
task_name: "tasks/{{ item }}"
include_tasks: "{{ task_name }}"
with_items:
- "{{ cmd_sequence[::-1] }}"
when: deploytype=="DESTROY"
- name: CREATE Instance in the Cloud
vars:
task_name: "tasks/{{ item }}"
include_tasks: "{{ task_name }}"
with_items:
- "{{ cmd_sequence }}"
when: deploytype=="CREATE"
=============================