From b64eafe6ed967929aab6bc72d17fb7c12b1889d3 Mon Sep 17 00:00:00 2001 From: brad2014 Date: Mon, 19 Jan 2026 16:37:42 +0100 Subject: [PATCH] Fix Issue #744 - semantic collision between linode and ansible tags In order to suppress the warning about using ansible reserved words as variables, We inject the instance tags as "linode_tags" instead of "tags". This would be a breaking change, since references to linode "tags" would need to change to "linode_tags". --- plugins/inventory/instance.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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]