Skip to content

Instantly share code, notes, and snippets.


Matt Martz sivel

View GitHub Profile
sivel /
Last active Sep 28, 2021
Ansible filter plugin to encrypt a string with yescrypt
# Copyright (c) 2021 Matt Martz <>
# GNU General Public License v3.0+ (see COPYING or
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import ctypes
from ansible.errors import AnsibleFilterError
from ansible.module_utils.common.text.converters import to_bytes, to_text
sivel /
Last active Sep 23, 2021
Ansible Binary Golang Module
go build helloworld.go
GOOS=windows GOARCH=amd64 go build helloworld.go
sivel /
Last active Sep 20, 2021
Script to create a MANIFEST.json and FILES.json for an Ansible collection from galaxy.yml
#!/usr/bin/env python
# Copyright (c) 2020 Matt Martz <>
# GNU General Public License v3.0+
# (see
import json
import os
from ansible.galaxy.collection import _build_files_manifest
from ansible.galaxy.collection import _build_manifest
sivel /
Last active Aug 31, 2021
Better SSH Authorized Keys Management

Better SSH Authorized Keys Management

A seemingly common problem that people encounter is how to handle all of your users authorized_keys file.

People struggle over management, ensuring that users only have specific keys in the authorized_keys file or even a method for expiring keys. A centralized key management system could help provide all of this functionality with a little scripting.

One piece of functionality overlooked in OpenSSH is the AuthorizedKeysCommand configuration keyword. This configuration allows you to specify a command that will run during login to retrieve a users public key file from a remote source and perform validation just as if the authorized_keys file was local.

Here is an example directory structure for a set of users with SSH public keys that can be shared out via a web server:

sivel / 00-include_until.yml
Last active Aug 16, 2021
Ansible Include Until
View 00-include_until.yml
- hosts: localhost
gather_facts: false
- include_tasks: include_me.yml
include_max: 10
sivel /
Last active Jun 4, 2021
Ansible inventory to dynamic inventory JSON output, accepts all inventory input formats
import sys
import json
from ansible.parsing.dataloader import DataLoader
from ansible.inventory.manager import InventoryManager
A24 = True
except ImportError:
from ansible.vars import VariableManager
View 00-output.txt
vars_secret_funky_json: !vault |
"vars_secret_funky_json": {
sivel /
Created Feb 20, 2012
nginx Perl Module to Output Content-MD5 HTTP Header
# nginx Embedded Perl module for adding a Content-MD5 HTTP header
# This perl module, will output an MD5 of a requested file using the
# Content-MD5 HTTP header, by pulling the hex hash from a file of the
# same name with .md5 appended to the end, if it exists.
# Author: Matt Martz <>
# Link:
# License:
sivel / wp-mysql-test.php
Created Aug 5, 2009
Database connection test script for WordPress
View wp-mysql-test.php
* Database connection test script for WordPress
* Parses the wp-config.php file for DB connection information and tests
* a mysql connection to the DB server and selection of the database.
* Errors will be reported. Attempts will be made to repair table errors.
* Place this file in the same directory as wp-config.php
sivel /
Last active Jul 29, 2020
Ansible Callback to aid in replicating set_stats workflow behavior in Tower

dump_stats Ansible callback plugin

This callback plugin can aid in replicating the set_stats workflow behavior in Tower

It allows you to dump the stats set with set_stats to a file, and then use that file with --extra-vars in subsequent ansible-playbook calls.


  1. Download file to a callback_plugins directory relative to your playbook
  2. Run ansible-playbook with ANSIBLE_CALLBACK_WHITELIST=dump_stats