diff --git a/plugins/inventory/instance.py b/plugins/inventory/instance.py index 404c4063..453cf908 100644 --- a/plugins/inventory/instance.py +++ b/plugins/inventory/instance.py @@ -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: @@ -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 """ @@ -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]