Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View anlutro's full-sized avatar

Andreas Lutro anlutro

View GitHub Profile
@anlutro
anlutro / .pylintrc
Created August 31, 2017 10:09
Pylint config file template
[MASTER]
#load-plugins = plugin1, plugin2
[REPORTS]
reports = no
output-format = colorized
[FORMAT]
#indent-string = \t
% git init
Initialized empty Git repository in /home/andreas/tmp/gittest2/.git/
% echo 'test' > test
% git add test
% git commit -m 'test commit'
[master (root-commit) 8d25641] test commit
1 file changed, 1 insertion(+)
@anlutro
anlutro / gist:cc52002cb172c5f30a59dbc7ae8b68c4
Created April 21, 2016 15:57
Installing Salt from source in a virtualenv
#!/bin/sh
git clone https://github.com/saltstack/salt
cd salt
git checkout 2015.8
virtualenv -p python2 .
. ./bin/activate
pip install -e .
# if $HOME/bin is in your $PATH
ln -sf $(readlink -f bin/salt-ssh) $HOME/bin/salt-ssh
#!/bin/sh
date -R
echo "Updating letsencrypt certificate for $1"
if [ "$(id -u)" = "0" ]; then
echo "This script cannot be run as root" 1>&2
exit 1
fi
@anlutro
anlutro / gist:cd0c16d1d23d55ded19b
Last active January 27, 2017 08:26
Illustration of states vs modules and function arguments
# in a /srv/salt .sls file
my_state: <- State ID
file.managed: <- State function
- name: /tmp/foo
- contents: hello world
^ state function arguments
{% if salt['file.directory_exists']('/tmp/bar') %}
^ module function ^ module function arguments
@anlutro
anlutro / pillar.sls
Last active August 25, 2020 13:53
IPtables salt state+pillar
{# allow outgoing traffic #}
{% macro outgoing(name, protocol, port, family, enable=true) %}
{{ name }}-{{ family }}-{{ protocol }}-{{ port }}-outgoing:
family: {{ family }}
chain: OUTPUT
jump: ACCEPT
protocol: {{ protocol }}
dport: {{ port }}
state: 'NEW,ESTABLISHED'
enable: {{ enable }}
@anlutro
anlutro / gist:9353fb43ed3b3095f086
Created July 28, 2015 08:24
Apparently += is unsafe in python
>>> l = []
>>> l = l + 'foo'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "str") to list
>>> l += 'foo'
>>> l
['f', 'o', 'o']
[ERROR ] Nested output failed:
Traceback (most recent call last):
File "/home/andreas/dev/python/salt/salt/output/__init__.py", line 43, in try_printout
return get_printout('nested', opts)(data).rstrip()
AttributeError: 'NoneType' object has no attribute 'rstrip'
[ERROR ] An un-handled exception was caught by salt's global exception handler:
AttributeError: 'NoneType' object has no attribute 'rstrip'
Traceback (most recent call last):
File "/usr/local/bin/salt-ssh", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
@anlutro
anlutro / install.sh
Last active August 29, 2015 14:05
Installing sassc - SASS/SCSS compiler written in C
#!/usr/bin/env sh
# where to put the executable - make sure you have write
# permissions to $prefix/bin !
prefix=$HOME # or /usr/local or whatever
# create a random tmp directory to work in
src=$(mktemp -d) && cd $src
git clone https://github.com/sass/libsass && cd libsass
@anlutro
anlutro / virtualhost
Created March 19, 2014 14:14
Separate app in subdirectory for Apache (Laravel 4 and AngularJS example)
<VirtualHost *:80>
# Client AngularJS application
DocumentRoot /var/www/example/client/public
# Server Laravel 4 API application
Alias /api /var/www/example/server/public
# Rewrite all requests in /api to server index.php
<Location /api>