Created
May 3, 2018 15:28
-
-
Save jmlrt/3eba47e8b8615ab3df72c35aa66c1cf8 to your computer and use it in GitHub Desktop.
Ansible Cloudformation Stack Update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# playbook_cf_stack_update.yml | |
# update an existing cloudformation stack by changing only the parameters specified into updated_params dict variable | |
- hosts: localhost | |
connection: local | |
gather_facts: False | |
vars: | |
stack_name: stack-to-update | |
stack_region: us-east-1 | |
stack_template: ./files/stack-to-update.json | |
updated_params: | |
- param-to-update: new-value | |
- other-param-to-update: new-value | |
tasks: | |
- name: retrieve stack facts | |
cloudformation_facts: | |
stack_name: "{{ stack_name }}" | |
stack_resources: true | |
check_mode: no | |
- name: update cloudformation stack | |
cloudformation: | |
stack_name: "{{ stack_name }}" | |
state: "present" | |
region: "{{ stack_region }}" | |
template: "{{ stack_template }}" | |
template_parameters: "{{ ansible_facts.cloudformation[stack_name].stack_parameters | combine(updated_params)}}" | |
- name: show stack status | |
debug: | |
msg: "{{ ansible_facts.cloudformation[stack_name].stack_description.stack_status }}" | |
- name: show stack params | |
debug: | |
msg: "{{ ansible_facts.cloudformation[stack_name].stack_parameters }}" | |
- name: show stack outputs | |
debug: | |
msg: "{{ ansible_facts.cloudformation[stack_name].stack_outputs }}" | |
- name: show stack resources | |
debug: | |
msg: "{{ ansible_facts.cloudformation[stack_name].stack_resources }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment