2013-10-17 13:27:16 +00:00
|
|
|
===========================
|
|
|
|
Spinning up Windows Minions
|
|
|
|
===========================
|
|
|
|
|
|
|
|
It is possible to use Salt Cloud to spin up Windows instances, and then install
|
|
|
|
Salt on them. This functionality is available on all cloud providers that are
|
|
|
|
supported by Salt Cloud. However, it may not necessarily be available on all
|
|
|
|
Windows images.
|
|
|
|
|
|
|
|
Requirements
|
|
|
|
============
|
2018-03-20 04:37:51 +00:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
Support ``winexe`` and ``impacket`` has been deprecated and will be removed in
|
2018-04-30 15:52:49 +00:00
|
|
|
Fluorine. These dependencies are replaced by ``pypsexec`` and ``smbprotocol``
|
2018-03-20 04:37:51 +00:00
|
|
|
respectivly. These are pure python alternatives that are compatible with all
|
|
|
|
supported python versions.
|
|
|
|
|
2014-12-17 18:45:49 +00:00
|
|
|
Salt Cloud makes use of `impacket` and `winexe` to set up the Windows Salt
|
|
|
|
Minion installer.
|
|
|
|
|
|
|
|
`impacket` is usually available as either the `impacket` or the
|
|
|
|
`python-impacket` package, depending on the distribution. More information on
|
|
|
|
`impacket` can be found at the project home:
|
|
|
|
|
|
|
|
* `impacket project home`__
|
|
|
|
|
|
|
|
.. __: https://code.google.com/p/impacket/
|
|
|
|
|
|
|
|
`winexe` is less commonly available in distribution-specific repositories.
|
|
|
|
However, it is currently being built for various distributions in 3rd party
|
|
|
|
channels:
|
2013-10-17 13:27:16 +00:00
|
|
|
|
2013-11-11 07:20:14 +00:00
|
|
|
* `RPMs at pbone.net`__
|
2013-10-17 13:27:16 +00:00
|
|
|
|
2014-02-04 04:11:56 +00:00
|
|
|
.. __: http://rpm.pbone.net/index.php3?stat=3&search=winexe
|
2013-11-11 07:20:14 +00:00
|
|
|
|
2016-05-27 05:11:20 +00:00
|
|
|
* `openSUSE Build Service`__
|
2013-11-11 07:20:14 +00:00
|
|
|
|
2014-02-04 04:11:56 +00:00
|
|
|
.. __: http://software.opensuse.org/package/winexe
|
2013-10-17 13:27:16 +00:00
|
|
|
|
2018-03-20 04:37:51 +00:00
|
|
|
* `pypsexec project home`__
|
|
|
|
|
|
|
|
.. __: https://github.com/jborean93/pypsexec
|
|
|
|
|
|
|
|
* `smbprotocol project home`__
|
|
|
|
|
|
|
|
.. __: https://github.com/jborean93/smbprotocol
|
|
|
|
|
|
|
|
|
2015-04-13 19:53:00 +00:00
|
|
|
Optionally WinRM can be used instead of `winexe` if the python module `pywinrm`
|
|
|
|
is available and WinRM is supported on the target Windows version. Information
|
|
|
|
on pywinrm can be found at the project home:
|
|
|
|
|
|
|
|
* `pywinrm project home`__
|
|
|
|
|
|
|
|
.. __: https://github.com/diyan/pywinrm
|
|
|
|
|
2013-10-17 13:27:16 +00:00
|
|
|
Additionally, a copy of the Salt Minion Windows installer must be present on
|
|
|
|
the system on which Salt Cloud is running. This installer may be downloaded
|
|
|
|
from saltstack.com:
|
|
|
|
|
2013-11-11 07:20:14 +00:00
|
|
|
* `SaltStack Download Area`__
|
|
|
|
|
2015-09-08 20:21:17 +00:00
|
|
|
.. __: https://repo.saltstack.com/windows/
|
2013-11-11 07:20:14 +00:00
|
|
|
|
2017-07-07 17:53:48 +00:00
|
|
|
.. _new-pywinrm:
|
2013-10-17 13:27:16 +00:00
|
|
|
|
2017-07-07 17:37:14 +00:00
|
|
|
Self Signed Certificates with WinRM
|
|
|
|
===================================
|
|
|
|
|
|
|
|
Salt-Cloud can use versions of ``pywinrm<=0.1.1`` or ``pywinrm>=0.2.1``.
|
|
|
|
|
|
|
|
For versions greater than `0.2.1`, ``winrm_verify_ssl`` needs to be set to
|
|
|
|
`False` if the certificate is self signed and not verifiable.
|
|
|
|
|
2013-10-17 13:27:16 +00:00
|
|
|
Firewall Settings
|
|
|
|
=================
|
|
|
|
Because Salt Cloud makes use of `smbclient` and `winexe`, port 445 must be open
|
|
|
|
on the target image. This port is not generally open by default on a standard
|
|
|
|
Windows distribution, and care must be taken to use an image in which this port
|
|
|
|
is open, or the Windows firewall is disabled.
|
|
|
|
|
2014-12-08 21:23:05 +00:00
|
|
|
If supported by the cloud provider, a PowerShell script may be used to open up
|
|
|
|
this port automatically, using the cloud provider's `userdata`. The following
|
|
|
|
script would open up port 445, and apply the changes:
|
|
|
|
|
2018-05-28 21:13:12 +00:00
|
|
|
.. code-block:: text
|
2014-12-08 21:23:05 +00:00
|
|
|
|
|
|
|
<powershell>
|
2014-12-09 18:57:35 +00:00
|
|
|
New-NetFirewallRule -Name "SMB445" -DisplayName "SMB445" -Protocol TCP -LocalPort 445
|
2014-12-08 21:23:05 +00:00
|
|
|
Set-Item (dir wsman:\localhost\Listener\*\Port -Recurse).pspath 445 -Force
|
|
|
|
Restart-Service winrm
|
|
|
|
</powershell>
|
|
|
|
|
|
|
|
For EC2, this script may be saved as a file, and specified in the provider or
|
|
|
|
profile configuration as `userdata_file`. For instance:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
2017-03-31 16:59:18 +00:00
|
|
|
my-ec2-config:
|
|
|
|
# Pass userdata to the instance to be created
|
|
|
|
userdata_file: /etc/salt/windows-firewall.ps1
|
2014-12-08 21:23:05 +00:00
|
|
|
|
2017-03-31 15:23:44 +00:00
|
|
|
.. note::
|
2017-03-31 16:59:18 +00:00
|
|
|
From versions 2016.11.0 and 2016.11.3, this file was passed through the
|
|
|
|
master's :conf_master:`renderer` to template it. However, this caused
|
|
|
|
issues with non-YAML data, so templating is no longer performed by default.
|
|
|
|
To template the userdata_file, add a ``userdata_template`` option to the
|
|
|
|
cloud profile:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
my-ec2-config:
|
|
|
|
# Pass userdata to the instance to be created
|
|
|
|
userdata_file: /etc/salt/windows-firewall.ps1
|
|
|
|
userdata_template: jinja
|
|
|
|
|
|
|
|
If no ``userdata_template`` is set in the cloud profile, then the master
|
|
|
|
configuration will be checked for a :conf_master:`userdata_template` value.
|
|
|
|
If this is not set, then no templating will be performed on the
|
|
|
|
userdata_file.
|
2017-03-31 15:23:44 +00:00
|
|
|
|
2017-03-31 20:31:13 +00:00
|
|
|
To disable templating in a cloud profile when a
|
|
|
|
:conf_master:`userdata_template` has been set in the master configuration
|
|
|
|
file, simply set ``userdata_template`` to ``False`` in the cloud profile:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
my-ec2-config:
|
|
|
|
# Pass userdata to the instance to be created
|
|
|
|
userdata_file: /etc/salt/windows-firewall.ps1
|
|
|
|
userdata_template: False
|
|
|
|
|
2017-03-31 15:23:44 +00:00
|
|
|
|
|
|
|
If you are using WinRM on EC2 the HTTPS port for the WinRM service must also be
|
|
|
|
enabled in your userdata. By default EC2 Windows images only have insecure HTTP
|
|
|
|
enabled. To enable HTTPS and basic authentication required by pywinrm consider
|
|
|
|
the following userdata example:
|
2013-10-17 13:27:16 +00:00
|
|
|
|
2018-05-28 21:13:12 +00:00
|
|
|
.. code-block:: text
|
2015-11-25 18:36:11 +00:00
|
|
|
|
|
|
|
<powershell>
|
|
|
|
New-NetFirewallRule -Name "SMB445" -DisplayName "SMB445" -Protocol TCP -LocalPort 445
|
|
|
|
New-NetFirewallRule -Name "WINRM5986" -DisplayName "WINRM5986" -Protocol TCP -LocalPort 5986
|
|
|
|
|
|
|
|
winrm quickconfig -q
|
|
|
|
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="300"}'
|
|
|
|
winrm set winrm/config '@{MaxTimeoutms="1800000"}'
|
|
|
|
winrm set winrm/config/service/auth '@{Basic="true"}'
|
|
|
|
|
|
|
|
$SourceStoreScope = 'LocalMachine'
|
|
|
|
$SourceStorename = 'Remote Desktop'
|
|
|
|
|
2018-04-12 20:41:19 +00:00
|
|
|
$SourceStore = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Store -ArgumentList $SourceStorename, $SourceStoreScope
|
2015-11-25 18:36:11 +00:00
|
|
|
$SourceStore.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadOnly)
|
|
|
|
|
2018-04-12 20:41:19 +00:00
|
|
|
$cert = $SourceStore.Certificates | Where-Object -FilterScript {
|
2015-11-25 18:36:11 +00:00
|
|
|
$_.subject -like '*'
|
|
|
|
}
|
|
|
|
|
|
|
|
$DestStoreScope = 'LocalMachine'
|
|
|
|
$DestStoreName = 'My'
|
|
|
|
|
2018-04-12 20:41:19 +00:00
|
|
|
$DestStore = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Store -ArgumentList $DestStoreName, $DestStoreScope
|
2015-11-25 18:36:11 +00:00
|
|
|
$DestStore.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
|
|
|
|
$DestStore.Add($cert)
|
|
|
|
|
|
|
|
$SourceStore.Close()
|
|
|
|
$DestStore.Close()
|
|
|
|
|
2018-04-12 20:41:19 +00:00
|
|
|
winrm create winrm/config/listener?Address=*+Transport=HTTPS `@`{CertificateThumbprint=`"($cert.Thumbprint)`"`}
|
2015-11-25 18:36:11 +00:00
|
|
|
|
|
|
|
Restart-Service winrm
|
|
|
|
</powershell>
|
|
|
|
|
|
|
|
No certificate store is available by default on EC2 images and creating
|
|
|
|
one does not seem possible without an MMC (cannot be automated). To use the
|
|
|
|
default EC2 Windows images the above copies the RDP store.
|
2015-04-13 19:53:00 +00:00
|
|
|
|
2013-10-17 13:27:16 +00:00
|
|
|
Configuration
|
|
|
|
=============
|
|
|
|
Configuration is set as usual, with some extra configuration settings. The
|
|
|
|
location of the Windows installer on the machine that Salt Cloud is running on
|
|
|
|
must be specified. This may be done in any of the regular configuration files
|
|
|
|
(main, providers, profiles, maps). For example:
|
|
|
|
|
|
|
|
Setting the installer in ``/etc/salt/cloud.providers``:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
my-softlayer:
|
2015-06-17 22:41:03 +00:00
|
|
|
driver: softlayer
|
2013-10-17 13:27:16 +00:00
|
|
|
user: MYUSER1138
|
|
|
|
apikey: 'e3b68aa711e6deadc62d5b76355674beef7cc3116062ddbacafe5f7e465bfdc9'
|
|
|
|
minion:
|
|
|
|
master: saltmaster.example.com
|
2014-12-08 21:23:05 +00:00
|
|
|
win_installer: /root/Salt-Minion-2014.7.0-AMD64-Setup.exe
|
2013-10-17 13:27:16 +00:00
|
|
|
win_username: Administrator
|
|
|
|
win_password: letmein
|
2015-03-26 15:31:38 +00:00
|
|
|
smb_port: 445
|
2013-10-17 13:27:16 +00:00
|
|
|
|
|
|
|
The default Windows user is `Administrator`, and the default Windows password
|
|
|
|
is blank.
|
|
|
|
|
2015-11-25 18:36:11 +00:00
|
|
|
If WinRM is to be used ``use_winrm`` needs to be set to `True`. ``winrm_port``
|
2017-07-07 17:37:14 +00:00
|
|
|
can be used to specify a custom port (must be HTTPS listener). And
|
|
|
|
``winrm_verify_ssl`` can be set to `False` to use a self signed certificate.
|
2015-04-13 19:53:00 +00:00
|
|
|
|
2014-12-08 21:23:05 +00:00
|
|
|
|
|
|
|
Auto-Generated Passwords on EC2
|
|
|
|
===============================
|
|
|
|
On EC2, when the `win_password` is set to `auto`, Salt Cloud will query EC2 for
|
|
|
|
an auto-generated password. This password is expected to take at least 4 minutes
|
|
|
|
to generate, adding additional time to the deploy process.
|
|
|
|
|
|
|
|
When the EC2 API is queried for the auto-generated password, it will be returned
|
|
|
|
in a message encrypted with the specified `keyname`. This requires that the
|
|
|
|
appropriate `private_key` file is also specified. Such a profile configuration
|
|
|
|
might look like:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
2014-12-09 18:57:35 +00:00
|
|
|
windows-server-2012:
|
2014-12-08 21:23:05 +00:00
|
|
|
provider: my-ec2-config
|
|
|
|
image: ami-c49c0dac
|
|
|
|
size: m1.small
|
|
|
|
securitygroup: windows
|
|
|
|
keyname: mykey
|
|
|
|
private_key: /root/mykey.pem
|
|
|
|
userdata_file: /etc/salt/windows-firewall.ps1
|
|
|
|
win_installer: /root/Salt-Minion-2014.7.0-AMD64-Setup.exe
|
|
|
|
win_username: Administrator
|
2014-12-17 18:45:49 +00:00
|
|
|
win_password: auto
|