Advertisement
cetex

ansible_variable_includes

Nov 24th, 2019
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. # deploy-all.yml:
  2. ---
  3. - hosts: localhost
  4. gather_facts: false
  5. tasks:
  6. - name: include region list
  7. include_vars: "{{ playbook_dir }}/config/{{ env | mandatory }}/regions.yml"
  8. - add_host:
  9. name: "{{ item }}"
  10. group: aws_regions
  11. region: "{{ item }}"
  12. with_items: "{{ Regions }}"
  13.  
  14.  
  15. - hosts: aws_regions
  16. connection: local
  17. gather_facts: false
  18. tasks:
  19. - name: "include service list"
  20. include_vars: "{{ playbook_dir}}/config/common.yml"
  21.  
  22. - name: "Include and deploy templates"
  23. include_role:
  24. name: "{{ item.type }}"
  25. vars:
  26. name: "{{ item.name }}"
  27. env: "{{ item.env }}"
  28. with_items: "{{ services }}"
  29.  
  30. -------------------------------------------------------
  31. # roles/cloudformation/tasks/main.yml
  32. ---
  33.  
  34. - name: include common vars
  35. include_vars: "{{ playbook_dir }}/config/{{ env | mandatory }}/common.yml"
  36.  
  37. - name: include vars
  38. include_vars: "{{ playbook_dir }}/config/{{ env | mandatory }}/{{ name | mandatory }}.yml"
  39. # This file might contain the variable "whitelist", it seems like it's not unset when the role is re-run.
  40. # so if configfile "a.yml" contains whitelist, the following task inlcuding "b.yml" will not overwrite it.
  41.  
  42. - name: "Create or update a cloudformation stack for {{ name }}"
  43. cloudformation:
  44. stack_name: "{{ name }}"
  45. state: "present"
  46. region: "{{ inventory_hostname }}"
  47. template: "{{ playbook_dir }}/../cloudformation/{{ taskvars.Template }}"
  48. template_parameters: "{{ TemplateParams }}"
  49. when: whitelist is not defined or (whitelist is defined and inventory_hostname in whitelist)
  50. register: stack
  51. async: 900
  52. poll: 0
  53.  
  54. - name: "Wait for stack to finish for {{ name }}"
  55. async_status:
  56. jid: "{{ stack.ansible_job_id }}"
  57. register: jobs
  58. until: jobs.finished
  59. delay: 5
  60. retries: 200
  61. when: whitelist is not defined or (whitelist is defined and inventory_hostname in whitelist)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement