Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions plugins/inventory/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
default: []
type: list
tags:
description: Populate inventory only with instances which have at least one of the tags listed here.
description: Populate inventory only with instances which have at least one of the linode tags listed here.
default: []
type: list
types:
Expand All @@ -75,13 +75,13 @@
plugin: linode.cloud.instance
api_token: foobar
keyed_groups:
- key: tags
- key: linode_tags
separator: ''
- key: region
prefix: region
groups:
webservers: "'web' in (tags|list)"
mailservers: "'mail' in (tags|list)"
webservers: "'web' in linode_tags"
mailservers: "'mail' in linode_tags"
compose:
ansible_port: 2222
"""
Expand Down Expand Up @@ -214,6 +214,12 @@ def _add_hostvars_for_instances(self) -> None:
hostvars.update(instance._raw_json)
hostvars["networking_info"] = instance.ips.dict

# Fix #744 - Rename 'tags' to circumvent collision
# between linode tags and ansible tags, and avoid Ansible
# reserved word warning.
if 'tags' in hostvars:
hostvars['linode_tags'] = hostvars.pop('tags')

for hostvar_key in hostvars:
self.inventory.set_variable(
instance.label, hostvar_key, hostvars[hostvar_key]
Expand Down