5

I'm trying to update a cloudformation stack with just a param value that I need to change via Ansible. The stack is previously created and has about 20 input params, but I just need to update the value for one. I tried the following:

- name: update
  cloudformation:
    stack_name: "{{ stack_name }}"
    state: present
    region: "{{ region }}"
    disable_rollback: false
  args:
    template_parameters:
      CreateAlarms: "{{ create_alarms }}"

When I run it, the play throws an error stating that it expects values for the other template params. From the ansible documentation here http://docs.ansible.com/ansible/latest/cloudformation_module.html, it says "If state is present, the stack does exist, and neither template nor template_url is specified, the previous template will be reused." How do I tell the cloudformation module to use previous values as well? I know that aws cli supports it via the usePreviousValue flag, but how I do it with Ansible cloudformation?

Thanks in advance.

Hussain K
  • 613
  • 8
  • 16
  • Hi as on cli, you need to push all the "required" parameters to cloudformation while creating/updating the stack. On the CLI you can use `ParameterKey=KeyPair,UsePreviousValue=true ` to don't change the parameter. But on ansible, I couldn't find a configuration like that. – Muhammet Arslan Feb 01 '18 at 06:06

1 Answers1

3

author/maintainer of the current Ansible cloudformation module here. There isn't a method to reuse previous values, you must specify the parameters every time. Usually that's fine because you have your params stored in your Ansible playbook anyhow.

If you're nervous, the values are listed in the cloudformation console, and you can also use changesets in Ansible to make sure only the expected are changing.

tedder42
  • 23,519
  • 13
  • 86
  • 102
  • Thanks @tedder42. Unfortunately, I do not have the params in the ansible playbook. The stack was created via a separate playbook. We have another playbook which is run on demand which needs to change just a single param, it doesnt really care about what the other values were. – user2755442 Feb 01 '18 at 20:27
  • Right, I'm saying you can copy the params from the AWS console to Ansible. Or remove Ansible from the process- it's designed to *assert* your configuration, not simply to make one-off changes. – tedder42 Feb 01 '18 at 20:53