overexchange
overexchange

Reputation: 1

ansible - Incorrect type. Expected "object"

site.yaml

---
- name: someapp deployment playbook
  hosts: localhost
  connection: local
  gather_facts: no
  vars_files:
    - secrets.yml
  environment:
    AWS_DEFAULT_REGION: "{{ lookup('env', 'AWS_DEFAULT_VERSION') | default('ca-central-1', true) }}"
  tasks:
    - include: tasks/create_stack.yml
    - include: tasks/deploy_app.yml

create_stack.yml

---
- name: task to create/update stack
  cloudformation:
    stack_name: someapp
    state: present
    template: templates/stack.yml
    template_format: yaml
    template_parameters:
      VpcId: "{{ vpc_id }}"
      SubnetId: "{{ subnet_id }}"
      KeyPair: "{{ ec2_keypair }}"
      InstanceCount: "{{ instance_count | default(1) }}"
      DbSubnets: "{{ db_subnets | join(',') }}"
      DbAvailabilityZone: "{{ db_availability_zone }}"
      DbUsername: "{{ db_username }}"
      DbPassword: "{{ db_password }}"
    tags:
      Environment: test
  register: cf_stack

- name: task to output stack output
  debug: msg={{ cf_stack }}
  when: debug is defined

Error at line debug: msg={{ cf_stack }} saying:

This module prints statements during execution and can be useful for debugging variables or expressions without necessarily halting the playbook. Useful for debugging together with the 'when:' directive.

This module is also supported for Windows targets.

Incorrect type. Expected "object".

Ansible documentation allows the above syntax, as shown here

$ ansible --version
ansible 2.5.1
....

How to resolve this error?

Upvotes: 2

Views: 2701

Answers (1)

Matt P
Matt P

Reputation: 2615

You still need to remember quotes for lines starting with a {, even when using short-hand notation:

- debug: msg="{{ cf_stack }}"

This would be more obvious using full YAML notation:

- debug:
    msg: "{{ cf_stack }}"

Also, given this is a variable, you could just do:

-  debug:
     var: cf_stack

Upvotes: 1

Related Questions