Skip to content

Instantly share code, notes, and snippets.

View sivel's full-sized avatar
😏

Matt Martz sivel

😏
View GitHub Profile
vars_secret_funky_json: !vault |
$ANSIBLE_VAULT;1.2;AES256;alan_host
35356666616633303337313766346562613961313262333530663432393965303736653334306433
6239666265343936343462653836386162343234353961330a306665396665353364613863316362
66646663313737393763383565333237316663666339623063646666646261643338616261633330
3634313634666264620a383632386661653330326435633861333031643334643237366430313733
3733
{
"vars_secret_funky_json": {
@sivel
sivel / paramiko-keyscan.py
Created May 19, 2015 18:58
Python Paramiko Keyscan
import paramiko
# provide host and port variables
t = paramiko.transport.Transport('%s:%s' % (host, port))
t.start_client()
key = t.get_remote_server_key()
if int(port) != 22:
host = '[%s]:%s' % (host, port)
@sivel
sivel / yescrypt_ctypes.py
Last active September 28, 2021 13:24
Ansible filter plugin to encrypt a string with yescrypt
# Copyright (c) 2021 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
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
sivel / wp-mysql-test.php
Created August 5, 2009 20:04
Database connection test script for WordPress
<?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
sivel / 00-README.md
Last active July 29, 2020 17:19
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.

Usage

  1. Download dump_stats.py file to a callback_plugins directory relative to your playbook
  2. Run ansible-playbook with ANSIBLE_CALLBACK_WHITELIST=dump_stats
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# (c) 2020 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+
# (see https://www.gnu.org/licenses/gpl-3.0.txt)
import argparse
import json
import re
import sys
@sivel
sivel / with2loop.yml
Last active February 4, 2020 22:12
Ansible playbook showcasing conversion from with_X loops to loop using filters instead of lookup
---
- name: Playbook showcasing conversion from with_X loops to loop+filters
hosts: localhost
gather_facts: false
vars:
items:
-
- foo
-
- bar
@sivel
sivel / test-head-footer.php
Created April 25, 2010 14:46
WordPress Plugin to test for the existence and functionality of wp_head and wp_footer in the active theme
# -*- coding: utf-8 -*-
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import ctypes.util
import locale

Draft

Using to_bytes/to_native/to_text

errors

The default value for errors, although specified as None in the function signature is surrogate_then_replace

The most common and recommended values for compatibility between python2