Skip to main content

Chaos Toolkit Extension for SaltStack

Project description

Chaos Toolkit Extension for SaltStack

Build Status Python versions

This project is a collection of actions and probes, gathered as an extension to the Chaos Toolkit.

Generally SaltStack runs minion agents in machine level, and minions are under management of one or more SaltMaster machines. On the SaltMaster or via API, SaltMaster can run bulk commands or scripts or other actions on any connected minion. The biggest advantage of SaltSatck is adapting cross cloud solutions on VM level chaos experiments. If you are working on hybrid cloud and have network tunnelled, one SaltMaster could control all VMs across multiple clouds, e.g. Azure, AWS, etc.

Install

This package requires Python 3.5+

To be used from your experiment, this package must be installed in the Python environment where chaostoolkit already lives.

$ pip install -U chaostoolkit-saltstack

Usage

To use the probes and actions from this package, add the following to your experiment file:

{
    "type": "action",
    "name": "burn_cpu",
    "provider": {
        "type": "python",
        "module": "chaossaltstack.machines.actions",
        "func": "burn_cpu",
        "secrets": ["saltstack"],
        "arguments": {
            "parameters": {
                "execution_duration": "300"
            }
        }
    }
}

That's it!

Please explore the code to see existing probes and actions.

Configuration

Credentials

0. Salt Master URL
    * SALTMASTER_HOST

1. Useranme & Password.
   -d username='salt' -d password='abcd1234' -d eauth='pam'
   Then a token in obrained via <salt_url>/login

2. Token
   A token directly, same with the backend of 1.

3. Key, only from Salt Master
    * SALTMASTER_HOST: Salt Master API address

    You can authenticate with user / password via:
    * SALTMASTER_USER: the user name
    * SALTMASTER_PASSWORD: the password

    Or via a token:
    * SALTMASTER_TOKEN

There are two ways of doing this:

  • you can either pass the name of the environment variables to the experiment definition as follows (recommended):

    {
        "saltstack": {
            "SALTMASTER_HOST": {
                "type": "env",
                "key": "SALTMASTER_HOST"
            },
            "SALTMASTER_USER": {
                "type": "env",
                "key": "SALTMASTER_USER"
            },
            "SALTMASTER_PASSWORD": {
                "type": "env",
                "key": "SALTMASTER_PASSWORD"
            }
        }
    }
    
    {
        "saltstack": {
            "SALTMASTER_HOST": {
                "type": "env",
                "key": "SALTMASTER_HOST"
            },
            "SALTMASTER_TOKEN": {
                "type": "env",
                "key": "SALTMASTER_TOKEN"
            }
        }
    }
    
  • or you inject the secrets explicitly to the experiment definition:

    {
        "saltstack": {
            "SALTMASTER_HOST": "https://172.10.20.666",
            "SALTMASTER_USER": "username",
            "SALTMASTER_PASSWORD": "password"
        }
    }
    
    {
        "saltstack": {
            "SALTMASTER_HOST": "https://172.10.20.666",
            "SALTMASTER_TOKEN": "abcd1234abcd1234abcd1234"
        }
    }
    

    Additionally you may directly use if you are on the SaltMaster

Putting it all together

Here is a full example:

{
  "version": "1.0.0",
  "title": "...",
  "description": "...",
  "tags": [
    "azure",
    "kubernetes",
	"aks",
	"node"
  ],
  "configuration": {
    "saltstack": {
        "environment": "azure"
	}
  },
  "secrets": {
   "saltstack": {
       "SALTMASTER_HOST": "https://172.20.1.172:8000",
       "SALTMASTER_USER": "saltuser",
       "SALTMASTER_PASSWORD": "asfasfasdfa"
    }
   },
  "steady-state-hypothesis": {
    "title": "Services are all available and healthy",
    "probes": [
      {
        "type": "probe",
        "name": "check_minions_online",
        "provider": {
          "type": "python",
          "module": "chaossaltstack.machine.probes",
          "func": "is_minion_online",
          "arguments": {
              "instance_ids": [ "PABCDEFGS0016","PABCDEFGS0666" ]
          },
          "secrets": ["saltstack"]
        }
      }
    ]
  },
  "method": [
    {
        "type": "action",
        "name": "stress_cpu",
        "provider": {
            "type": "python",
          "module": "chaossaltstack.machine.probes",
            "module": "saltstack.machine.actions",
            "func": "stress_cpu",
            "arguments": {
                "execution_duration": "300",
                "instance_ids": [ "PABCDEFGS0016","PABCDEFGS0666" ]
            },
            "secrets": ["saltstack"]
        }
    }
  ],
  "rollbacks": [

  ]
}

Contribute

If you wish to contribute more functions to this package, you are more than welcome to do so. Please, fork this project, make your changes following the usual PEP 8 code style, sprinkling with tests and submit a PR for review.

The Chaos Toolkit projects require all contributors must sign a Developer Certificate of Origin on each commit they would like to merge into the master branch of the repository. Please, make sure you can abide by the rules of the DCO before submitting a PR.

Develop

If you wish to develop on this project, make sure to install the development dependencies. But first, create a virtual environment and then install those dependencies.

$ pip install -r requirements-dev.txt -r requirements.txt 

Then, point your environment to this directory:

$ pip install -e .

Now, you can edit the files and they will be automatically be seen by your environment, even when running from the chaos command locally.

Test

To run the tests for the project execute the following:

$ pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chaostoolkit-saltstack-0.1.0.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

chaostoolkit_saltstack-0.1.0-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file chaostoolkit-saltstack-0.1.0.tar.gz.

File metadata

  • Download URL: chaostoolkit-saltstack-0.1.0.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.6

File hashes

Hashes for chaostoolkit-saltstack-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bcbbba22de15fbe027226e38e2d1932519e8d6b93dcef066aa8cf92a85c2eb5c
MD5 af5c610784ee20a53f00498298c4c352
BLAKE2b-256 2badbf0fa942fb572966d2045f764603b4c4a6fe4177725c2e5d06fd198e0616

See more details on using hashes here.

File details

Details for the file chaostoolkit_saltstack-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: chaostoolkit_saltstack-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.6

File hashes

Hashes for chaostoolkit_saltstack-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e1b60cfad8b42f5bdfefba3516e04703ca66d2d3e860ae0d8e3e0eae5ad7689d
MD5 5e12ea22f7107cb1cb51d20fea94b5bc
BLAKE2b-256 5fd4ecce2e1bb4e6b5ca04d9af1e7b3a24d108b64d8ea5e2bfc2bd2ad4b5287c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page