Skip to content

Instantly share code, notes, and snippets.

View ryan-lane's full-sized avatar

Ryan Lane ryan-lane

  • PayPay Japan
  • San Francisco
View GitHub Profile
@ryan-lane
ryan-lane / example.sh
Last active December 7, 2015 22:52
Handling SaltStack forks
# First, fork salt. This example will use https://github.com/ryan-lane/salt
git clone git@github.com:saltstack/salt.git
cd salt
git remote add myfork git@github.com:saltstack/salt.git
git checkout -b stable-2015.8
git reset --hard origin/2015.8
git push myfork stable-2015.8
# Making PRs against 2015.8
git checkout 2015.8
@ryan-lane
ryan-lane / example.py
Last active December 2, 2015 21:51
Using _cache_id
# cache something
_cache_id('elb', sub_resource=name, resource_id=lb[0], region=region, key=key, keyid=keyid, profile=profile)
# retrieve the cached item
_cache_id('elb', sub_resource=name, region=region, key=key, keyid=keyid, profile=profile)
# Invalidate something
_cache_id('elb', sub_resource=name, invalidate=True, region=region, key=key, keyid=keyid, profile=profile)
@ryan-lane
ryan-lane / gist:2c4bed05542b1d088bc4
Last active January 11, 2020 22:54
Environment example
{% if pillar.environment == 'production' %}
Ensure instance1 is configured:
file.managed:
- name /var/local/instance1/context.xml
- source: salt://instance.xml.tmpl
- template: jinja
- context:
somesetting: testme
{% else %}
Ensure instance1 is configured:
Comment: An exception occurred in this state: Traceback (most recent call last):
File "venv/src/salt/salt/state.py", line 1563, in call
**cdata['kwargs'])
File "mymodules/states/boto_dynamodb.py", line 371, in present
s3_base_location=config['s3_base_location'],
File "mymodules/states/boto_dynamodb.py", line 462, in _ensure_backup_datapipeline_present
return __states__['boto_datapipeline.present'](**kwargs)
File "venv/src/salt/salt/utils/lazy.py", line 87, in __getitem__
return self._dict[key]
KeyError: 'boto_datapipeline.present'
saltmastertest_role:
boto_iam_role.present:
- name: saltmastertest
- region: us-east-1
- policies:
saltmastertest:
Version: '2012-10-17'
Statement:
- Action:
- 'ec2:*'
@ryan-lane
ryan-lane / init.sls
Last active January 11, 2020 22:54
Context example
Ensure instance1 is configured:
file.managed:
- name /var/local/instance1/context.xml
- source: salt://instance.xml.tmpl
- template: jinja
- context:
var1: some content
var2: more content
Ensure instance2 is configured:
@ryan-lane
ryan-lane / pillar
Last active January 11, 2020 22:54
user state example
users:
testuser:
full_name: Test User
id: 1001
disabled: False
deployment_config:
parent_dir: /srv
redis:
host: myredisserver.example.com
port: 6379
db: 0
repo_config:
'ricochet/ricochet':
upstream: 'https://github.com/trebuchet-deploy/ricochet'
#grep maxlogins /etc/security/limits.conf /etc/security/limits.d/*
mycommand to be run:
- cmd
- run
# Basic usage (uses default pillar profile key 'grafana')
Ensure myservice dashboard is managed:
grafana.dashboard_present:
- name: myservice
- dashboard_from_pillar: default
- rows_from_pillar:
- systemhealth
- requests