Skip to content

Commit 646ac9a

Browse files
authored
Merge pull request #116 from mirceaulinic/develop
Release 2020.7.0
2 parents b6a4c4b + 6969328 commit 646ac9a

File tree

25 files changed

+1235
-62
lines changed

25 files changed

+1235
-62
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [mirceaulinic]

MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
include LICENSE
2+
include NOTICE
13
include pypi.rst
24
include docs/man/*
35
include requirements.txt
46
include salt_sproxy/_runners/*
57
include salt_sproxy/_modules/*
68
include salt_sproxy/_roster/*
9+
include salt_sproxy/_proxy/*
10+
include salt_sproxy/_executors/*

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ flexibility and extensibility of Salt, while you don't have to manage thousands
1818
of (Proxy) Minion services. However, you are able to use both ``salt-sproxy``
1919
and your (Proxy) Minions at the same time.
2020

21-
*Note*:
22-
23-
> This is NOT a SaltStack product.
24-
2521
Why ``salt-sproxy``
2622
-------------------
2723

@@ -42,13 +38,17 @@ In brief, here are some benefits you can get by using *salt-sproxy*:
4238

4339
- Say goodbye to the burden of managing hundreds of system services for the
4440
Proxy Minion processes.
41+
- Reuse your existing extension modules, templates, Pillars, States, etc., you
42+
may have already developed in your environment, transparently.
4543
- You can run it locally, on your own computer.
4644
- Python programming made a breeze - might go well with the
4745
[ISalt](https://github.com/mirceaulinic/isalt) package.
4846
- Integrates easily with your existing Salt environment (if you have), by
4947
installing the package on your Salt Master.
5048
- Can continue to leverage the event-driven automation and orchestration
5149
methodologies.
50+
- Can continue using any of the usual [targeting mechanisms](
51+
https://salt-sproxy.readthedocs.io/en/latest/targeting.html).
5252
- REST API, see also
5353
[the Salt REST API](https://salt-sproxy.readthedocs.io/en/latest/salt_api.html)
5454
documentation.
@@ -58,6 +58,23 @@ In brief, here are some benefits you can get by using *salt-sproxy*:
5858
contributed by thousands of users, and tested in hundreds of different
5959
environments, over almost a decade of development.
6060

61+
Is ``salt-sproxy`` a wrapper around ``salt-ssh``?
62+
-------------------------------------------------
63+
64+
No, nothing to do with *salt-ssh*. The core of *salt-sproxy* is a Runner loaded
65+
dynamically on runtime, that spins up a pool of child processes, each running
66+
a temporary light version of the Proxy Minion underneath; as soon as the
67+
execution is complete for a device, its associated Proxy Minion is shut down,
68+
and another one takes its place into the child processes bucket.
69+
70+
A source of confusion may also be the usage of the [Roster](
71+
https://salt-sproxy.readthedocs.io/en/latest/roster.html) interface, which,
72+
historically has only been used by *salt-ssh*, although the Roster is not
73+
tightly coupled with *salt-ssh*: it just happened to be the only use case so
74+
far. Essentially, the Roster simply provides a list of devices together with
75+
their credentials (e.g., similar to the *inventory* as dubbed in other
76+
automation frameworks) - and now has another use case in *salt-sproxy*.
77+
6178
Prerequisites
6279
-------------
6380

README.rst

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ flexibility and extensibility of Salt, while you don't have to manage thousands
3838
of (Proxy) Minion services. However, you are able to use both ``salt-sproxy``
3939
and your (Proxy) Minions at the same time.
4040

41-
.. note::
42-
43-
This is NOT a SaltStack product.
44-
4541
Why ``salt-sproxy``
4642
-------------------
4743

@@ -62,13 +58,17 @@ In brief, here are some benefits you can get by using *salt-sproxy*:
6258

6359
- Say goodbye to the burden of managing hundreds of system services for the
6460
Proxy Minion processes.
61+
- Reuse your existing extension modules, templates, Pillars, States, etc., you
62+
may have already developed in your environment, transparently.
6563
- You can run it locally, on your own computer.
6664
- Python programming made a breeze - might go well with the
6765
`ISalt <https://github.com/mirceaulinic/isalt>`__ package.
6866
- Integrates easily with your existing Salt environment (if you have), by
6967
installing the package on your Salt Master.
7068
- Can continue to leverage the event-driven automation and orchestration
7169
methodologies.
70+
- Can continue using any of the usual `targeting mechanisms
71+
<https://salt-sproxy.readthedocs.io/en/latest/targeting.html>`__.
7272
- REST API, see also
7373
`the Salt REST API <https://salt-sproxy.readthedocs.io/en/latest/salt_api.html>`__
7474
documentation.
@@ -78,6 +78,22 @@ In brief, here are some benefits you can get by using *salt-sproxy*:
7878
contributed by thousands of users, and tested in hundreds of different
7979
environments, over almost a decade of development.
8080

81+
Is ``salt-sproxy`` a wrapper around ``salt-ssh``?
82+
-------------------------------------------------
83+
84+
No, nothing to do with *salt-ssh*. The core of *salt-sproxy* is a Runner loaded
85+
dynamically on runtime, that spins up a pool of child processes, each running
86+
a temporary light version of the Proxy Minion underneath; as soon as the
87+
execution is complete for a device, its associated Proxy Minion is shut down,
88+
and another one takes its place into the child processes bucket.
89+
90+
A source of confusion may also be the usage of the `Roster
91+
<https://salt-sproxy.readthedocs.io/en/latest/roster.html>`__ interface, which,
92+
historically has only been used by *salt-ssh*, although the Roster is not
93+
tightly coupled with *salt-ssh*: it just happened to be the only use case so
94+
far. Essentially, the Roster simply provides a list of devices together with
95+
their credentials (e.g., similar to the *inventory* as dubbed in other
96+
automation frameworks) - and now has another use case in *salt-sproxy*.
8197

8298
Prerequisites
8399
-------------

docs/best_practices.rst

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
.. _best-practices:
2+
3+
Salt SProxy Best Practices
4+
==========================
5+
6+
.. note::
7+
8+
This document refers to best practices in regards to optimising the usage
9+
of *salt-sproxy*.
10+
11+
To refer to the Salt best practices concerning the structure of the
12+
configuration files, see `this
13+
<https://docs.saltstack.com/en/latest/topics/best_practices.html>`__
14+
document.
15+
16+
In order to simplify the default usage, *salt-sproxy* tries to load Grains,
17+
Roster, and Execution Modules; this adds an execution overhead everytime you
18+
invoke a Salt command through *salt-sproxy*, of approximatively 0.5s up to
19+
1 second. In some cases, this can be reduced or even removed entirely by
20+
configuring one or more of the options below, depending on your use case.
21+
22+
TL;DR
23+
-----
24+
25+
To speed up the execution, you can add the *salt-sproxy* installation path to
26+
your ``file_roots`` settings in the Master config (see :ref:`runner` for more
27+
notes on how to do this), and execute ``salt-run saltutil.sync_all``. At the
28+
same time, add the following in the Master config:
29+
30+
.. code-block:: yaml
31+
32+
sync_grains: false
33+
sync_roster: false
34+
sync_modules: false
35+
36+
.. important::
37+
38+
Once you have these settings enabled, while it will speed up the
39+
*salt-sproxy* execution and make it more efficient, if you have custom
40+
Grains or Execution Modules in your own environment, you will need to take
41+
care that they are properly sync'ed on your Master. That is, execute
42+
``salt-run saltutil.sync_all`` or equivalent whenever you update your
43+
modules. Examples include: manually execute ``salt-run saltutil.sync_all``
44+
(not recommended), a cron on the same, or if you have a Salt Master running
45+
you can have it automatically sync those for you by adding a `scheduled job
46+
<https://docs.saltstack.com/en/latest/topics/jobs/>`__, e.g.,
47+
48+
.. code-block:: yaml
49+
50+
schedule:
51+
sync_all:
52+
function: saltutil.sync_all
53+
minutes: 5
54+
55+
The example configuration snippet above would ensure that your custom
56+
modules are sync'ed every 5 minutes.
57+
58+
If for some reason you can't do this for one or more of these modules, check out
59+
the recommendations below for each of them.
60+
61+
*salt-sproxy* core Runner
62+
-------------------------
63+
64+
Another contributor to the *salt-sproxy* execution speed is the :ref:`runner`
65+
which is the very core of *salt-sproxy*. That said, if this Runner is already
66+
"well known" to the Salt filesystem, it'll make it more efficient.
67+
68+
.. tip::
69+
70+
If you have a Master already running, the execution may be up to 5 seconds
71+
faster.
72+
73+
In this case, you will need to follow the notes from :ref:`runner` to update
74+
your ``file_roots`` settings, and run ``salt-run saltutil.sync_runner``.
75+
76+
Remember that you'll need to re-run that in case you re-install *salt-sproxy*,
77+
Salt, or remove the Salt cache.
78+
79+
Of course, you can always have a scheduled job that does it for you, either
80+
a cron job, or a `scheduled job
81+
<https://docs.saltstack.com/en/latest/topics/jobs/>`__ if you have a Salt
82+
Master running, e.g., re-sync Runners every hour:
83+
84+
.. code-block:: yaml
85+
86+
schedule:
87+
sync_runners:
88+
function: saltutil.sync_runner
89+
minutes: 60
90+
91+
Disable Grains
92+
--------------
93+
94+
If you don't have any custom Grains modules in your environment, you can
95+
disable the load, by configuring ``sync_grains: false`` in your Master
96+
configuration file.
97+
98+
.. tip::
99+
100+
If you do have custom Grains in your environment, you can disable the
101+
*salt-sproxy* automatic sync by adding ``sync_grains: false`` to your
102+
Master configuration, and sync the Grains manually or automatically
103+
whenever you update (or create) your modules: ``salt-run
104+
saltutil.sync_grains``.
105+
106+
107+
Additionally, disabling the load of some specific Grains modules (whether your
108+
own, or natively available in Salt), may speed up your setup. Configure
109+
``disable_grains`` in your Master config, as a list of Grains modules to avoid
110+
loading when executing through *salt-sproxy*.
111+
112+
Example:
113+
114+
.. code-block:: yaml
115+
116+
disable_grains:
117+
- esxi
118+
119+
Disable Execution Modules
120+
-------------------------
121+
122+
If you don't have any custom Execution modules in your own environment, and you
123+
don't make use of the modules shipped together with *salt-sproxy* (see
124+
:ref:`execution-modules`), you can disable the load by configuring
125+
``sync_modules: false`` in your Master configuration file.
126+
127+
.. tip::
128+
129+
If you do have custom modules in your environment, you can disable the
130+
*salt-sproxy* automatic sync by adding ``sync_modules: false`` to your
131+
Master configuration, and sync the modules manually or automatically
132+
whenever you update (or create) your modules: ``salt-run
133+
saltutil.sync_modules``.
134+
135+
Additionally, disabling the load of some specific Execution modules (whether
136+
your own, natively available in Salt, or provided through *salt-sproxy*), may
137+
speed up your setup. Configure ``disable_modules`` in your Master config, as a
138+
list of modules to avoid loading when executing through *salt-sproxy*.
139+
140+
Example:
141+
142+
.. code-block:: yaml
143+
144+
disable_modules:
145+
- pip
146+
- statuspage
147+
148+
Disable Roster Sync
149+
-------------------
150+
151+
If you use one of the Roster modules provided with this package, or from your
152+
own sources, *salt-sproxy* would attempt to sync only the Roster module you
153+
reference in ``roster:`` or using the ``--roster`` CLI argument. Even so, this
154+
may be time and resource consuming, so it'd may be optimal to disable the
155+
default behaviour by setting ``sync_roster: false`` in the Master
156+
configuration. Similarly to the previous sections, if you'd like to use
157+
a custom module in your own environment, you can sync them by running
158+
``salt-run saltutil.sync_roster``.
159+
160+
Disable Events
161+
--------------
162+
163+
If you don't need the :ref:`events`, you can gain a few execution seconds by
164+
disabling this so *salt-sproxy* doesn't attempt to send execution events to an
165+
nonexistent Master (or you simply don't need / use those events).
166+
167+
File open limit
168+
---------------
169+
170+
As *salt-sproxy* runs locally, it means it starts the processes and initializes
171+
the connection on the local computer. Every new process creates a process file,
172+
and every new connection creates at least one more file as well. That said,
173+
depending on your operating system and configuration, you may hit the hard
174+
limit for max open files. For example, on Unix operating systems, ``ulimit
175+
-Hn`` will tell you the max open files number. If you hit any issues, consider
176+
increasing this limit.

docs/index.rst

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ flexibility and extensibility of Salt, while you don't have to manage thousands
1010
of (Proxy) Minion services. However, you are able to use both ``salt-sproxy``
1111
and your (Proxy) Minions at the same time.
1212

13-
.. note::
14-
15-
This is NOT a SaltStack product.
16-
1713
Why ``salt-sproxy``
1814
-------------------
1915

@@ -27,26 +23,50 @@ the exact same effect, and result. On top of that, using ``salt-sproxy`` allows
2723
you to manage other devices for which you don't run (Proxy) Minions for.
2824

2925
Of course, if you don't already have Salt, no problem, you can start managing
30-
your devices straight away, check out the :ref:`quick-start` steps.
26+
your devices straight away, check out the `quick
27+
start steps <https://github.com/mirceaulinic/salt-sproxy/blob/develop/docs/quick_start.rst>`__.
3128

3229
In brief, here are some benefits you can get by using *salt-sproxy*:
3330

3431
- Say goodbye to the burden of managing hundreds of system services for the
3532
Proxy Minion processes.
33+
- Reuse your existing extension modules, templates, Pillars, States, etc., you
34+
may have already developed in your environment, transparently.
3635
- You can run it locally, on your own computer.
3736
- Python programming made a breeze - might go well with the
3837
`ISalt <https://github.com/mirceaulinic/isalt>`__ package.
3938
- Integrates easily with your existing Salt environment (if you have), by
4039
installing the package on your Salt Master.
4140
- Can continue to leverage the event-driven automation and orchestration
4241
methodologies.
43-
- REST API, see also :ref:`salt-api` documentation.
42+
- Can continue using any of the usual `targeting mechanisms
43+
<https://salt-sproxy.readthedocs.io/en/latest/targeting.html>`__.
44+
- REST API, see also
45+
`the Salt REST API <https://salt-sproxy.readthedocs.io/en/latest/salt_api.html>`__
46+
documentation.
4447
- By sending events to a Salt Master, you are able to implement whatever
4548
auditing you need (e.g., what command was executed by who and when, etc.).
4649
- Benefit from inheriting _all_ the native Salt features and integrations
4750
contributed by thousands of users, and tested in hundreds of different
4851
environments, over almost a decade of development.
4952

53+
Is ``salt-sproxy`` a wrapper around ``salt-ssh``?
54+
-------------------------------------------------
55+
56+
No, nothing to do with *salt-ssh*. The core of *salt-sproxy* is a Runner loaded
57+
dynamically on runtime, that spins up a pool of child processes, each running
58+
a temporary light version of the Proxy Minion underneath; as soon as the
59+
execution is complete for a device, its associated Proxy Minion is shut down,
60+
and another one takes its place into the child processes bucket.
61+
62+
A source of confusion may also be the usage of the `Roster
63+
<https://salt-sproxy.readthedocs.io/en/latest/roster.html>`__ interface, which,
64+
historically has only been used by *salt-ssh*, although the Roster is not
65+
tightly coupled with *salt-ssh*: it just happened to be the only use case so
66+
far. Essentially, the Roster simply provides a list of devices together with
67+
their credentials (e.g., similar to the *inventory* as dubbed in other
68+
automation frameworks) - and now has another use case in *salt-sproxy*.
69+
5070
Install
5171
-------
5272

@@ -324,7 +344,10 @@ See Also
324344
grains
325345
targeting
326346
opts
347+
ssh
348+
best_practices
327349
runner
350+
proxy/index
328351
events
329352
salt_api
330353
mixed_envs

0 commit comments

Comments
 (0)