Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

undefined variable 'env' #3

@namebrandon

Description

@namebrandon

Details
Not using galaxy, just adding the code as a role directly. Using the built in test command I get the below error (I see this same error when using aws-sts as a role in my playbook)

This is with Amazon Linux 2, not sure if it's relevant. Ansible was installed via pip ==2.5 --user

command
ansible-playbook test.yml -e Sts.Role=arn:aws:iam::000000000:role/analytics-ec2-provision-instance-profile

output
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'env' is undefined\n\nThe error appears to have been in '/home/ec2-user/sts_ec2/roles/aws-sts/tasks/main.yml': line 3, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n- block:\n - name: create sts variable\n ^ here\n"}

environment info
[ec2-user@ip-172-31-51-166 aws-sts]$ aws --version
aws-cli/1.14.8 Python/2.7.14 Linux/4.14.47-64.38.amzn2.x86_64 botocore/1.8.12.

[ec2-user@ip-172-31-51-166 aws-sts]$ pip --version
pip 10.0.1 from /home/ec2-user/.local/lib/python2.7/site-packages/pip (python 2.7).

[ec2-user@ip-172-31-51-166 aws-sts]$ python --version
Python 2.7.14.

[ec2-user@ip-172-31-51-166 aws-sts]$ ansible --version
ansible 2.5.0.
config file = None.
configured module search path = [u'/home/ec2-user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'].
ansible python module location = /home/ec2-user/.local/lib/python2.7/site-packages/ansible
executable location = /home/ec2-user/.local/bin/ansible.
python version = 2.7.14 (default, Mar 16 2018, 18:20:07) [GCC 7.2.1 20170915 (Red Hat 7.2.1-2)].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions