[stable-6] inventory plugins: make data obtained from remote unsafe (#8147)

inventory plugins: make data obtained from remote unsafe (#8098)

Make data obtained from remote unsafe.

(cherry picked from commit d62fe154d2)
This commit is contained in:
Felix Fontein 2024-03-25 06:50:17 +01:00 committed by GitHub
parent 12df7f7a95
commit d250bb5217
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 83 additions and 46 deletions

View file

@ -84,6 +84,7 @@ keyed_groups:
from ansible.errors import AnsibleError, AnsibleParserError
from ansible.module_utils.common.text.converters import to_native
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable
from ansible.utils.unsafe_proxy import wrap_var as make_unsafe
try:
import gitlab
@ -106,11 +107,11 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
else:
runners = gl.runners.all()
for runner in runners:
host = str(runner['id'])
host = make_unsafe(str(runner['id']))
ip_address = runner['ip_address']
host_attrs = vars(gl.runners.get(runner['id']))['_attrs']
host_attrs = make_unsafe(vars(gl.runners.get(runner['id']))['_attrs'])
self.inventory.add_host(host, group='gitlab_runners')
self.inventory.set_variable(host, 'ansible_host', ip_address)
self.inventory.set_variable(host, 'ansible_host', make_unsafe(ip_address))
if self.get_option('verbose_output', True):
self.inventory.set_variable(host, 'gitlab_runner_attributes', host_attrs)