Interview Prep/Ansible/YAML, Syntax and Jinja2 Errors

`Unexpected templating type error occurred on ({{ base_port + port_offset }}): unsupported operand type(s) for +: 'int' and 'str'`

IntermediateTroubleshootingYAML, Syntax and Jinja2 Errors
Answer

Likely causes → One of the operands is a string. It came from -e port_offset=10, an AWX survey text field, a lookup('env', ...) or stdout.

Fix →

listen_port: "{{ base_port | int + port_offset | int }}"

For lists, + needs a list on both sides: "{{ list_a + [single_item] }}".

Prevent → Cast at the boundary where data enters the playbook (| int, | bool, | from_json), and declare type: int in meta/argument_specs.yml.

All Ansible questions Roadmap: Ansible

More on YAML, Syntax and Jinja2 Errors