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 / gist:f423b87c5dabcc24301d
Last active August 29, 2015 14:00
Salt states example
# Two inconsistent and unclear ways of defining a state:
pkg.installed:
- name: mypackage
apache2:
pkg
- installed
service:
- running
@ryan-lane
ryan-lane / gist:cabe233738028d3082dc
Created May 2, 2014 21:27
Launch config and autoscaling group state example need for a register action
Ensure my launch config exists:
boto_launch_config.present:
- name: my-launch-config-name
- ami: ami-887i9080
- instance_type: c3.2xlarge
- register: my_launch_config
Ensure my autoscale group exists:
boto_autoscale_group.present:
- name: my-autoscale-group-name
{% set a = 'world' %}
{% set b = 'hello-{test}' %}
test:
file.touch:
- name: /tmp/{{ b.format(test=a) }}
Ensure myelb exists:
boto_elb.present:
- name: myelb
- availability_zones:
- us-east-1a
- listeners:
- elb_port: 80
instance_port: 8210
elb_protocol: HTTP
- elb_port: 443
@ryan-lane
ryan-lane / gist:085ec4fd14f337a6b09f
Created June 10, 2014 16:49
Only run apt-get update if a ppa has changed
Run apt-get update on ppa additions:
module.wait:
- name: pkg.refresh_db
Ensure openstack ppa:
pkgrepo.managed:
- ppa: openstack-ubuntu-testing/juno
- refresh_db: False
- watch_in:
- module: pkg.refresh_db
@ryan-lane
ryan-lane / Calling salt-call with environment variables
Last active May 24, 2022 06:52
Using an environment variable in a state file
MYENVVAR="world" salt-call state.template test.sls
{{ (grains['mem_total'] * 1024) * 0.1 | round(1, 'floor') | int }}
0
{{ (grains['mem_total'] * 1024) / 10 | round(1, 'floor') | int }}
383795.2
{{ ((grains['mem_total'] * 1024) * 0.1) | round(1, 'floor') | int }}
@ryan-lane
ryan-lane / execution module: testme.py
Last active August 29, 2015 14:02
Using __context__ in execution modules
def testme():
if not 'testme.testme' in __context__:
__context__['testme.testme'] = 1
else:
__context__['testme.testme'] = __context__['testme.testme'] + 1
return __context__['testme.testme']
### Apache
Ensure apache packages are installed:
pkg.installed:
- pkgs:
- apache2
- apache2-utils
- libapache2-mod-wsgi
Ensure apache is stopped on install:
cmd.wait:
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()