mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
VMware: vmware_tools tls warning fixes (#55187)
* vmware_tools: remove silence_tls_warnings option * attempt import of bundled urllib3
This commit is contained in:
parent
36ab96e4a9
commit
7191d45885
1 changed files with 11 additions and 17 deletions
|
@ -12,14 +12,6 @@ from ssl import SSLError
|
|||
from time import sleep
|
||||
import traceback
|
||||
|
||||
URLLIB3_IMP_ERR = None
|
||||
try:
|
||||
import urllib3
|
||||
HAS_URLLIB3 = True
|
||||
except ImportError:
|
||||
URLLIB3_IMP_ER = traceback.format_exc()
|
||||
HAS_URLLIB3 = False
|
||||
|
||||
REQUESTS_IMP_ERR = None
|
||||
try:
|
||||
import requests
|
||||
|
@ -28,6 +20,16 @@ except ImportError:
|
|||
REQUESTS_IMP_ERR = traceback.format_exc()
|
||||
HAS_REQUESTS = False
|
||||
|
||||
try:
|
||||
from requests.packages import urllib3
|
||||
HAS_URLLIB3 = True
|
||||
except ImportError:
|
||||
try:
|
||||
import urllib3
|
||||
HAS_URLLIB3 = True
|
||||
except ImportError:
|
||||
HAS_URLLIB3 = False
|
||||
|
||||
from ansible.errors import AnsibleError, AnsibleFileNotFound, AnsibleConnectionFailure
|
||||
from ansible.module_utils._text import to_bytes, to_native
|
||||
from ansible.plugins.connection import ConnectionBase
|
||||
|
@ -109,13 +111,6 @@ DOCUMENTATION = """
|
|||
- name: ansible_vmware_validate_certs
|
||||
default: True
|
||||
type: bool
|
||||
silence_tls_warnings:
|
||||
description:
|
||||
- Don't output warnings about insecure connections.
|
||||
vars:
|
||||
- name: ansible_vmware_silence_tls_warnings
|
||||
default: True
|
||||
type: bool
|
||||
vm_path:
|
||||
description:
|
||||
- VM path absolute to the connection.
|
||||
|
@ -180,7 +175,6 @@ ansible_vmware_host: vcenter.example.com
|
|||
ansible_vmware_user: administrator@vsphere.local
|
||||
ansible_vmware_password: Secr3tP4ssw0rd!12
|
||||
ansible_vmware_validate_certs: no # default is yes
|
||||
ansible_vmware_silence_tls_warnings: yes # default is yes
|
||||
|
||||
# vCenter Connection VM Path Example
|
||||
ansible_vmware_guest_path: DATACENTER/vm/FOLDER/{{ inventory_hostname }}
|
||||
|
@ -297,7 +291,7 @@ class Connection(ConnectionBase):
|
|||
if self.validate_certs:
|
||||
connect = SmartConnect
|
||||
else:
|
||||
if HAS_URLLIB3 and self.get_option("silence_tls_warnings"):
|
||||
if HAS_URLLIB3:
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
connect = SmartConnectNoSSL
|
||||
|
||||
|
|
Loading…
Reference in a new issue