I am running into an issue with Ansible 2.9 where I get the following error after the ec2 instance is created and before it tries to run apt update on that instance the first time around using the playbook I created:
[WARNING]: Could not match supplied host pattern, ignoring: tag_type_master
Yet when I run it the second time, it does find the host matching that tag and continues on with running the apt update and the rest of the playbook tasks.
Here is the command I am running:
ansible-playbook deploy.yaml --private-key ../../../../../Downloads/XXXXXXX.pem --inventory=inventory_aws_ec2.yaml
Here is my deploy.yaml file:
- name: Build out AWS Infrastructure
hosts: localhost
connection: local
gather_facts: False
roles:
- role: aws
- name: Setup Master
hosts: tag_type_master
remote_user: ubuntu
become: yes
roles:
- role: master
- name: Build Master AMI
hosts: localhost
connection: local
roles:
- role: master_ami
Here is my inventory_aws_ec2.yaml file:
plugin: aws_ec2
regions:
- us-east-2
keyed_groups:
- key: tags.type
prefix: tag_type_
separator: ""
hostnames:
- dns-name
compose:
ansible_host: dns-name
cache: yes
cache_plugin: memory
cache_timeout: 7200
cache_prefix: aws_ec2
And here is my ansible.cfg file:
[defaults]
host_key_checking = False
fact_caching = memory
cache_timeout = 3600
[inventory_aws_ec2]
enable_plugins = aws_ec2
cache = yes
Is there something that I am missing? Thanks in advance!
UPDATE:
I am also able to run the ansible-inventory
command without any issues, and it gives me the expected results:
ansible-inventory -i inventory_aws_ec2.yaml --graph
@all:
|--@aws_ec2:
| |--ec2-XX-XX-XX-XX.us-east-2.compute.amazonaws.com
| |--ec2-XX-XX-XX-XX.us-east-2.compute.amazonaws.com
| |--ec2-XX-XX-XX-XX.us-east-2.compute.amazonaws.com
| |--ec2-XX-XX-XX-XX.us-east-2.compute.amazonaws.com
| |--ec2-XX-XX-XX-XX.us-east-2.compute.amazonaws.com
| |--ec2-XX-XX-XX-XX.us-east-2.compute.amazonaws.com
|--@tag_type_master:
| |--ec2-XX-XX-XX-XX.us-east-2.compute.amazonaws.com
|--@ungrouped: