Advertisement
Guest User

Untitled

a guest
Jun 30th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. diff --git a/salt/cloud/clouds/ec2.py b/salt/cloud/clouds/ec2.py
  2. index 2b2e258231..9a534d97d2 100644
  3. --- a/salt/cloud/clouds/ec2.py
  4. +++ b/salt/cloud/clouds/ec2.py
  5. @@ -2224,6 +2224,9 @@ def wait_for_instance(
  6. use_winrm = config.get_cloud_config_value(
  7. 'use_winrm', vm_, __opts__, default=False
  8. )
  9. + winrm_verify_ssl = config.get_cloud_config_value(
  10. + 'winrm_verify_ssl', vm_, __opts__, default=True
  11. + )
  12.  
  13. if win_passwd and win_passwd == 'auto':
  14. log.debug('Waiting for auto-generated Windows EC2 password')
  15. @@ -2295,7 +2298,8 @@ def wait_for_instance(
  16. winrm_port,
  17. username,
  18. win_passwd,
  19. - timeout=ssh_connect_timeout):
  20. + timeout=ssh_connect_timeout,
  21. + verify=winrm_verify_ssl):
  22. raise SaltCloudSystemExit(
  23. 'Failed to authenticate against remote windows host'
  24. )
  25. diff --git a/salt/utils/cloud.py b/salt/utils/cloud.py
  26. index 0485a7476a..886dbcdd28 100644
  27. --- a/salt/utils/cloud.py
  28. +++ b/salt/utils/cloud.py
  29. @@ -499,6 +499,9 @@ def bootstrap(vm_, opts):
  30. deploy_kwargs['winrm_port'] = salt.config.get_cloud_config_value(
  31. 'winrm_port', vm_, opts, default=5986
  32. )
  33. + deploy_kwargs['winrm_verify_ssl'] = salt.config.get_cloud_config_value(
  34. + 'winrm_verify_ssl', vm_, opts, default=True
  35. + )
  36.  
  37. # Store what was used to the deploy the VM
  38. event_kwargs = copy.deepcopy(deploy_kwargs)
  39. @@ -823,7 +826,7 @@ def wait_for_winexesvc(host, port, username, password, timeout=900):
  40. )
  41.  
  42.  
  43. -def wait_for_winrm(host, port, username, password, timeout=900):
  44. +def wait_for_winrm(host, port, username, password, timeout=900, verify=True):
  45. '''
  46. Wait until WinRM connection can be established.
  47. '''
  48. @@ -834,10 +837,13 @@ def wait_for_winrm(host, port, username, password, timeout=900):
  49. )
  50. )
  51. trycount = 0
  52. + if not verify:
  53. + log.warn("SSL validation for WinRM disabled.")
  54. while True:
  55. trycount += 1
  56. try:
  57. - s = winrm.Session(host, auth=(username, password), transport='ssl')
  58. + s = winrm.Session(host, auth=(username, password), transport='ssl',
  59. + server_cert_validation=((verify and 'validate') or 'ignore'))
  60. if hasattr(s.protocol, 'set_timeout'):
  61. s.protocol.set_timeout(15)
  62. log.trace('WinRM endpoint url: {0}'.format(s.url))
  63. @@ -984,6 +990,7 @@ def deploy_windows(host,
  64. master_sign_pub_file=None,
  65. use_winrm=False,
  66. winrm_port=5986,
  67. + winrm_verify_ssl=True,
  68. **kwargs):
  69. '''
  70. Copy the install files to a remote Windows box, and execute them
  71. @@ -1009,8 +1016,10 @@ def deploy_windows(host,
  72.  
  73. if HAS_WINRM and use_winrm:
  74. winrm_session = wait_for_winrm(host=host, port=winrm_port,
  75. - username=username, password=password,
  76. - timeout=port_timeout * 60)
  77. + username=username, password=password,
  78. + timeout=port_timeout * 60,
  79. + verify=winrm_verify_ssl
  80. + )
  81. if winrm_session is not None:
  82. service_available = True
  83. else:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement