Skip to content

Commit

Permalink
Add suggested docs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
twangboy committed Jun 15, 2023
1 parent 1fd4006 commit bd3a47b
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 46 deletions.
3 changes: 1 addition & 2 deletions changelog/64439.added.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Added documentation on how to run a 2nd minion in a user context on Windows
Also created a script to automate setting up a 2nd minion
Added a script to automate setting up a 2nd minion in a user context on Windows
59 changes: 33 additions & 26 deletions doc/topics/windows/multi-minion.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=============================
Multi-Minion Setup on Windows
Multi-minion setup on Windows
=============================

There may be a scenario where having a minion running in the context of the
Expand All @@ -14,18 +14,21 @@ The steps required to do this are as follows:
2. Set root_dir permissions
3. Create directory structure
4. Write minion config

We will now go through each of these steps in detail.
5. Start the minion
6. Register the minion as a service (optional)

.. note::

We have created a powershell script that will configure an additional minion
on the system for you. It can be found in the root of the Salt installation.
The script is named ``multi-minion.ps1``. You can get help on how to use the
script by running the following in a PowerShell prompt:
The Salt Project has created a powershell script that will configure an
additional minion on the system for you. It can be found in the root of the
Salt installation. The script is named ``multi-minion.ps1``. You can get
help on how to use the script by running the following in a PowerShell
prompt:

``Get-Help .\multi-minion.ps1 -Detailed``

The following guide explains these steps in more detail.

1. Create new ``root_dir``
--------------------------

Expand All @@ -42,7 +45,8 @@ put the ``root_dir`` in the Local AppData directory (``$env:LocalAppData``).

The user running Salt requires full access to the ``root_dir``. If you have
placed the root_dir in a location that the user does not have access to, you'll
need to give the user full permissions to that directory.
need to give the user full permissions to that directory. Replace the
<placeholder variables> in this example with your own configuration information.

.. code-block:: powershell
Expand All @@ -57,9 +61,9 @@ need to give the user full permissions to that directory.
-----------------------------

Salt expects a certain directory structure to be present to avoid unnecessary
messages in the logs. This is usually handled by the installer. Since we're
running our own instance, we need to do it. Make sure the following directories
are present:
messages in the logs. This is usually handled by the installer. Since you're
running your own instance, you need to do it. Make sure the following
directories are present:

- root_dir\\conf\\minion.d
- root_dir\\conf\\pki
Expand All @@ -83,9 +87,10 @@ are present:
4. Write minion config
----------------------

The minion will need is own config, separate from the system minion config. This
config tells the minion where everything is as well as defines the master and
minion id. Create a minion config file named ``minion`` in the conf directory.
The minion will need its own config, separate from the system minion config.
This config tells the minion where everything is located in the file structure
and also defines the master and minion id. Create a minion config file named
``minion`` in the conf directory.

.. code-block:: powershell
Expand Down Expand Up @@ -119,8 +124,8 @@ Make sure the config file has at least the following contents:
base:
- <root_dir>\srv\thorium
Run the minion
--------------
5. Run the minion
-----------------

Everything is now set up to run the minion. You can start the minion as you
would normally, but you need to specify the full path to the config file you
Expand All @@ -130,24 +135,26 @@ created above.
salt-minion.exe -c <root_dir>\conf
Register the minion as a service
--------------------------------
6. Register the minion as a service (optional)
----------------------------------------------

You can also register the minion as a service, but you need to understand the
implications of doing so.

- You will need to have administrator privileges to register this minion service
- You will need the password to the user account that will be running the minion
- You will need to have administrator privileges to register this minion
service.
- You will need the password to the user account that will be running the
minion.
- If the user password changes, you will have to update the service definition
to reflect the new password
- The minion will run all the time under the user context, whether that user is
logged in or not
to reflect the new password.
- The minion runs all the time under the user context, whether that user is
logged in or not.
- This requires great trust from the user as the minion will be able to perform
operations under the user's name without the user knowing, whether they are
logged in or not
logged in or not.
- If you decide to run the new minion under the Local System account, it might
as well just be a normal minion
- The helper script does not support registering the 2nd minion as a service
as well just be a normal minion.
- The helper script does not support registering the second minion as a service.

To register the minion as a service, use the ``ssm.exe`` binary that came with
the Salt installation. Run the following commands, replacing ``<service-name>``,
Expand Down
10 changes: 5 additions & 5 deletions pkg/tests/integration/test_multi_minion.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_script_present(mm_script):

def test_install(mm_script, mm_conf):
"""
Install a 2nd minion with default settings. Should create a minion config
Install a second minion with default settings. Should create a minion config
file in Local AppData
"""
ret = subprocess.run(
Expand All @@ -54,7 +54,7 @@ def test_install(mm_script, mm_conf):

def test_install_master(mm_script, mm_conf):
"""
Install a 2nd minion and set the master to spongebob
Install a second minion and set the master to spongebob
"""
ret = subprocess.run(
["powershell", str(mm_script).replace(" ", "' '"), "-m", "spongebob"],
Expand All @@ -71,7 +71,7 @@ def test_install_master(mm_script, mm_conf):

def test_install_prefix(mm_script, mm_conf):
"""
Install a 2nd minion and add a prefix to the minion id
Install a second minion and add a prefix to the minion id
"""
ret = subprocess.run(
["powershell", str(mm_script).replace(" ", "' '"), "-p", "squarepants"],
Expand All @@ -88,7 +88,7 @@ def test_install_prefix(mm_script, mm_conf):

def test_install_log_level(mm_script, mm_conf):
"""
Install a 2nd minion and set the log level in the log file to debug
Install a second minion and set the log level in the log file to debug
"""
ret = subprocess.run(
["powershell", str(mm_script).replace(" ", "' '"), "-l", "debug"],
Expand All @@ -105,7 +105,7 @@ def test_install_log_level(mm_script, mm_conf):

def test_install_start(mm_script, mm_conf):
"""
Install a 2nd minion and start that minion in a hidden process
Install a second minion and start that minion in a hidden process
"""
ret = subprocess.run(
["powershell", str(mm_script).replace(" ", "' '"), "-s"],
Expand Down
26 changes: 13 additions & 13 deletions pkg/windows/multi-minion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Script for setting up an additional salt-minion on a machine with Salt installed
.DESCRIPTION
This script will configure an additional minion on a machine that already has a
Salt installation using one of the Salt packages. It will set up the directory
structure required by Salt. It will also lay down a minion config to be used
This script configures an additional minion on a machine that already has a Salt
installation using one of the Salt packages. It sets up the directory structure
required by Salt. It also lays down a minion config to be used
by the Salt minion. Additionaly, this script can start the new minion in a
hidden window.
Expand All @@ -16,30 +16,30 @@ This script does not need to be run with Administrator privileges
If a minion that was configured with this script is already running, the script
will exit.
The following example will set up a minion for the current logged in account. It
The following example sets up a minion for the current logged in account. It
configures the minion to connect to the master at 192.168.0.10
.EXAMPLE
PS>multi-minion.ps1 -Master 192.168.0.10
PS>multi-minion.ps1 -m 192.168.0.10
The following example will set up a minion for the current logged in account. It
configures the minion to connect to the master at 192.168.0.10. It will also
prefix the minion id with `spongebob`
The following example sets up a minion for the current logged in account. It
configures the minion to connect to the master at 192.168.0.10. It also prefixes
the minion id with `spongebob`
.EXAMPLE
PS>multi-minion.ps1 -Master 192.168.0.10 -Prefix spongebob
PS>multi-minion.ps1 -m 192.168.0.10 -p spongebob
The following example will set up a minion for the current logged in account. It
configures the minion to connect to the master at 192.168.0.10. It will also
start the minion in a hidden window:
The following example sets up a minion for the current logged in account. It
configures the minion to connect to the master at 192.168.0.10. It also starts
the minion in a hidden window:
.EXAMPLE
PS>multi-minion.ps1 -Master 192.168.0.10 -Start
PS>multi-minion.ps1 -m 192.168.0.10 -s
The following example will remove a multiminion for the current running account:
The following example removes a multiminion for the current running account:
.EXAMPLE
PS>multi-minion.ps1 -Delete
Expand All @@ -60,7 +60,7 @@ param(
[Alias("p")]
# The prefix to the minion id to differentiate it from the installed system
# minion. The default is $env:COMPUTERNAME. It might be helpful to use the
# minion id of the System minion if you know it
# minion id of the system minion if you know it
[String] $Prefix = "$env:COMPUTERNAME",

[Parameter(Mandatory=$false)]
Expand All @@ -82,7 +82,7 @@ param(
"critical",
"quiet"
)]
# Start the minion in the background
# Set the log level for log file. Default is `warning`
[String] $LogLevel = "warning",

[Parameter(Mandatory=$false)]
Expand Down

0 comments on commit bd3a47b

Please sign in to comment.