summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/hrobot/plugins/inventory
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:35 +0000
commit7fec0b69a082aaeec72fee0612766aa42f6b1b4d (patch)
treeefb569b86ca4da888717f5433e757145fa322e08 /ansible_collections/community/hrobot/plugins/inventory
parentReleasing progress-linux version 7.7.0+dfsg-3~progress7.99u1. (diff)
downloadansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.tar.xz
ansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.zip
Merging upstream version 9.4.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/community/hrobot/plugins/inventory')
-rw-r--r--ansible_collections/community/hrobot/plugins/inventory/robot.py27
1 files changed, 20 insertions, 7 deletions
diff --git a/ansible_collections/community/hrobot/plugins/inventory/robot.py b/ansible_collections/community/hrobot/plugins/inventory/robot.py
index 1d5af4537..19a2f1aa4 100644
--- a/ansible_collections/community/hrobot/plugins/inventory/robot.py
+++ b/ansible_collections/community/hrobot/plugins/inventory/robot.py
@@ -26,7 +26,7 @@ DOCUMENTATION = r"""
- ansible.builtin.inventory_cache
- community.hrobot.robot
notes:
- - The I(hetzner_user) and I(hetzner_password) options can be templated.
+ - The O(hetzner_user) and O(hetzner_password) options can be templated.
options:
plugin:
description: Token that ensures this is a source file for the plugin.
@@ -38,13 +38,17 @@ DOCUMENTATION = r"""
hetzner_password:
env:
- name: HROBOT_API_PASSWORD
- filters:
+ simple_filters:
description:
- A dictionary of filter value pairs.
- Available filters are listed here are keys of server like C(status) or C(server_ip).
- See U(https://robot.your-server.de/doc/webservice/en.html#get-server) for all values that can be used.
+ - This option has been renamed from O(filters) to O(simple_filters) in community.hrobot 1.9.0.
+ The old name can still be used until community.hrobot 2.0.0.
type: dict
default: {}
+ aliases:
+ - filters
"""
EXAMPLES = r"""
@@ -63,7 +67,7 @@ hetzner_password: '{{ (lookup("community.sops.sops", "keys/hetzner.sops.yaml") |
# Example using constructed features to create groups
plugin: community.hrobot.robot
-filters:
+simple_filters:
status: ready
traffic: unlimited
# keyed_groups may be used to create custom groups
@@ -81,6 +85,7 @@ from ansible.errors import AnsibleError
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
from ansible.template import Templar
from ansible.utils.display import Display
+from ansible.utils.unsafe_proxy import wrap_var as make_unsafe
from ansible_collections.community.hrobot.plugins.module_utils.robot import (
BASE_URL,
@@ -109,10 +114,18 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
def parse(self, inventory, loader, path, cache=True):
super(InventoryModule, self).parse(inventory, loader, path)
servers = {}
- config = self._read_config_data(path)
+ orig_config = self._read_config_data(path)
self.load_cache_plugin()
cache_key = self.get_cache_key(path)
+ if 'filters' in orig_config:
+ display.deprecated(
+ 'The `filters` option of the community.hrobot.robot inventory plugin has been renamed to `simple_filters`. '
+ 'The old name will stop working in community.hrobot 2.0.0.',
+ collection_name='community.hrobot',
+ version='2.0.0',
+ )
+
self.templar = Templar(loader=loader)
# cache may be True or False at this point to indicate if the inventory is being refreshed
@@ -143,7 +156,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
self.populate(servers)
def populate(self, servers):
- filters = self.get_option('filters')
+ filters = self.get_option('simple_filters')
strict = self.get_option('strict')
server_lists = []
for server in servers:
@@ -162,9 +175,9 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
self.inventory.add_host(server_name)
server_lists.append(server_name)
if 'server_ip' in s:
- self.inventory.set_variable(server_name, 'ansible_host', s['server_ip'])
+ self.inventory.set_variable(server_name, 'ansible_host', make_unsafe(s['server_ip']))
for hostvar, hostval in s.items():
- self.inventory.set_variable(server_name, "{0}_{1}".format('hrobot', hostvar), hostval)
+ self.inventory.set_variable(server_name, "{0}_{1}".format('hrobot', hostvar), make_unsafe(hostval))
# Composed variables
server_vars = self.inventory.get_host(server_name).get_vars()