Creating Puppet Bolt groups based on AWS tags

July 1, 2021 

The Using tags in Puppet Bolt aws_inventory target_mapping showed how to use AWS "Name" tag as the target name for Puppet Bolt. Use of tags can be extended to creating Bolt target groups:

  - name: webservers
     - _plugin: aws_inventory
         _plugin: env_var
         var: AWS_DEFAULT_REGION
         - name: tag:Type
           values: [webserver]
         name: tags.Name
         uri: public_ip_address

All you need to do is add a "filter" section with one filter. The "name" parameter tells Bolt that the filter is based on tags and what tag to look for. The "Type" that follows "tag" is the name of the tag you want to filter by. The "values" array lists acceptable values for that tag. Any nodes that don't have the tag (here: "Type") or where tag value is not acceptable (e.g. "db") will not be shown in the group.

For more details see puppetlabs-aws_inventory GitHub page.

Samuli Seppänen
Samuli Seppänen
Author archive