Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # deploy-all.yml:
- ---
- - hosts: localhost
- gather_facts: false
- tasks:
- - name: include region list
- include_vars: "{{ playbook_dir }}/config/{{ env | mandatory }}/regions.yml"
- - add_host:
- name: "{{ item }}"
- group: aws_regions
- region: "{{ item }}"
- with_items: "{{ Regions }}"
- - hosts: aws_regions
- connection: local
- gather_facts: false
- tasks:
- - name: "include service list"
- include_vars: "{{ playbook_dir}}/config/common.yml"
- - name: "Include and deploy templates"
- include_role:
- name: "{{ item.type }}"
- vars:
- name: "{{ item.name }}"
- env: "{{ item.env }}"
- with_items: "{{ services }}"
- -------------------------------------------------------
- # roles/cloudformation/tasks/main.yml
- ---
- - name: include common vars
- include_vars: "{{ playbook_dir }}/config/{{ env | mandatory }}/common.yml"
- - name: include vars
- include_vars: "{{ playbook_dir }}/config/{{ env | mandatory }}/{{ name | mandatory }}.yml"
- # This file might contain the variable "whitelist", it seems like it's not unset when the role is re-run.
- # so if configfile "a.yml" contains whitelist, the following task inlcuding "b.yml" will not overwrite it.
- - name: "Create or update a cloudformation stack for {{ name }}"
- cloudformation:
- stack_name: "{{ name }}"
- state: "present"
- region: "{{ inventory_hostname }}"
- template: "{{ playbook_dir }}/../cloudformation/{{ taskvars.Template }}"
- template_parameters: "{{ TemplateParams }}"
- when: whitelist is not defined or (whitelist is defined and inventory_hostname in whitelist)
- register: stack
- async: 900
- poll: 0
- - name: "Wait for stack to finish for {{ name }}"
- async_status:
- jid: "{{ stack.ansible_job_id }}"
- register: jobs
- until: jobs.finished
- delay: 5
- retries: 200
- when: whitelist is not defined or (whitelist is defined and inventory_hostname in whitelist)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement