saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.1k stars 5.47k forks source link

salt-cloud vmware Windows Template on a DHCP network with static map file doesn't connect #39955

Open kruule69 opened 7 years ago

kruule69 commented 7 years ago

Description of Issue/Question

When deploying a new Windows Template using salt-cloud vmware module with a static IP in the map file, but the destination network is DHCP, the salt-cloud installer gets the DHCP address first before the server has finished being customized by vmware image customized. The customization complets and sets the IP address but salt-cloud does not see the new IP address and keeps trying the DHCP address.

Setup

(Please provide relevant configs and/or SLS files (Be sure to remove sensitive info).)

[root@salt-cloud02 build.d]# cat /etc/salt/cloud.profiles.d/ADCCluster-win2012r2.conf

ADCCluster-win2012r2:
  provider: 'vmware-vcsa1'
  clonefrom: 'Template - SaltBootstrap - WINMASTER'
  folder: 'Builds'
  datacenter: ADC
  cluster: 'VMWareCluster'
  deploy: True

  num_cpus: 1
  memory: 4GB

  devices:
    network:
      Network adapter 1:
        name: 'VLAN151_MGMT-10.16.201.0-24'
        switch_type: distributed
        ip: 10.16.201.123
        gateway: 10.16.201.1
        subnet_mask: 255.255.255.0
        domain: lab.local

  domain: lab.local
  dns_servers:
    - 10.16.201.11
    - 10.16.201.12

  power_on: True
  win_username: Administrator
  win_password: reallybadpassword
  win_organization_name: LAB
  plain_text: True
  win_installer: /srv/salt/installer/Salt-Minion-2016.11.2-x86-Setup.exe
  win_user_fullname: Windows User
  use_winrm: False
  winrm_verify_ssl: False

Steps to Reproduce Issue

(Include debug logs if possible and relevant.)

[root@salt-cloud02 build.d]# salt-cloud -l info -p LADCCluster-win2012r2 testvm111
[INFO    ] salt-cloud starting
[WARNING ] There's no master defined on the 'testvm111' VM settings.
[ERROR   ] Specified folder: 'Builds' does not exist
[INFO    ] Creating testvm111 from template(Template - SaltBootstrap - TCWINMASTER-12.2.1114.3s)
[INFO    ] [ testvm111 ] Waiting for clone task to finish [0 s]
[INFO    ] [ testvm111 ] Successfully completed clone task in 5 seconds
[INFO    ] [ testvm111 ] Waiting for VMware tools to be running [0 s]
[INFO    ] [ testvm111 ] Waiting for VMware tools to be running [5 s]
[INFO    ] [ testvm111 ] Waiting for VMware tools to be running [10 s]
[INFO    ] [ testvm111 ] Waiting for VMware tools to be running [15 s]
[INFO    ] [ testvm111 ] Waiting for VMware tools to be running [20 s]
[INFO    ] [ testvm111 ] Waiting for VMware tools to be running [25 s]
[INFO    ] [ testvm111 ] Waiting for VMware tools to be running [30 s]
[INFO    ] [ testvm111 ] Waiting for VMware tools to be running [35 s]
[INFO    ] [ testvm111 ] Waiting for VMware tools to be running [40 s]
[INFO    ] [ testvm111 ] Waiting for VMware tools to be running [45 s]
[INFO    ] [ testvm111 ] Successfully got VMware tools running on the guest in 45 seconds
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [0 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [5 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [10 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [15 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [20 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [25 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [30 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [35 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [40 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [45 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [50 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [55 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [60 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [65 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [70 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [75 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [80 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [85 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [90 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [95 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [100 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [105 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [110 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [115 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [120 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [125 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [130 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [135 s]
[INFO    ] [ testvm111 ] Waiting to retrieve IPv4 information [140 s]
[INFO    ] [ testvm111 ] Successfully retrieved IPv4 information in 140 seconds
[INFO    ] [ testvm111 ] IPv4 is: 10.16.201.236
[INFO    ] Rendering deploy script: /usr/lib/python2.7/site-packages/salt/cloud/deploy/bootstrap-salt.sh
[INFO    ] Running command under pid 24216: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24217: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24218: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24219: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24220: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24221: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24222: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24231: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24232: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24233: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24234: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24235: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24236: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24237: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24238: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24239: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24240: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24241: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24242: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24243: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24244: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24302: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24303: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24304: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24305: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24306: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24307: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24308: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24309: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24310: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24311: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24312: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24313: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24314: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24315: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24316: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24317: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24318: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
[INFO    ] Running command under pid 24327: '-U 'Administrator%XXX-REDACTED-XXX' //10.16.201.236'
^C
Exiting gracefully on Ctrl-c

Versions Report

(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.) [root@salt-cloud02 build.d]# salt --versions-report Salt Version: Salt: 2016.11.3

Dependency Versions: cffi: Not Installed cherrypy: 3.2.2 dateutil: Not Installed gitdb: Not Installed gitpython: Not Installed ioflo: Not Installed Jinja2: 2.7.2 libgit2: Not Installed libnacl: Not Installed M2Crypto: Not Installed Mako: Not Installed msgpack-pure: Not Installed msgpack-python: 0.4.8 mysql-python: Not Installed pycparser: Not Installed pycrypto: 2.6.1 pygit2: Not Installed Python: 2.7.5 (default, Nov 6 2016, 00:28:07) python-gnupg: Not Installed PyYAML: 3.11 PyZMQ: 15.3.0 RAET: Not Installed smmap: Not Installed timelib: Not Installed Tornado: 4.2.1 ZMQ: 4.1.4

System Versions: dist: centos 7.3.1611 Core machine: x86_64 release: 3.10.0-514.6.1.el7.x86_64 system: Linux version: CentOS Linux 7.3.1611 Core

kruule69 commented 7 years ago

Additional information --- When we disable the DHCP Scope on that network, it works as expected.

Ch3LL commented 7 years ago

Does this only occur with windows?

kruule69 commented 7 years ago

Our company has almost no Linux so we only have tested the deployment for windows and haven't setup/tested the bootstrap for Linux. So, unfortunately I haven't tested if this is only windows or also is a problem in Linux but I believe this will be specific to the salt-cloud vmware provider.

konstest commented 6 years ago

Hi i found this problem earlier and try to fix it so but this is not the solution because the procedure for determining ip addresses is invoked earlier, there need to make a cycle

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

amalaguti commented 4 years ago

I'm re-opening this issue due lately I have seen a few customers running into this same issue, and I'd like your consideration for a fix or at least document it in the Salt Cloud - Windows section documentation to prevent users about this problem

I've seen the same problem running latest 3001.1 with pyvmomi 7, using our internal Vsphere server.

amalaguti commented 4 years ago

https://saltstack.zendesk.com/agent/tickets/5505 here you go a ZD ticket for this issue

amalaguti commented 4 years ago

Workaround: use ssh_host to provide the static IP address, this way salt-cloud will connect to this IP instead of the one informed initially by VMWARE (DHCP). Note, it will take some time and connection attempts while the instance is being customized until it finally gets the static IP and salt-cloud is able to connect. SOme scary errors will be thrown until the connection is allowed.

Make sure the template was properly configured to allow SMB connections (firewall rules). Also make sure the Administrator password set in the Vsphere customization settings for Windows matches the one set in your profile.

vmware-win16-mod:
  provider: salt_vsphere_c7
  clonefrom: amalaguti-win16-dhcp

  cluster: Rackmount Server Cluster

  winrm_verify_ssl: False
  win_installer: /srv/salt/Salt-Minion-3001.1-Py3-AMD64-Setup.exe
  win_username: Administrator
  win_password: REDACTED

  plain_text: True

  minion:
    master: 10.27.74.40
  display_ssh_output: False
  deploy: True
  customization: True

  devices:
    network:
      Network adapter 1:
        name: "VM Network"
        switch_type: standard
        ip: 10.1.47.85
        gateway: [10.1.0.1]
        subnet_mask: 255.255.0.0
        domain: c7.saltstack.net
        adapter_type: e1000e
  domain: c7.saltstack.net
  dns_servers:
    - 10.1.0.1

  ssh_host: 10.1.47.85
shadoutmapes commented 1 year ago

So still seeing this issue on windows server 2022 again. Salt Version: Salt: 3005.1

Dependency Versions: cffi: Not Installed cherrypy: Not Installed dateutil: 2.7.3 docker-py: Not Installed gitdb: 2.0.6 gitpython: 3.0.7 Jinja2: 2.10.1 libgit2: 0.28.3 M2Crypto: Not Installed Mako: Not Installed msgpack: 0.6.2 msgpack-pure: Not Installed mysql-python: 1.4.4 pycparser: Not Installed pycrypto: 2.6.1 pycryptodome: 3.6.1 pygit2: 1.0.3 Python: 3.8.10 (default, Jun 22 2022, 20:18:18) python-gnupg: 0.4.5 PyYAML: 5.3.1 PyZMQ: 20.0.0 smmap: 2.0.5 timelib: Not Installed Tornado: 4.5.3 ZMQ: 4.3.2

System Versions: dist: ubuntu 20.04 focal locale: utf-8 machine: x86_64 release: 5.4.0-125-generic system: Linux version: Ubuntu 20.04 focal

In linux deploys to vcenter it seems that the nic comes up disconnected to alleviate this issue, but windows deploy isn't doing this and a dhcp address is reported before the customization happens to assign the static.