Reputation: 584
I am using the Ansible EC2 Dynamic Inventory script to auto-generate groups.
This creates Ansible group ec2
, that encompases all EC2 hosts in my AWS account.
A subset of those hosts have tag KubernetesCluster:kube-acceptance
. The dynamic inventory script creates a group tag_KubernetesCluster_kube_acceptance
.
I would like to construct an Ansible group including all hosts in group ec2
, but excluding those in group tag_KubernetesCluster_kube_acceptance
.
Can this be achieved in an inventory file?
Upvotes: 2
Views: 1962
Reputation: 59989
Do you really need to create such a group or do you just want to use the resulting hosts in a playbook as described in your question?
A hosts definition in your play like this should do the latter:
- hosts: ec2:!tag_KubernetesCluster_kube_acceptance
tasks: ...
Upvotes: 1