![]() # demo.aws_ec2.yml plugin : _ec2 regions : - us-east-1 - us-east-2 keyed_groups : # add hosts to tag_Name_value groups for each aws_ec2 host's tags.Name variable - key : tags.Name prefix : tag_Name_ separator : "" # If you have a tag called "Role" which has the value "Webserver", this will add the group # role_Webserver and add any hosts that have that tag assigned to it. Here is an aws_ec2 example utilizing constructed features: The option groups can also be used to create groups and compose creates and modifies host variables. You can create dynamic groups using host variables with the constructed keyed_groups option. ![]() Otherwise, you can use -i with multiple sources to impose a specific order, for example -i demo.aws_ec2.yml -i clouds.yml -i constructed.yml. Inventory plugins that extend constructed features directly can work around that restriction by adding constructed options in addition to the inventory plugin options. You cannot configure the parsing approach, so name your files to make it work predictably. Ansible parses the directory recursively, alphabetically. The constructed inventory plugin only operates on those hosts already in inventory, so you may want the constructed inventory configuration parsed at a particular point (such as last). Your inventory source might be a directory of inventory configuration files. If you are using an inventory plugin in a playbook-adjacent collection and want to test your setup with ansible-inventory, use the -playbook-dir flag. Controlling how Ansible behaves: precedence rules.Virtualization and Containerization Guides.Protecting sensitive data with Ansible vault.
0 Comments
Leave a Reply. |