Hi everyone,
I need some help troubleshooting a persistent NoneType error when trying to use the aws_ec2 inventory plugin combined with the amazon.aws.aws_ssm connection plugin.
I have already verified my AWS infrastructure side:
- The EC2 instance has full network connectivity to the SSM endpoints (tested via
curlfrom inside the instance). - The IAM Role attached to the EC2 instance is fully active (
Attached entities: 1) and includesAmazonSSMManagedInstanceCorealong with explicit permissions forssm:SendCommand,ssm:GetCommandInvocation,ssm:ListCommandInvocations, andssm:CancelCommand. - My local AWS credentials have full Administrator access.
Despite having the network and IAM permissions correctly configured, the ad-hoc ping command fails immediately. It shows a warning about a reserved variable name tags right before throwing the NoneType exception.
Steps to reproduce:
- Set up an
aws_ec2inventory file usingkeyed_groupsto organize instances by their AWS tags. - Configure the connection plugin to use
amazon.aws.aws_ssm. - Run the ad-hoc command:
ansible -i inventories/aws_ec2.yml all -m ping
My Current Inventory Configuration (inventories/aws_ec2.yml):
plugin: amazon.aws.aws_ec2
regions:
- us-east-1
keyed_groups:
- key: tags
prefix: tag
compose:
ansible_connection: “amazon.aws.aws_ssm”
ansible_aws_ssm_region: “us-east-1”
ansible_user: “ssm-user”
Relevant Logs & Error Output:
renatomadeiamuiambo@Waka-Muiambo-2 ansible % ansible -i inventories/aws_ec2.yml all -m ping
[WARNING]: Found variable using reserved name ‘tags’.
Origin:
tags
[ERROR]: Task failed: expected string or bytes-like object, got ‘NoneType’
Origin: <adhoc ‘ping’ task>
{‘action’: ‘ping’, ‘args’: {}, ‘timeout’: 0, ‘async_val’: 0, ‘poll’: 15}
ec2-3-90-239-179.compute-1.amazonaws.com | FAILED! => {
“changed”: false,
“msg”: “Task failed: expected string or bytes-like object, got ‘NoneType’”
}