Skip to content

Instantly share code, notes, and snippets.

@pcn
pcn / gist:d4a9cd1ea42e6e02f5e1
Last active January 13, 2021 15:35 — forked from tbonza2/gist:20757551443a61254aa6
Saltstack mode for emacs

Saltstack mode for emacs

Earlier today I was looking for a Saltstack mode for emacs. Couldn't find one, so I posted the question on Stack overflow. Somebody had a good suggestion about using yaml-mode because a Sublime Text implementation appeared to be taking this approach.Another person thought that Saltstack's use of jinja templates would make an emacs mode easy enough to configure. These were both helpful ideas so I wanted to implement parts of each.

Reasoning

After looking around, I found that someone had configured an emacs mode for a similar situation. They needed to combine HTML and Python to use Mako templates for a project not involving Saltstack. Since Edx uses Mako t

@pcn
pcn / salt_tester.py
Last active August 29, 2015 14:25
A saltstack "tester" that will use controlled input to create expected (?) output
#!/usr/bin/env python
'''
This module contains the function calls to render state files into yaml.
The intent is that your repo of states will have a default grains.json. In each directory in
your states, you will will have a test/ directory in each state directory that will contain a
pillars.json and an <statename>.json one per sls file in the directory.
The test consists of calling the state.show_sls on the state file, with the provided grains
@pcn
pcn / check.md
Last active August 29, 2015 14:25
Check to see if an appropriate mdadm.conf is in the initrd

The salt mdadm state is slightly broken until saltstack/salt#24952 becomes a release (not sure how to track that). In the mean time, I think I want this anyway:

gunzip -c /boot/initrd.img-3.13.0-52-generic \
  | cpio --to-stdout -i etc/mdadm/mdadm.conf 2>/dev/null \
  | egrep -q '^ARRAY'

This could be a state check, like so:

@pcn
pcn / irc_log.md
Created July 8, 2015 01:03
use the same version of salt-cloud as salt-minion
2015-07-07 17:44:47     coval3nce       arrg my brain is hurting trying to track down “[ERROR   ] Invalid keyword 'standard' for variable 'master_type’”
2015-07-07 17:44:56     murrdoc or is that something u can do on the os itself
2015-07-07 17:46:08     murrdoc whats the salt version on the two servers ?
2015-07-07 17:46:11     murrdoc coval3nce:
2015-07-07 17:46:37     coval3nce       the error is happening on 2015.5.0, 2015.5.1, 2015.5.2, but 2015.5.3 works
2015-07-07 17:46:55     coval3nce       of course 2015.5.2 is the one in EPEL right now
2015-07-07 17:47:08     murrdoc ouch
2015-07-07 17:47:58     coval3nce       oh i beti know whats up, the minion config is getting generated with different options compatible with 2015.5.3 (salt-cloud version)
2015-07-07 17:48:14     coval3nce       and that is a mismatch with what my minions have
@pcn
pcn / no-idea-why.md
Last active August 29, 2015 14:23
salt-static-grains-not-working

Trying to get a custom static grain with this:

grains:
  node_name: pcn_cass-v1-stg-datanode-01
  cassandra_cluster_name: pcn_cass
@pcn
pcn / OMG.md
Last active August 29, 2015 14:23
This is what the cassandra commandline looks ilke when you install the package

If you try to break out what the various cassandra startup scripts end up running, this is what you end up with, broken out with some backslashes:

java -ea \
     -javaagent:/usr/share/cassandra/lib/jamm-0.2.5.jar \
     -XX:+CMSClassUnloadingEnabled \
     -XX:+UseThreadPriorities \
     -XX:ThreadPriorityPolicy=42 \
     -Xms1024M \
     -Xmx1024M \
This used to work on 2014.1.13 but fails on 2015.5.0 and 2015.5.2:
state init.sls file content:
{% set TEST_SYMLINK = '/opt/test_symlink' %}
{% if 0 == salt['cmd.retcode']('test -h '~ TEST_SYMLINK ~' ') %}
{{ TEST_SYMLINK }}:
file.symlink:
- target: /opt/yp
@pcn
pcn / run_info.md
Last active August 29, 2015 14:22
Salt-ssh with the ec2 contrib grain - trying to render grain data

Trying to get the grain info into a file on the disk of the target system (good IMO for the repetetive style of debugging runs):

[CRITICAL] Rendering SLS 'base:cassandra.raid' failed: Unknown yaml render error; line 7

---
[...]
# as an option, too.
/tmp/disks:
 file.append:
@pcn
pcn / vagrant_log.md
Created June 10, 2015 03:50
Building a python+pyenv apt package with fpm on a bare-ish ubuntu image

Vagrant up an official cloud 14.04. Vagrant ssh in, then

sudo apt-get -y install git gcc libz-dev libreadline-dev libbz2-dev libsqlite3-dev libssl-dev ruby-dev
git clone https://github.com/yyuu/pyenv-installer
cd pyenv-installer; bin/pyenv-installer

Add this to the user's .bash_profile:

@pcn
pcn / Comparison.adoc
Last active July 29, 2020 18:38
Going to saltstack from chef as a user

About me

I’m an intermediate/advanced chef user. My main usage has been as a client of the services that chef provides, and not operating the server. My comfort zone is that I am very happy to write and hack on fairly complicated chef cookbooks, LWRPs, and chef-solo work, but I don’t work much with the chef server - I’ve opted to use the hosted service in the past, and very much enjoyed the service.

Why Saltstack?

I’m interested in saltstack. When I first started working with chef in 2011, saltstack was very new, so I learned chef, as the more mature option (though it was still fairly new). Now salt is in a fairly mature phase where it seems to be able to handle the same classes of installation and configuration management that I’ve seen chef work with in the past. This impression is backed up by users of Salt who are clearly using it in their day-to-day operations. So I’m trying it out.

References, etc.