modules/modules/testme.py:
from salt.exceptions import CommandExecutionError
def testme(name):
if name == 'fail':
raise CommandExecutionError('test error message')
else:
return True
docker-registries: | |
https://myregistry.example.com/v1/: | |
email: [email protected] | |
password: mypassword | |
username: my-username | |
docker.url: 'tcp://127.0.0.1:2375' |
Make the directory: | |
file.directory: | |
- name: /tmp/mydir | |
Manage the directory: | |
file.managed: | |
- name: /tmp/mydir | |
- source: salt://blah | |
- recurse: True |
modules/modules/testme.py:
from salt.exceptions import CommandExecutionError
def testme(name):
if name == 'fail':
raise CommandExecutionError('test error message')
else:
return True
Ensure my virtualenv is installed: | |
virtualenv.installed: | |
- name: /srv/myvenv | |
Run a command: | |
cmd.run: | |
- name: mycommand | |
Ensure my file is installed: | |
file.managed: |
Ensure salt virtualenv exists: | |
virtualenv.managed: | |
- name: /srv/salt/venv | |
# Switch to the existing salt venv | |
- pip_exists_action: s | |
- system_site_packages: True | |
- requirements: /my/requirements.txt | |
Ensure modules and grains are refreshed if salt venv changes: | |
module.wait: |
base: | |
'*': | |
- base | |
- service-common | |
- order: 1 | |
{% for root in opts['pillar_roots']['base'] -%} | |
{% set service_group_sls = '{0}/{1}.sls'.format(root, grains['service_group']) -%} | |
{% if salt['file.file_exists'](service_group_sls) %} | |
'service_group:{{ grains["service_group"] }}': | |
- match: grain |
base: | |
# For each directory that can have pillar files | |
{% for root in opts['pillar_roots']['base'] -%} | |
# Set a variable to the path to check | |
{% set mygrain_sls = '{0}/{1}.sls'.format(root, grains['mygrain']) -%} | |
# Check to see if the file exists, if so, include that pillar file. | |
{% if salt['file.file_exists'](mygrain_sls) %} | |
'service_group:{{ grains["mygrain"] }}': | |
- match: grain | |
- {{ grains['mygrain'] }} |
export PYFLAKES_BUILTINS="__salt__,__opts__,__grains__,__pillars__,__context__" |
$script = <<SCRIPT | |
# Install salt dependencies | |
sudo apt-get -y update | |
sudo apt-get install -y build-essential libssl-dev python-dev python-m2crypto \ | |
python-pip python-virtualenv python-zmq swig virtualenvwrapper git-core python-apt | |
if [ ! -d /srv/salt/venv ] | |
then | |
sudo mkdir -p /srv/salt/venv | |
fi |
KeyError: 'file_|-Ensure statsd supervisor configuration exists_|-/etc/supervisor/conf.d/statsd.conf_|-managed' | |
Traceback (most recent call last): | |
File "/usr/bin/salt-call", line 11, in <module> | |
salt_call() | |
File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 128, in salt_call | |
client.run() | |
File "/usr/lib/python2.7/dist-packages/salt/cli/__init__.py", line 398, in run | |
caller.run() | |
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 186, in run | |
ret = self.call() |