mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 17:50:20 +00:00
Start checking rst files at pre-commit level with rstcheck
Additionally, fixed most of the errors reported by rstcheck. Fixes https://github.com/saltstack/salt/issues/58668
This commit is contained in:
parent
e9afe9168e
commit
b427688048
42 changed files with 274 additions and 225 deletions
|
@ -1112,6 +1112,16 @@ repos:
|
||||||
tests/kitchen/.*
|
tests/kitchen/.*
|
||||||
)$
|
)$
|
||||||
|
|
||||||
|
- repo: https://github.com/myint/rstcheck
|
||||||
|
# This, for now, is meant to run when locally committing code and will be disabled(skipped) when we run pre-commit
|
||||||
|
# against all codebase to avoid MASSIVE code churn. This way, we do it in smaller chunks, a few at a time.
|
||||||
|
rev: 3f92957
|
||||||
|
hooks:
|
||||||
|
- id: rstcheck
|
||||||
|
name: Check reST files using rstcheck
|
||||||
|
args: [--report=warning]
|
||||||
|
additional_dependencies: [sphinx]
|
||||||
|
|
||||||
- repo: https://github.com/asottile/blacken-docs
|
- repo: https://github.com/asottile/blacken-docs
|
||||||
rev: v1.7.0
|
rev: v1.7.0
|
||||||
hooks:
|
hooks:
|
||||||
|
|
27
.rstcheck.cfg
Normal file
27
.rstcheck.cfg
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
[rstcheck]
|
||||||
|
ignore_directives=
|
||||||
|
automodule,
|
||||||
|
autoclass,
|
||||||
|
autofunction,
|
||||||
|
conf_proxy,
|
||||||
|
conf_log,
|
||||||
|
conf_master,
|
||||||
|
conf_minion,
|
||||||
|
releasestree,
|
||||||
|
jinja_ref,
|
||||||
|
salt:event
|
||||||
|
ignore_roles=
|
||||||
|
conf_master,
|
||||||
|
conf_minion,
|
||||||
|
conf_proxy,
|
||||||
|
conf_log,
|
||||||
|
formula_url,
|
||||||
|
issue,
|
||||||
|
pull,
|
||||||
|
blob,
|
||||||
|
jinja_ref
|
||||||
|
ignore_substitutions=
|
||||||
|
saltrepo,
|
||||||
|
repo_primary_branch,
|
||||||
|
windownload,
|
||||||
|
osxdownloadpy3
|
|
@ -5,7 +5,7 @@ if (env.CHANGE_ID) {
|
||||||
pre_commit_skips = ''
|
pre_commit_skips = ''
|
||||||
} else {
|
} else {
|
||||||
// This is a branch build
|
// This is a branch build
|
||||||
pre_commit_skips = 'pyupgrade,remove-import-headers'
|
pre_commit_skips = 'pyupgrade,remove-import-headers,rstcheck'
|
||||||
}
|
}
|
||||||
|
|
||||||
runPreCommit(
|
runPreCommit(
|
||||||
|
|
|
@ -14,8 +14,8 @@ of the Salt system each have a respective configuration file. The
|
||||||
:ref:`Example master configuration file <configuration-examples-master>`.
|
:ref:`Example master configuration file <configuration-examples-master>`.
|
||||||
|
|
||||||
The configuration file for the salt-master is located at ``/etc/salt/master``
|
The configuration file for the salt-master is located at ``/etc/salt/master``
|
||||||
by default. Atomic included configuration files can be placed in
|
by default. Atomic included configuration files can be placed in
|
||||||
``/etc/salt/master.d/*.conf``. Warning: files with other suffixes than .conf will
|
``/etc/salt/master.d/*.conf``. Warning: files with other suffixes than .conf will
|
||||||
not be included. A notable exception is FreeBSD, where the configuration file is
|
not be included. A notable exception is FreeBSD, where the configuration file is
|
||||||
located at ``/usr/local/etc/salt``. The available options are as follows:
|
located at ``/usr/local/etc/salt``. The available options are as follows:
|
||||||
|
|
||||||
|
@ -2022,7 +2022,7 @@ Each minion connecting to the master uses AT LEAST one file descriptor, the
|
||||||
master subscription connection. If enough minions connect you might start
|
master subscription connection. If enough minions connect you might start
|
||||||
seeing on the console(and then salt-master crashes):
|
seeing on the console(and then salt-master crashes):
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: text
|
||||||
|
|
||||||
Too many open files (tcp_listener.cpp:335)
|
Too many open files (tcp_listener.cpp:335)
|
||||||
Aborted (core dumped)
|
Aborted (core dumped)
|
||||||
|
|
|
@ -97,7 +97,7 @@ included libraries.
|
||||||
|
|
||||||
Then, create the zip:
|
Then, create the zip:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
modules $ zip -r lumberjack lumberjack
|
modules $ zip -r lumberjack lumberjack
|
||||||
adding: lumberjack/ (stored 0%)
|
adding: lumberjack/ (stored 0%)
|
||||||
|
|
|
@ -125,4 +125,4 @@ responding to Salt calls could look like this:
|
||||||
client = salt.client.LocalClient(__opts__["conf_file"])
|
client = salt.client.LocalClient(__opts__["conf_file"])
|
||||||
minions = client.cmd("*", "test.version", timeout=1)
|
minions = client.cmd("*", "test.version", timeout=1)
|
||||||
for minion in sorted(minions):
|
for minion in sorted(minions):
|
||||||
print minion
|
print(minion)
|
||||||
|
|
|
@ -363,6 +363,8 @@ shown in json for clarity:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.. code-block:: json
|
||||||
|
|
||||||
{
|
{
|
||||||
"local": {
|
"local": {
|
||||||
"pkgrepo_|-salt-minion_|-salt-minion_|-managed": {
|
"pkgrepo_|-salt-minion_|-salt-minion_|-managed": {
|
||||||
|
|
|
@ -66,11 +66,12 @@ A well-written state function will follow these steps:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
ret = {"name": name, "result": False, "changes": {}, "comment": ""}
|
def myfunc():
|
||||||
|
ret = {"name": name, "result": False, "changes": {}, "comment": ""}
|
||||||
|
|
||||||
if foo and bar:
|
if foo and bar:
|
||||||
ret["comment"] = "Only one of foo and bar is permitted"
|
ret["comment"] = "Only one of foo and bar is permitted"
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
2. Check if changes need to be made. This is best done with an
|
2. Check if changes need to be made. This is best done with an
|
||||||
information-gathering function in an accompanying :ref:`execution module
|
information-gathering function in an accompanying :ref:`execution module
|
||||||
|
@ -87,10 +88,11 @@ A well-written state function will follow these steps:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
if result:
|
def myfunc():
|
||||||
ret["result"] = True
|
if result:
|
||||||
ret["comment"] = "{0} is already installed".format(name)
|
ret["result"] = True
|
||||||
return ret
|
ret["comment"] = "{0} is already installed".format(name)
|
||||||
|
return ret
|
||||||
|
|
||||||
4. If step 2 found that changes *do* need to be made, then check to see if the
|
4. If step 2 found that changes *do* need to be made, then check to see if the
|
||||||
state was being run in test mode (i.e. with ``test=True``). If so, then exit
|
state was being run in test mode (i.e. with ``test=True``). If so, then exit
|
||||||
|
@ -99,11 +101,12 @@ A well-written state function will follow these steps:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
if __opts__["test"]:
|
def myfunc():
|
||||||
ret["result"] = None
|
if __opts__["test"]:
|
||||||
ret["comment"] = "{0} would be installed".format(name)
|
ret["result"] = None
|
||||||
ret["changes"] = result
|
ret["comment"] = "{0} would be installed".format(name)
|
||||||
return ret
|
ret["changes"] = result
|
||||||
|
return ret
|
||||||
|
|
||||||
5. Make the desired changes. This should again be done using a function from an
|
5. Make the desired changes. This should again be done using a function from an
|
||||||
accompanying execution module. If the result of that function is enough to
|
accompanying execution module. If the result of that function is enough to
|
||||||
|
@ -132,13 +135,14 @@ A well-written state function will follow these steps:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
if ret["changes"]:
|
def myfunc():
|
||||||
ret["comment"] = "{0} failed to install".format(name)
|
if ret["changes"]:
|
||||||
else:
|
ret["comment"] = "{0} failed to install".format(name)
|
||||||
ret["result"] = True
|
else:
|
||||||
ret["comment"] = "{0} was installed".format(name)
|
ret["result"] = True
|
||||||
|
ret["comment"] = "{0} was installed".format(name)
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
Using Custom State Modules
|
Using Custom State Modules
|
||||||
==========================
|
==========================
|
||||||
|
@ -307,11 +311,12 @@ run. An example of such a check could look like this:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
# Return comment of changes if test.
|
def myfunc():
|
||||||
if __opts__["test"]:
|
# Return comment of changes if test.
|
||||||
ret["result"] = None
|
if __opts__["test"]:
|
||||||
ret["comment"] = "State Foo will execute with param {0}".format(bar)
|
ret["result"] = None
|
||||||
return ret
|
ret["comment"] = "State Foo will execute with param {0}".format(bar)
|
||||||
|
return ret
|
||||||
|
|
||||||
Make sure to test and return before performing any real actions on the minion.
|
Make sure to test and return before performing any real actions on the minion.
|
||||||
|
|
||||||
|
|
|
@ -949,7 +949,7 @@ Alternate Endpoint
|
||||||
Normally, EC2 endpoints are build using the region and the service_url. The
|
Normally, EC2 endpoints are build using the region and the service_url. The
|
||||||
resulting endpoint would follow this pattern:
|
resulting endpoint would follow this pattern:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: text
|
||||||
|
|
||||||
ec2.<region>.<service_url>
|
ec2.<region>.<service_url>
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ command:
|
||||||
Images can be obtained using the ``--list-images`` option for the ``salt-cloud``
|
Images can be obtained using the ``--list-images`` option for the ``salt-cloud``
|
||||||
command:
|
command:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
# salt-cloud --list-images exoscale
|
# salt-cloud --list-images exoscale
|
||||||
exoscale:
|
exoscale:
|
||||||
|
|
|
@ -652,36 +652,38 @@ data:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
"providers": {
|
{
|
||||||
"my-develop-envs": [
|
"providers": {
|
||||||
{
|
"my-develop-envs": [
|
||||||
"availability_zone": "ap-southeast-1b",
|
{
|
||||||
"id": "HJGRYCILJLKJYG",
|
"availability_zone": "ap-southeast-1b",
|
||||||
"key": "kdjgfsgm;woormgl/aserigjksjdhasdfgn",
|
"id": "HJGRYCILJLKJYG",
|
||||||
"keyname": "test",
|
"key": "kdjgfsgm;woormgl/aserigjksjdhasdfgn",
|
||||||
"location": "ap-southeast-1",
|
"keyname": "test",
|
||||||
"private_key": "/root/test.pem",
|
"location": "ap-southeast-1",
|
||||||
"driver": "aws",
|
"private_key": "/root/test.pem",
|
||||||
"securitygroup": "quick-start",
|
"driver": "aws",
|
||||||
},
|
"securitygroup": "quick-start",
|
||||||
{
|
},
|
||||||
"location": "Raleigh",
|
{
|
||||||
"password": "mypass",
|
"location": "Raleigh",
|
||||||
"driver": "ibmsce",
|
"password": "mypass",
|
||||||
"ssh_key_file": "/etc/salt/ibm/mykey.pem",
|
"driver": "ibmsce",
|
||||||
"ssh_key_name": "mykey",
|
"ssh_key_file": "/etc/salt/ibm/mykey.pem",
|
||||||
"user": "myuser@mycorp.com",
|
"ssh_key_name": "mykey",
|
||||||
},
|
"user": "myuser@mycorp.com",
|
||||||
],
|
},
|
||||||
"my-productions-envs": [
|
],
|
||||||
{
|
"my-productions-envs": [
|
||||||
"availability_zone": "us-east-1",
|
{
|
||||||
"location": "us-east-1",
|
"availability_zone": "us-east-1",
|
||||||
"password": "mypass",
|
"location": "us-east-1",
|
||||||
"driver": "ibmsce",
|
"password": "mypass",
|
||||||
"ssh_key_file": "/etc/salt/ibm/mykey.pem",
|
"driver": "ibmsce",
|
||||||
"ssh_key_name": "mykey",
|
"ssh_key_file": "/etc/salt/ibm/mykey.pem",
|
||||||
"user": "my-production-user@mycorp.com",
|
"ssh_key_name": "mykey",
|
||||||
}
|
"user": "my-production-user@mycorp.com",
|
||||||
],
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ command --list-sizes is run a default will be returned).
|
||||||
Images can be obtained using the ``--list-images`` option for the ``salt-cloud``
|
Images can be obtained using the ``--list-images`` option for the ``salt-cloud``
|
||||||
command:
|
command:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
# salt-cloud --list-images my-dimensiondata-config
|
# salt-cloud --list-images my-dimensiondata-config
|
||||||
my-dimensiondata-config:
|
my-dimensiondata-config:
|
||||||
|
|
|
@ -89,7 +89,7 @@ command:
|
||||||
Images can be obtained using the ``--list-images`` option for the ``salt-cloud``
|
Images can be obtained using the ``--list-images`` option for the ``salt-cloud``
|
||||||
command:
|
command:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
# salt-cloud --list-images my-gogrid-config
|
# salt-cloud --list-images my-gogrid-config
|
||||||
my-gogrid-config:
|
my-gogrid-config:
|
||||||
|
|
|
@ -93,7 +93,7 @@ command:
|
||||||
Images can be obtained using the ``--list-images`` option for the ``salt-cloud``
|
Images can be obtained using the ``--list-images`` option for the ``salt-cloud``
|
||||||
command:
|
command:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
# salt-cloud --list-images my-joyent-config
|
# salt-cloud --list-images my-joyent-config
|
||||||
my-joyent-config:
|
my-joyent-config:
|
||||||
|
|
|
@ -67,7 +67,7 @@ List Cloud Provider Options
|
||||||
You can now query the cloud provider you configured for available locations,
|
You can now query the cloud provider you configured for available locations,
|
||||||
images, and sizes. This information is used when you set up VM profiles.
|
images, and sizes. This information is used when you set up VM profiles.
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
salt-cloud --list-locations <provider_name> # my-ec2 in the previous example
|
salt-cloud --list-locations <provider_name> # my-ec2 in the previous example
|
||||||
salt-cloud --list-images <provider_name>
|
salt-cloud --list-images <provider_name>
|
||||||
|
@ -109,7 +109,7 @@ Create VMs
|
||||||
----------
|
----------
|
||||||
VMs are created by calling ``salt-cloud`` with the following options:
|
VMs are created by calling ``salt-cloud`` with the following options:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
salt-cloud -p <profile> <name1> <name2> ...
|
salt-cloud -p <profile> <name1> <name2> ...
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ Set up an initial profile at /etc/salt/cloud.profiles or in the /etc/salt/cloud.
|
||||||
|
|
||||||
Images can be obtained using the ``--list-images`` option for the ``salt-cloud`` command:
|
Images can be obtained using the ``--list-images`` option for the ``salt-cloud`` command:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
#salt-cloud --list-images my-scaleway-config
|
#salt-cloud --list-images my-scaleway-config
|
||||||
my-scaleway-config:
|
my-scaleway-config:
|
||||||
|
@ -81,7 +81,7 @@ Images can be obtained using the ``--list-images`` option for the ``salt-cloud``
|
||||||
|
|
||||||
Execute a query and return all information about the nodes running on configured cloud providers using the ``-Q`` option for the ``salt-cloud`` command:
|
Execute a query and return all information about the nodes running on configured cloud providers using the ``-Q`` option for the ``salt-cloud`` command:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
# salt-cloud -F
|
# salt-cloud -F
|
||||||
[INFO ] salt-cloud starting
|
[INFO ] salt-cloud starting
|
||||||
|
|
|
@ -122,7 +122,7 @@ following command:
|
||||||
The if the output of this command includes a line that looks like this, then
|
The if the output of this command includes a line that looks like this, then
|
||||||
the ``/tmp/`` directory is mounted as ``noexec``:
|
the ``/tmp/`` directory is mounted as ``noexec``:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
tmpfs on /tmp type tmpfs (rw,noexec)
|
tmpfs on /tmp type tmpfs (rw,noexec)
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,7 @@ Create and use your new Salt minion
|
||||||
|
|
||||||
.. _this gist: https://github.com/jirsbek/SSH-keys-in-macOS-Sierra-keychain
|
.. _this gist: https://github.com/jirsbek/SSH-keys-in-macOS-Sierra-keychain
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
ssh -A vagrant@< the bridged network address >
|
ssh -A vagrant@< the bridged network address >
|
||||||
# [ or, if you are at /home/my_username/ on my_laptop ]
|
# [ or, if you are at /home/my_username/ on my_laptop ]
|
||||||
|
@ -251,7 +251,7 @@ Create and use your new Salt minion
|
||||||
|
|
||||||
- then typing on your new node "v1" (a.k.a. quail1.bevy1.test)...
|
- then typing on your new node "v1" (a.k.a. quail1.bevy1.test)...
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
password: vagrant
|
password: vagrant
|
||||||
# [ stuff types out ... ]
|
# [ stuff types out ... ]
|
||||||
|
|
|
@ -172,7 +172,7 @@ If you would like to log to the console instead of to the log file, remove the
|
||||||
|
|
||||||
Once the minion starts, you may see an error like the following:
|
Once the minion starts, you may see an error like the following:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
zmq.core.error.ZMQError: ipc path "/path/to/your/virtualenv/
|
zmq.core.error.ZMQError: ipc path "/path/to/your/virtualenv/
|
||||||
var/run/salt/minion/minion_event_7824dcbcfd7a8f6755939af70b96249f_pub.ipc"
|
var/run/salt/minion/minion_event_7824dcbcfd7a8f6755939af70b96249f_pub.ipc"
|
||||||
|
|
|
@ -82,6 +82,7 @@ Deprecated and destined to be removed. For now, should just do the following:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
|
def myfunc():
|
||||||
return __salt__["pkg.latest_version"](name) != ""
|
return __salt__["pkg.latest_version"](name) != ""
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,7 +139,8 @@ return the output of ``salt.utils.data.compare_dicts()``:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
return salt.utils.data.compare_dicts(old, new)
|
def myfunc():
|
||||||
|
return salt.utils.data.compare_dicts(old, new)
|
||||||
|
|
||||||
|
|
||||||
remove
|
remove
|
||||||
|
@ -174,7 +176,7 @@ Lists the repositories that are currently configured on this system.
|
||||||
|
|
||||||
Returns a dictionary, in the following format:
|
Returns a dictionary, in the following format:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: pycon
|
||||||
|
|
||||||
{'reponame': 'config_key_1': 'config value 1',
|
{'reponame': 'config_key_1': 'config value 1',
|
||||||
'config_key_2': 'config value 2',
|
'config_key_2': 'config value 2',
|
||||||
|
@ -192,7 +194,7 @@ Displays all local configuration for a specific repository.
|
||||||
The information is formatted in much the same way as list_repos, but is
|
The information is formatted in much the same way as list_repos, but is
|
||||||
specific to only one repo.
|
specific to only one repo.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: pycon
|
||||||
|
|
||||||
{'config_key_1': 'config value 1',
|
{'config_key_1': 'config value 1',
|
||||||
'config_key_2': 'config value 2',
|
'config_key_2': 'config value 2',
|
||||||
|
|
|
@ -347,18 +347,19 @@ Testing salt-ssh functionality can be done using the SSHCase test class:
|
||||||
|
|
||||||
from tests.support.case import SSHCase
|
from tests.support.case import SSHCase
|
||||||
|
|
||||||
class SSHGrainsTest(SSHCase):
|
|
||||||
'''
|
|
||||||
Test salt-ssh grains functionality
|
|
||||||
Depend on proper environment set by integration.SSHCase class
|
|
||||||
'''
|
|
||||||
|
|
||||||
def test_grains_id(self):
|
class SSHGrainsTest(SSHCase):
|
||||||
'''
|
"""
|
||||||
Test salt-ssh grains id work for localhost.
|
Test salt-ssh grains functionality
|
||||||
'''
|
Depend on proper environment set by integration.SSHCase class
|
||||||
cmd = self.run_function('grains.get', ['id'])
|
"""
|
||||||
self.assertEqual(cmd, 'localhost')
|
|
||||||
|
def test_grains_id(self):
|
||||||
|
"""
|
||||||
|
Test salt-ssh grains id work for localhost.
|
||||||
|
"""
|
||||||
|
cmd = self.run_function("grains.get", ["id"])
|
||||||
|
self.assertEqual(cmd, "localhost")
|
||||||
|
|
||||||
|
|
||||||
Testing Event System via SaltMinionEventAssertsMixin
|
Testing Event System via SaltMinionEventAssertsMixin
|
||||||
|
@ -582,43 +583,42 @@ contain valid information are also required in the test class's ``setUp`` functi
|
||||||
from tests.support.case import ShellCase
|
from tests.support.case import ShellCase
|
||||||
from tests.support.paths import FILES
|
from tests.support.paths import FILES
|
||||||
|
|
||||||
|
|
||||||
class LinodeTest(ShellCase):
|
class LinodeTest(ShellCase):
|
||||||
'''
|
"""
|
||||||
Integration tests for the Linode cloud provider in Salt-Cloud
|
Integration tests for the Linode cloud provider in Salt-Cloud
|
||||||
'''
|
"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
'''
|
"""
|
||||||
Sets up the test requirements
|
Sets up the test requirements
|
||||||
'''
|
"""
|
||||||
super(LinodeTest, self).setUp()
|
super(LinodeTest, self).setUp()
|
||||||
|
|
||||||
# check if appropriate cloud provider and profile files are present
|
# check if appropriate cloud provider and profile files are present
|
||||||
profile_str = 'linode-config:'
|
profile_str = "linode-config:"
|
||||||
provider = 'linode'
|
provider = "linode"
|
||||||
providers = self.run_cloud('--list-providers')
|
providers = self.run_cloud("--list-providers")
|
||||||
if profile_str not in providers:
|
if profile_str not in providers:
|
||||||
self.skipTest(
|
self.skipTest(
|
||||||
'Configuration file for {0} was not found. Check {0}.conf files '
|
"Configuration file for {0} was not found. Check {0}.conf files "
|
||||||
'in tests/integration/files/conf/cloud.*.d/ to run these tests.'
|
"in tests/integration/files/conf/cloud.*.d/ to run these tests.".format(
|
||||||
.format(provider)
|
provider
|
||||||
)
|
)
|
||||||
|
)
|
||||||
# check if apikey and password are present
|
|
||||||
path = os.path.join(FILES,
|
# check if apikey and password are present
|
||||||
'conf',
|
path = os.path.join(FILES, "conf", "cloud.providers.d", provider + ".conf")
|
||||||
'cloud.providers.d',
|
config = cloud_providers_config(path)
|
||||||
provider + '.conf')
|
api = config["linode-config"]["linode"]["apikey"]
|
||||||
config = cloud_providers_config(path)
|
password = config["linode-config"]["linode"]["password"]
|
||||||
api = config['linode-config']['linode']['apikey']
|
if api == "" or password == "":
|
||||||
password = config['linode-config']['linode']['password']
|
self.skipTest(
|
||||||
if api == '' or password == '':
|
"An api key and password must be provided to run these tests. Check "
|
||||||
self.skipTest(
|
"tests/integration/files/conf/cloud.providers.d/{0}.conf".format(
|
||||||
'An api key and password must be provided to run these tests. Check '
|
provider
|
||||||
'tests/integration/files/conf/cloud.providers.d/{0}.conf'.format(
|
)
|
||||||
provider
|
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
Repeatedly creating and destroying instances on cloud providers can be costly.
|
Repeatedly creating and destroying instances on cloud providers can be costly.
|
||||||
Therefore, cloud provider tests are off by default and do not run automatically. To
|
Therefore, cloud provider tests are off by default and do not run automatically. To
|
||||||
|
|
|
@ -146,7 +146,7 @@ Push
|
||||||
Push your branch to your GitHub account. You will likely need to enter your
|
Push your branch to your GitHub account. You will likely need to enter your
|
||||||
GitHub username and password.
|
GitHub username and password.
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
$ git push origin virt_ret
|
$ git push origin virt_ret
|
||||||
Username for 'https://github.com': <my_account>
|
Username for 'https://github.com': <my_account>
|
||||||
|
@ -159,7 +159,7 @@ GitHub username and password.
|
||||||
you have done this, you may need add the keys to your git repository
|
you have done this, you may need add the keys to your git repository
|
||||||
configuration
|
configuration
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
$ git config ssh.key ~/.ssh/<key_name>
|
$ git config ssh.key ~/.ssh/<key_name>
|
||||||
|
|
||||||
|
|
|
@ -247,10 +247,9 @@ done at the CLI:
|
||||||
|
|
||||||
caller = salt.client.Caller()
|
caller = salt.client.Caller()
|
||||||
|
|
||||||
ret = caller.cmd('event.send',
|
ret = caller.cmd(
|
||||||
'myco/event/success'
|
"event.send", "myco/event/success", {"success": True, "message": "It works!"}
|
||||||
{ 'success': True,
|
)
|
||||||
'message': "It works!" })
|
|
||||||
|
|
||||||
if not ret:
|
if not ret:
|
||||||
# the event could not be sent, process the error here
|
# the event could not be sent, process the error here
|
||||||
|
|
|
@ -217,7 +217,7 @@ grain data structure. For example, consider this custom grain file:
|
||||||
|
|
||||||
The output of this example renders like so:
|
The output of this example renders like so:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
# salt-call --local grains.items
|
# salt-call --local grains.items
|
||||||
local:
|
local:
|
||||||
|
@ -235,7 +235,7 @@ the function will be rendered twice by Salt in the items output: once for the
|
||||||
``my_custom_grain`` call itself, and again when it is called in the ``main``
|
``my_custom_grain`` call itself, and again when it is called in the ``main``
|
||||||
function:
|
function:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
# salt-call --local grains.items
|
# salt-call --local grains.items
|
||||||
local:
|
local:
|
||||||
|
|
|
@ -6,7 +6,7 @@ The Salt minion for Arista EOS is distributed as a SWIX extension and can be ins
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
This SWIX extension has been tested on Arista DCS-7280SE-68-R, running EOS 4.17.5M and vEOS 4.18.3F.
|
This SWIX extension has been tested on Arista DCS-7280SE-68-R, running EOS 4.17.5M and vEOS 4.18.3F.
|
||||||
|
|
||||||
Important Notes
|
Important Notes
|
||||||
===============
|
===============
|
||||||
|
@ -46,8 +46,8 @@ Verify the installation
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
veos#show extensions | include salt-eos
|
veos#show extensions | include salt-eos
|
||||||
salt-eos-2017-07-19.swix 1.0.11/1.fc25 A, F 27
|
salt-eos-2017-07-19.swix 1.0.11/1.fc25 A, F 27
|
||||||
|
|
||||||
Change the Salt master IP address or FQDN, by edit the variable (SALT_MASTER)
|
Change the Salt master IP address or FQDN, by edit the variable (SALT_MASTER)
|
||||||
|
|
||||||
|
@ -55,9 +55,9 @@ Change the Salt master IP address or FQDN, by edit the variable (SALT_MASTER)
|
||||||
|
|
||||||
veos#bash vi /mnt/flash/startup.sh
|
veos#bash vi /mnt/flash/startup.sh
|
||||||
|
|
||||||
Make sure you enable the eAPI with unix-socket
|
Make sure you enable the eAPI with unix-socket
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
veos(config)#management api http-commands
|
veos(config)#management api http-commands
|
||||||
protocol unix-socket
|
protocol unix-socket
|
||||||
|
@ -70,7 +70,7 @@ Generate Keys and host record and start Salt minion
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
veos#bash
|
veos#bash
|
||||||
#sudo /mnt/flash/startup.sh
|
#sudo /mnt/flash/startup.sh
|
||||||
|
|
||||||
``salt-minion`` should be running
|
``salt-minion`` should be running
|
||||||
|
@ -79,14 +79,14 @@ Copy the installed extensions to boot-extensions
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
veos#copy installed-extensions boot-extensions
|
veos#copy installed-extensions boot-extensions
|
||||||
|
|
||||||
Apply event-handler to let EOS start salt-minion during boot-up
|
Apply event-handler to let EOS start salt-minion during boot-up
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
veos(config)#event-handler boot-up-script
|
veos(config)#event-handler boot-up-script
|
||||||
trigger on-boot
|
trigger on-boot
|
||||||
action bash sudo /mnt/flash/startup.sh
|
action bash sudo /mnt/flash/startup.sh
|
||||||
|
|
||||||
For more specific installation details of the ``salt-minion``, please refer to :ref:`Configuring Salt<configuring-salt>`.
|
For more specific installation details of the ``salt-minion``, please refer to :ref:`Configuring Salt<configuring-salt>`.
|
||||||
|
@ -112,7 +112,7 @@ If you decide to uninstall this package, the following steps are recommended for
|
||||||
|
|
||||||
2. Remove boot-up script
|
2. Remove boot-up script
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
veos(config)#no event-handler boot-up-script
|
veos(config)#no event-handler boot-up-script
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ Starting in release ``9.2(1)`` and onward, the .ova file can be copied to the ``
|
||||||
|
|
||||||
Copy the ``guestshell.ova`` file to ``volatile:`` if supported, otherwise copy it to ``bootflash:``
|
Copy the ``guestshell.ova`` file to ``volatile:`` if supported, otherwise copy it to ``bootflash:``
|
||||||
|
|
||||||
.. code:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
n3xxx# copy scp://admin@1.2.3.4/guestshell.ova volatile: vrf management
|
n3xxx# copy scp://admin@1.2.3.4/guestshell.ova volatile: vrf management
|
||||||
guestshell.ova 100% 55MB 10.9MB/s 00:05
|
guestshell.ova 100% 55MB 10.9MB/s 00:05
|
||||||
|
@ -174,7 +174,7 @@ Copy the ``guestshell.ova`` file to ``volatile:`` if supported, otherwise copy i
|
||||||
|
|
||||||
Use the ``guestshell enable`` command to install and enable guestshell.
|
Use the ``guestshell enable`` command to install and enable guestshell.
|
||||||
|
|
||||||
.. code:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
n3xxx# guestshell enable package volatile:guestshell.ova
|
n3xxx# guestshell enable package volatile:guestshell.ova
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ The ``guestshell`` container environment is enabled by default on most platforms
|
||||||
|
|
||||||
**Example.** Allocate resources for guestshell by setting new limits to 500MB disk and 350MB memory.
|
**Example.** Allocate resources for guestshell by setting new limits to 500MB disk and 350MB memory.
|
||||||
|
|
||||||
.. code:: bash
|
.. code:: console
|
||||||
|
|
||||||
n3k# guestshell resize rootfs 500
|
n3k# guestshell resize rootfs 500
|
||||||
n3k# guestshell resize memory 350
|
n3k# guestshell resize memory 350
|
||||||
|
@ -238,7 +238,7 @@ The ``guestshell`` is an independent CentOS container that does not inherit sett
|
||||||
|
|
||||||
**OPTIONAL: Add DNS Configuration**
|
**OPTIONAL: Add DNS Configuration**
|
||||||
|
|
||||||
.. code:: bash
|
.. code:: console
|
||||||
|
|
||||||
[root@guestshell guestshell]# cat >> /etc/resolv.conf << EOF
|
[root@guestshell guestshell]# cat >> /etc/resolv.conf << EOF
|
||||||
nameserver 10.0.0.202
|
nameserver 10.0.0.202
|
||||||
|
@ -248,7 +248,7 @@ The ``guestshell`` is an independent CentOS container that does not inherit sett
|
||||||
|
|
||||||
**OPTIONAL: Define proxy server variables if needed to allow network access to SaltStack package repositories**
|
**OPTIONAL: Define proxy server variables if needed to allow network access to SaltStack package repositories**
|
||||||
|
|
||||||
.. code:: bash
|
.. code:: console
|
||||||
|
|
||||||
export http_proxy=http://proxy.yourdomain.com:<port>
|
export http_proxy=http://proxy.yourdomain.com:<port>
|
||||||
export https_proxy=https://proxy.yourdomain.com:<port>
|
export https_proxy=https://proxy.yourdomain.com:<port>
|
||||||
|
|
|
@ -1348,7 +1348,7 @@ Example:
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: pycon
|
||||||
|
|
||||||
{
|
{
|
||||||
'body': '{
|
'body': '{
|
||||||
|
@ -2205,7 +2205,7 @@ log at the ``profile`` level along with the render time of the block.
|
||||||
The ``profile`` block in the ``example.sls`` state will emit the following log
|
The ``profile`` block in the ``example.sls`` state will emit the following log
|
||||||
statement:
|
statement:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
# salt-call --local -l profile state.apply example
|
# salt-call --local -l profile state.apply example
|
||||||
[...]
|
[...]
|
||||||
|
@ -2241,7 +2241,7 @@ Using the same logic as the ``profile`` block, the ``import_yaml``,
|
||||||
|
|
||||||
For ``import_*`` blocks, the ``profile`` log statement has the following form:
|
For ``import_*`` blocks, the ``profile`` log statement has the following form:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
# salt-call --local -l profile state.apply example
|
# salt-call --local -l profile state.apply example
|
||||||
[...]
|
[...]
|
||||||
|
|
|
@ -240,7 +240,7 @@ Grains Changes
|
||||||
|
|
||||||
New behavior:
|
New behavior:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
root@master:~# salt 'testwin200' grains.item cpu_model
|
root@master:~# salt 'testwin200' grains.item cpu_model
|
||||||
testwin200:
|
testwin200:
|
||||||
|
|
|
@ -713,7 +713,7 @@ Alternatively, the newly-added :py:func:`pkg.show <salt.modules.aptpkg.show>`
|
||||||
function can be used to get more detailed information about a given package and
|
function can be used to get more detailed information about a given package and
|
||||||
help determine what package name is correct:
|
help determine what package name is correct:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
# salt myminion pkg.show 'nginx*' filter=description,provides
|
# salt myminion pkg.show 'nginx*' filter=description,provides
|
||||||
myminion:
|
myminion:
|
||||||
|
@ -955,7 +955,7 @@ Those who are using the :ref:`LocalClient <local-client>` (either directly,
|
||||||
or implicitly via a :ref:`netapi module <all-netapi-modules>`) need to update
|
or implicitly via a :ref:`netapi module <all-netapi-modules>`) need to update
|
||||||
their code to use ``tgt_type``.
|
their code to use ``tgt_type``.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: pycon
|
||||||
|
|
||||||
>>> import salt.client
|
>>> import salt.client
|
||||||
>>> local = salt.client.LocalClient()
|
>>> local = salt.client.LocalClient()
|
||||||
|
|
|
@ -292,7 +292,7 @@ A new :py:func:`state <salt.states.keystore>` and
|
||||||
Keystore files is now included. It allows for adding/removing/listing
|
Keystore files is now included. It allows for adding/removing/listing
|
||||||
as well as managing keystore files.
|
as well as managing keystore files.
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
# salt-call keystore.list /path/to/keystore.jks changeit
|
# salt-call keystore.list /path/to/keystore.jks changeit
|
||||||
local:
|
local:
|
||||||
|
|
|
@ -115,7 +115,7 @@ Then install salt using the following command:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
sudo pip install salt==<rc tag version>
|
sudo pip install salt==$rc_tag_version
|
||||||
|
|
||||||
For example for the 3002rc1 release:
|
For example for the 3002rc1 release:
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,10 @@ connection object, then that connection object is returned. For instance, the
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
conn = sqlite3.connect(__opts__["spm_db"], isolation_level=None)
|
def myfunc():
|
||||||
...
|
conn = sqlite3.connect(__opts__["spm_db"], isolation_level=None)
|
||||||
return conn
|
...
|
||||||
|
return conn
|
||||||
|
|
||||||
SPM itself will not use this connection object; it will be passed in as-is to
|
SPM itself will not use this connection object; it will be passed in as-is to
|
||||||
the other functions in the module. Therefore, when you set up this object, make
|
the other functions in the module. Therefore, when you set up this object, make
|
||||||
|
|
|
@ -112,7 +112,7 @@ The salt-master needs at least 2 sockets per host that connects to it, one for
|
||||||
the Publisher and one for response port. Thus, large installations may, upon
|
the Publisher and one for response port. Thus, large installations may, upon
|
||||||
scaling up the number of minions accessing a given master, encounter:
|
scaling up the number of minions accessing a given master, encounter:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
12:45:29,289 [salt.master ][INFO ] Starting Salt worker process 38
|
12:45:29,289 [salt.master ][INFO ] Starting Salt worker process 38
|
||||||
Too many open files
|
Too many open files
|
||||||
|
|
|
@ -47,7 +47,7 @@ The salt-master needs at least 2 sockets per host that connects to it, one for
|
||||||
the Publisher and one for response port. Thus, large installations may, upon
|
the Publisher and one for response port. Thus, large installations may, upon
|
||||||
scaling up the number of minions accessing a given master, encounter:
|
scaling up the number of minions accessing a given master, encounter:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
12:45:29,289 [salt.master ][INFO ] Starting Salt worker process 38
|
12:45:29,289 [salt.master ][INFO ] Starting Salt worker process 38
|
||||||
Too many open files
|
Too many open files
|
||||||
|
@ -188,7 +188,7 @@ profiling graphs could use `gprof2dot`_, `graphviz`_ and this batch file:
|
||||||
.. _`gprof2dot`: https://pypi.org/project/gprof2dot
|
.. _`gprof2dot`: https://pypi.org/project/gprof2dot
|
||||||
.. _`graphviz`: https://graphviz.gitlab.io
|
.. _`graphviz`: https://graphviz.gitlab.io
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: batch
|
||||||
|
|
||||||
::
|
::
|
||||||
:: Converts callgrind* profiler output to *.pdf, via *.dot
|
:: Converts callgrind* profiler output to *.pdf, via *.dot
|
||||||
|
|
|
@ -35,7 +35,7 @@ on various platforms.
|
||||||
If you have netcat installed, you can check port connectivity from the minion
|
If you have netcat installed, you can check port connectivity from the minion
|
||||||
with the ``nc`` command:
|
with the ``nc`` command:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
$ nc -v -z salt.master.ip.addr 4505
|
$ nc -v -z salt.master.ip.addr 4505
|
||||||
Connection to salt.master.ip.addr 4505 port [tcp/unknown] succeeded!
|
Connection to salt.master.ip.addr 4505 port [tcp/unknown] succeeded!
|
||||||
|
@ -44,7 +44,7 @@ with the ``nc`` command:
|
||||||
|
|
||||||
The `Nmap`_ utility can also be used to check if these ports are open:
|
The `Nmap`_ utility can also be used to check if these ports are open:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
# nmap -sS -q -p 4505-4506 salt.master.ip.addr
|
# nmap -sS -q -p 4505-4506 salt.master.ip.addr
|
||||||
|
|
||||||
|
|
|
@ -342,7 +342,7 @@ to the minions to refresh the pillar to pick up on the change:
|
||||||
Now, migration routines can be run! To migrate a VM, simply run the Salt Virt
|
Now, migration routines can be run! To migrate a VM, simply run the Salt Virt
|
||||||
migrate routine:
|
migrate routine:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
salt-run virt.migrate centos <new hypervisor>
|
salt-run virt.migrate centos <new hypervisor>
|
||||||
|
|
||||||
|
|
|
@ -1012,7 +1012,7 @@ host key in the ``~/.ssh/known_hosts`` file. If the master is also a minion,
|
||||||
this can be done using the :mod:`ssh.set_known_host
|
this can be done using the :mod:`ssh.set_known_host
|
||||||
<salt.modules.ssh.set_known_host>` function:
|
<salt.modules.ssh.set_known_host>` function:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
# salt mymaster ssh.set_known_host user=root hostname=github.com
|
# salt mymaster ssh.set_known_host user=root hostname=github.com
|
||||||
mymaster:
|
mymaster:
|
||||||
|
@ -1056,7 +1056,7 @@ Verifying the Fingerprint
|
||||||
To verify that the correct fingerprint was added, it is a good idea to look it
|
To verify that the correct fingerprint was added, it is a good idea to look it
|
||||||
up. One way to do this is to use ``nmap``:
|
up. One way to do this is to use ``nmap``:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
$ nmap -p 22 github.com --script ssh-hostkey
|
$ nmap -p 22 github.com --script ssh-hostkey
|
||||||
|
|
||||||
|
@ -1138,7 +1138,7 @@ steps to this process:
|
||||||
all users to fire the event. Add the following policy to the sudoers file
|
all users to fire the event. Add the following policy to the sudoers file
|
||||||
on the git server.
|
on the git server.
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
Cmnd_Alias SALT_GIT_HOOK = /bin/salt-call event.fire_master update salt/fileserver/gitfs/update
|
Cmnd_Alias SALT_GIT_HOOK = /bin/salt-call event.fire_master update salt/fileserver/gitfs/update
|
||||||
Defaults!SALT_GIT_HOOK !requiretty
|
Defaults!SALT_GIT_HOOK !requiretty
|
||||||
|
|
|
@ -469,8 +469,9 @@ value of match in the return text. In Python terms this looks like:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
if match in html_text:
|
def myfunc():
|
||||||
return True
|
if match in html_text:
|
||||||
|
return True
|
||||||
|
|
||||||
If more complex pattern matching is required, a regular expression can be used
|
If more complex pattern matching is required, a regular expression can be used
|
||||||
by specifying a ``match_type``. By default this is set to ``string``, but it
|
by specifying a ``match_type``. By default this is set to ``string``, but it
|
||||||
|
|
|
@ -144,7 +144,7 @@ be doubled after each attempt to reconnect (ZeroMQ default behavior).
|
||||||
|
|
||||||
Lets say the generated random value is 11 seconds (or 11000ms).
|
Lets say the generated random value is 11 seconds (or 11000ms).
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
reconnect 1: wait 11 seconds
|
reconnect 1: wait 11 seconds
|
||||||
reconnect 2: wait 22 seconds
|
reconnect 2: wait 22 seconds
|
||||||
|
|
|
@ -18,17 +18,17 @@ you to manage different cloud resources through a unified and easy to use API. A
|
||||||
Execution and state modules are available for Compute, DNS, Storage and Load Balancer drivers from Apache Libcloud in
|
Execution and state modules are available for Compute, DNS, Storage and Load Balancer drivers from Apache Libcloud in
|
||||||
SaltStack.
|
SaltStack.
|
||||||
|
|
||||||
* :mod:`libcloud_compute <salt.modules.libcloud_compute>` - Compute -
|
* :mod:`libcloud_compute <salt.modules.libcloud_compute>` - Compute -
|
||||||
services such as OpenStack Nova, Amazon EC2, Microsoft Azure VMs
|
services such as OpenStack Nova, Amazon EC2, Microsoft Azure VMs
|
||||||
* :mod:`libcloud_dns <salt.modules.libcloud_dns>` - DNS as a Service -
|
* :mod:`libcloud_dns <salt.modules.libcloud_dns>` - DNS as a Service -
|
||||||
services such as Amazon Route 53 and Zerigo
|
services such as Amazon Route 53 and Zerigo
|
||||||
* :mod:`libcloud_loadbalancer <salt.modules.libcloud_loadbalancer>` - Load Balancers as a Service -
|
* :mod:`libcloud_loadbalancer <salt.modules.libcloud_loadbalancer>` - Load Balancers as a Service -
|
||||||
services such as Amazon Elastic Load Balancer and GoGrid LoadBalancers
|
services such as Amazon Elastic Load Balancer and GoGrid LoadBalancers
|
||||||
* :mod:`libcloud_storage <salt.modules.libcloud_storage>` - Cloud Object Storage and CDN -
|
* :mod:`libcloud_storage <salt.modules.libcloud_storage>` - Cloud Object Storage and CDN -
|
||||||
services such as Amazon S3 and Rackspace CloudFiles, OpenStack Swift
|
services such as Amazon S3 and Rackspace CloudFiles, OpenStack Swift
|
||||||
|
|
||||||
|
|
||||||
These modules are designed as a way of having a multi-cloud deployment and abstracting simple differences
|
These modules are designed as a way of having a multi-cloud deployment and abstracting simple differences
|
||||||
between platform to design a high-availability architecture.
|
between platform to design a high-availability architecture.
|
||||||
|
|
||||||
The Apache Libcloud functionality is available through both execution modules and Salt states.
|
The Apache Libcloud functionality is available through both execution modules and Salt states.
|
||||||
|
@ -39,11 +39,11 @@ Configuring Drivers
|
||||||
Drivers can be configured in the Salt Configuration/Minion settings. All libcloud modules expect a list of "profiles" to
|
Drivers can be configured in the Salt Configuration/Minion settings. All libcloud modules expect a list of "profiles" to
|
||||||
be configured with authentication details for each driver.
|
be configured with authentication details for each driver.
|
||||||
|
|
||||||
Each driver will have a string identifier, these can be found in the libcloud.<api>.types.Provider class
|
Each driver will have a string identifier, these can be found in the libcloud.<api>.types.Provider class
|
||||||
for each API, https://libcloud.readthedocs.io/en/latest/supported_providers.html
|
for each API, https://libcloud.readthedocs.io/en/latest/supported_providers.html
|
||||||
|
|
||||||
Some drivers require additional parameters, which are documented in the Apache Libcloud documentation. For example,
|
Some drivers require additional parameters, which are documented in the Apache Libcloud documentation. For example,
|
||||||
GoDaddy DNS expects "`shopper_id`", which is the customer ID. These additional parameters can be added to the profile settings
|
GoDaddy DNS expects "`shopper_id`", which is the customer ID. These additional parameters can be added to the profile settings
|
||||||
and will be passed directly to the driver instantiation method.
|
and will be passed directly to the driver instantiation method.
|
||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
@ -80,25 +80,25 @@ administrators distinguish their purpose.
|
||||||
Using the execution modules
|
Using the execution modules
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
Amongst over 60 clouds that Apache Libcloud supports, you can add profiles to your Salt configuration to access and control these clouds.
|
Amongst over 60 clouds that Apache Libcloud supports, you can add profiles to your Salt configuration to access and control these clouds.
|
||||||
Each of the libcloud execution modules exposes the common API methods for controlling Compute, DNS, Load Balancers and Object Storage.
|
Each of the libcloud execution modules exposes the common API methods for controlling Compute, DNS, Load Balancers and Object Storage.
|
||||||
To see which functions are supported across specific clouds, see the Libcloud `supported methods
|
To see which functions are supported across specific clouds, see the Libcloud `supported methods
|
||||||
<https://libcloud.readthedocs.io/en/latest/supported_providers.html#supported-methods-block-storage>`_ documentation.
|
<https://libcloud.readthedocs.io/en/latest/supported_providers.html#supported-methods-block-storage>`_ documentation.
|
||||||
|
|
||||||
The module documentation explains each of the API methods and how to leverage them.
|
The module documentation explains each of the API methods and how to leverage them.
|
||||||
|
|
||||||
* :mod:`libcloud_compute <salt.modules.libcloud_compute>` - Compute -
|
* :mod:`libcloud_compute <salt.modules.libcloud_compute>` - Compute -
|
||||||
services such as OpenStack Nova, Amazon EC2, Microsoft Azure VMs
|
services such as OpenStack Nova, Amazon EC2, Microsoft Azure VMs
|
||||||
* :mod:`libcloud_dns <salt.modules.libcloud_dns>` - DNS as a Service -
|
* :mod:`libcloud_dns <salt.modules.libcloud_dns>` - DNS as a Service -
|
||||||
services such as Amazon Route 53 and Zerigo
|
services such as Amazon Route 53 and Zerigo
|
||||||
* :mod:`libcloud_loadbalancer <salt.modules.libcloud_loadbalancer>` - Load Balancers as a Service -
|
* :mod:`libcloud_loadbalancer <salt.modules.libcloud_loadbalancer>` - Load Balancers as a Service -
|
||||||
services such as Amazon Elastic Load Balancer and GoGrid LoadBalancers
|
services such as Amazon Elastic Load Balancer and GoGrid LoadBalancers
|
||||||
* :mod:`libcloud_storage <salt.modules.libcloud_storage>` - Cloud Object Storage and CDN -
|
* :mod:`libcloud_storage <salt.modules.libcloud_storage>` - Cloud Object Storage and CDN -
|
||||||
services such as Amazon S3 and Rackspace CloudFiles, OpenStack Swift
|
services such as Amazon S3 and Rackspace CloudFiles, OpenStack Swift
|
||||||
|
|
||||||
For example, listing buckets in the Google Storage platform:
|
For example, listing buckets in the Google Storage platform:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
$ salt-call libcloud_storage.list_containers google
|
$ salt-call libcloud_storage.list_containers google
|
||||||
|
|
||||||
|
@ -123,16 +123,16 @@ such as Google Storage, S3 and OpenStack Swift
|
||||||
Using the state modules
|
Using the state modules
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
For each configured profile, the assets available in the API (e.g. storage objects, containers,
|
For each configured profile, the assets available in the API (e.g. storage objects, containers,
|
||||||
DNS records and load balancers) can be deployed via Salt's state system.
|
DNS records and load balancers) can be deployed via Salt's state system.
|
||||||
|
|
||||||
The state module documentation explains the specific states that each module supports
|
The state module documentation explains the specific states that each module supports
|
||||||
|
|
||||||
* :mod:`libcloud_storage <salt.states.libcloud_storage>` - Cloud Object Storage and CDN
|
* :mod:`libcloud_storage <salt.states.libcloud_storage>` - Cloud Object Storage and CDN
|
||||||
- services such as Amazon S3 and Rackspace CloudFiles, OpenStack Swift
|
- services such as Amazon S3 and Rackspace CloudFiles, OpenStack Swift
|
||||||
* :mod:`libcloud_loadbalancer <salt.states.libcloud_loadbalancer>` - Load Balancers as a Service
|
* :mod:`libcloud_loadbalancer <salt.states.libcloud_loadbalancer>` - Load Balancers as a Service
|
||||||
- services such as Amazon Elastic Load Balancer and GoGrid LoadBalancers
|
- services such as Amazon Elastic Load Balancer and GoGrid LoadBalancers
|
||||||
* :mod:`libcloud_dns <salt.states.libcloud_dns>` - DNS as a Service
|
* :mod:`libcloud_dns <salt.states.libcloud_dns>` - DNS as a Service
|
||||||
- services such as Amazon Route 53 and Zerigo
|
- services such as Amazon Route 53 and Zerigo
|
||||||
|
|
||||||
For DNS, the state modules can be used to provide DNS resilience for multiple nameservers, for example:
|
For DNS, the state modules can be used to provide DNS resilience for multiple nameservers, for example:
|
||||||
|
@ -223,7 +223,7 @@ Accessing custom arguments in execution modules
|
||||||
Some cloud providers have additional functionality that can be accessed on top of the base API, for example
|
Some cloud providers have additional functionality that can be accessed on top of the base API, for example
|
||||||
the Google Cloud Engine load balancer service offers the ability to provision load balancers into a specific region.
|
the Google Cloud Engine load balancer service offers the ability to provision load balancers into a specific region.
|
||||||
|
|
||||||
Looking at the `API documentation <https://libcloud.readthedocs.io/en/latest/loadbalancer/drivers/gce.html#libcloud.loadbalancer.drivers.gce.GCELBDriver.create_balancer>`_,
|
Looking at the `API documentation <https://libcloud.readthedocs.io/en/latest/loadbalancer/drivers/gce.html#libcloud.loadbalancer.drivers.gce.GCELBDriver.create_balancer>`_,
|
||||||
we can see that it expects an `ex_region` in the `create_balancer` method, so when we execute the salt command, we can add this additional parameter like this:
|
we can see that it expects an `ex_region` in the `create_balancer` method, so when we execute the salt command, we can add this additional parameter like this:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
@ -234,11 +234,11 @@ we can see that it expects an `ex_region` in the `create_balancer` method, so wh
|
||||||
Accessing custom methods in Libcloud drivers
|
Accessing custom methods in Libcloud drivers
|
||||||
============================================
|
============================================
|
||||||
|
|
||||||
Some cloud APIs have additional methods that are prefixed with `ex_` in Apache Libcloud, these methods
|
Some cloud APIs have additional methods that are prefixed with `ex_` in Apache Libcloud, these methods
|
||||||
are part of the non-standard API but can still
|
are part of the non-standard API but can still
|
||||||
be accessed from the Salt modules for `libcloud_storage`, `libcloud_loadbalancer` and `libcloud_dns`.
|
be accessed from the Salt modules for `libcloud_storage`, `libcloud_loadbalancer` and `libcloud_dns`.
|
||||||
The extra methods are available via the `extra` command, which expects the name of the method as the
|
The extra methods are available via the `extra` command, which expects the name of the method as the
|
||||||
first argument, the profile as the second and then
|
first argument, the profile as the second and then
|
||||||
accepts a list of keyword arguments to pass onto the driver method, for example, accessing permissions in Google Storage objects:
|
accepts a list of keyword arguments to pass onto the driver method, for example, accessing permissions in Google Storage objects:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
|
@ -25,11 +25,11 @@ function:
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name=<NAME>,
|
name=THE_NAME,
|
||||||
version=<VERSION>,
|
version=THE_VERSION,
|
||||||
description=<DESC>,
|
description=THE_DESCRIPTION,
|
||||||
author=<AUTHOR>,
|
author=THE_AUTHOR_NAME,
|
||||||
author_email=<AUTHOR-EMAIL>,
|
author_email=THE_AUTHOR_EMAIL,
|
||||||
url=" ... ",
|
url=" ... ",
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
entry_points="""
|
entry_points="""
|
||||||
|
@ -39,7 +39,7 @@ function:
|
||||||
pillar_dirs = <package>.<loader-module>:pillar_dirs
|
pillar_dirs = <package>.<loader-module>:pillar_dirs
|
||||||
returner_dirs = <package>.<loader-module>:returner_dirs
|
returner_dirs = <package>.<loader-module>:returner_dirs
|
||||||
roster_dirs = <package>.<loader-module>:roster_dirs
|
roster_dirs = <package>.<loader-module>:roster_dirs
|
||||||
"""
|
""",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,36 +57,36 @@ how `<package>/<loader-module>.py` it should look:
|
||||||
|
|
||||||
|
|
||||||
def engines_dirs():
|
def engines_dirs():
|
||||||
'''
|
"""
|
||||||
yield one path per parent directory of where engines can be found
|
yield one path per parent directory of where engines can be found
|
||||||
'''
|
"""
|
||||||
yield os.path.join(PKG_DIR, 'engines_1')
|
yield os.path.join(PKG_DIR, "engines_1")
|
||||||
yield os.path.join(PKG_DIR, 'engines_2')
|
yield os.path.join(PKG_DIR, "engines_2")
|
||||||
|
|
||||||
|
|
||||||
def fileserver_dirs():
|
def fileserver_dirs():
|
||||||
'''
|
"""
|
||||||
yield one path per parent directory of where fileserver modules can be found
|
yield one path per parent directory of where fileserver modules can be found
|
||||||
'''
|
"""
|
||||||
yield os.path.join(PKG_DIR, 'fileserver')
|
yield os.path.join(PKG_DIR, "fileserver")
|
||||||
|
|
||||||
|
|
||||||
def pillar_dirs():
|
def pillar_dirs():
|
||||||
'''
|
"""
|
||||||
yield one path per parent directory of where external pillar modules can be found
|
yield one path per parent directory of where external pillar modules can be found
|
||||||
'''
|
"""
|
||||||
yield os.path.join(PKG_DIR, 'pillar')
|
yield os.path.join(PKG_DIR, "pillar")
|
||||||
|
|
||||||
|
|
||||||
def returner_dirs():
|
def returner_dirs():
|
||||||
'''
|
"""
|
||||||
yield one path per parent directory of where returner modules can be found
|
yield one path per parent directory of where returner modules can be found
|
||||||
'''
|
"""
|
||||||
yield os.path.join(PKG_DIR, 'returners')
|
yield os.path.join(PKG_DIR, "returners")
|
||||||
|
|
||||||
|
|
||||||
def roster_dirs():
|
def roster_dirs():
|
||||||
'''
|
"""
|
||||||
yield one path per parent directory of where roster modules can be found
|
yield one path per parent directory of where roster modules can be found
|
||||||
'''
|
"""
|
||||||
yield os.path.join(PKG_DIR, 'roster')
|
yield os.path.join(PKG_DIR, "roster")
|
||||||
|
|
|
@ -493,7 +493,7 @@ You can get a list of packages installed on the system using
|
||||||
This will return all software installed on the system whether it is managed by
|
This will return all software installed on the system whether it is managed by
|
||||||
Salt or not as shown below:
|
Salt or not as shown below:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
local:
|
local:
|
||||||
----------
|
----------
|
||||||
|
@ -647,7 +647,7 @@ be inside that directory and named ``init.sls``.
|
||||||
Look at the following example directory structure on a Linux master assuming
|
Look at the following example directory structure on a Linux master assuming
|
||||||
default config settings:
|
default config settings:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
srv/
|
srv/
|
||||||
|---salt/
|
|---salt/
|
||||||
|
@ -932,7 +932,7 @@ the control panel. You can also get this information by installing the package
|
||||||
manually and then running ``pkg.list_pkgs``. Here's an example of the output
|
manually and then running ``pkg.list_pkgs``. Here's an example of the output
|
||||||
from ``pkg.list_pkgs``:
|
from ``pkg.list_pkgs``:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: console
|
||||||
|
|
||||||
salt 'test-2008' pkg.list_pkgs
|
salt 'test-2008' pkg.list_pkgs
|
||||||
test-2008
|
test-2008
|
||||||
|
|
Loading…
Add table
Reference in a new issue