diff --git a/changelogs/fragments/9099-proxmox-fix-insecure.yml b/changelogs/fragments/9099-proxmox-fix-insecure.yml new file mode 100644 index 0000000000..b277a0f933 --- /dev/null +++ b/changelogs/fragments/9099-proxmox-fix-insecure.yml @@ -0,0 +1,2 @@ +minor_changes: + - proxmox inventory plugin - fix urllib3 ``InsecureRequestWarnings`` not being suppressed when a token is used (https://github.com/ansible-collections/community.general/pull/9099). diff --git a/plugins/inventory/proxmox.py b/plugins/inventory/proxmox.py index d7e2107719..3ce4f789a3 100644 --- a/plugins/inventory/proxmox.py +++ b/plugins/inventory/proxmox.py @@ -276,16 +276,18 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable): def _get_auth(self): + validate_certs = self.get_option('validate_certs') + + if validate_certs is False: + from requests.packages.urllib3 import disable_warnings + disable_warnings() + if self.proxmox_password: credentials = urlencode({'username': self.proxmox_user, 'password': self.proxmox_password}) a = self._get_session() - if a.verify is False: - from requests.packages.urllib3 import disable_warnings - disable_warnings() - ret = a.post('%s/api2/json/access/ticket' % self.proxmox_url, data=credentials) json = ret.json()