Skip to content

Instantly share code, notes, and snippets.

View UtahDave's full-sized avatar

David Boucha UtahDave

View GitHub Profile
@UtahDave
UtahDave / postgres-cheatsheet.md
Created February 11, 2020 18:45 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@UtahDave
UtahDave / gist:665c086547b44cb3ebe1
Created September 22, 2014 17:40
Example of Salt State directory layout
.
├── bacula
│   ├── client.sls
│   └── server.sls
├── bprobe
│   └── init.sls
├── cpall.sls
├── dirty-users
│   ├── exports
│   ├── group -> /etc/group
@UtahDave
UtahDave / icinga.py
Last active January 11, 2020 22:54 — forked from d--j/icinga.py
'''
Manages Icinga Passive Check delivery
'''
import logging
import logging.handlers
import os
import signal
LOG_LEVELS = (logging.WARNING, logging.INFO, logging.DEBUG)
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'] }}
@UtahDave
UtahDave / gist:c63948358ff0df94f927
Created July 7, 2014 22:10
gate state with existence of a directory or file example
{% if salt['file.file_exists']('/scr') %}
/scr:
file.directory:
- user: root
- group: psgvb
- mode: 2775
{% endif %}
@UtahDave
UtahDave / gist:11066593
Created April 18, 2014 22:09
set a private key in pillar. Not tested. Verify before putting into production.
univeralkey: universalvalue
{% if opts.id == 'server01' %}
github_key: |
lkjasdlkfjsalkjsadflkjsalfkjasfdl kjasdfdl jsfd
lkjaslfkjaslfkjslkfjlaskfjfslkfjslakfjflsakfjlkj
lkjkaslkfjsalfkjsdlfkjsaldfkjsdfdlkjsafdlkjsadlfkj
{% elif opts.id == 'server02' %}
github_key: |
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Description

Have you ever wanted to have a Vagrant workspace with more than one Virtual Machine, and managed by Salt Stack? I did, but the documentation is not all there yet.

I managed to make it work with the following, hope it will be useful.

To use

See the Complete salty-vagrant setup, but use the current Vagrantfile to have two machines.

@UtahDave
UtahDave / lxc-exec-all.sh
Created May 15, 2019 04:34 — forked from lcherone/lxc-exec-all.sh
LXD run command in all running containers
#!/bin/bash
#
# Run command in all running containers
# Usage: $ ./lxc-exec-all.sh apt update && apt upgrade
#
for container in $(lxc list volatile.last_state.power=RUNNING -c n --format csv); do
lxc exec "$container" "$@"
done
@UtahDave
UtahDave / rpm-digital-signature.sh
Created March 14, 2019 23:24 — forked from fernandoaleman/rpm-digital-signature.sh
How to sign your custom RPM package with GPG key
# How to sign your custom RPM package with GPG key
# Step: 1
# Generate gpg key pair (public key and private key)
#
# You will be prompted with a series of questions about encryption.
# Simply select the default values presented. You will also be asked
# to create a Real Name, Email Address and Comment (comment optional).
#
# If you get the following response:
@UtahDave
UtahDave / gist:10939584
Created April 16, 2014 22:38
Create Salt-SSH Roster from current regular minions
salt '*' --out=txt cmd.run template=jinja "printf '{{ grains.id }}:\n host: {{ grains.fqdn }}\n user: yourname\n priv: /path/to/id_rsa\n sudo: false'" | awk -F':' '{ st = index($0,":")+1;print substr($0,st+1)}'