How Do You Troubleshoot the Ansible Error “This task includes an option with an undefined variable”?

Problem scenario
You have a playbook, and your variables are defined. But you get an error "FAILED => {'msg": 'The task includes an option with an undefined variable. The error was 'dict object' has no attribute 'Name'…"

What do you do to solve this?

The variable's source could be blank. With "ec2_instance_info" the module will connect to AWS. If an EC-2 server has not been named in the web console, the item.tags.Name variable in Ansible will be blank. This error message may give you the idea that something else is wrong. The playbook may be fine, it just relies on EC-2 servers having a name in the web console (as opposed to a hostname at the OS level). Give the EC-2 instance a name in the AWS web console.

Leave a comment

Your email address will not be published. Required fields are marked *