Skip to content

Instantly share code, notes, and snippets.

View utoddl's full-sized avatar

Todd Lewis utoddl

  • U. of North Carolina at Chapel Hill
  • Chapel Hill, North Carolina, USA
View GitHub Profile
@utoddl
utoddl / ansible-cfg2env
Created November 23, 2023 13:50
converts ansible.cfg settings to shell environment variables
#!/bin/env python3
import os
import re
import yaml
import ast
import pprint
import configparser
import subprocess
import argparse
@utoddl
utoddl / mergevars.py
Created September 16, 2023 01:21
Merge ansible variables listed by name and/or matching regular expression.
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import re
from ansible.errors import AnsibleError
from ansible.plugins.lookup import LookupBase
from ansible.plugins.filter.core import flatten
from ansible.module_utils.six import string_types
@utoddl
utoddl / av-filter
Last active November 17, 2023 07:18
Filter for "ansible-vault"ing YAML Data Values
#!/usr/bin/env python
"""Filter for "ansible-vault"ing YAML Data Values
https://gist.github.com/utoddl/66baa4154618ba1fc8ec8127483e7e89
This script allows an ansible user to pass lines of yaml data
through it to get string values vaulted and/or already-vaulted values
unvaulted, thus simplifying the maintenance of vaulted strings in
Ansible vars files and eliminating the need to vault entire files.
@utoddl
utoddl / polymac.py
Last active February 3, 2022 16:19
Ansible filter module for expanding dicts with variable substitutions
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2020, Todd M. Lewis <utoddl@gmail.com>
# 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
DOCUMENTATION = """
lookup: polymac
@utoddl
utoddl / jsfgenerate.pl
Last active November 14, 2019 19:39
generate files to test / demonstrate .jsf colors
#!/usr/bin/perl -w
# generate files to test .jsf colors.
# (c) 2019 utoddl@gmail.com
# GPL
use strict;
syntax() if @ARGV;
sub syntax {
print qq[Usage: $0
@utoddl
utoddl / test.yaml
Created February 3, 2017 19:35
Simple YAML file showing comment
---
# This is a comment.
NoComments:
aa: "Not # a # comment."
bb: Also#not a comment.
cc: Also# not a comment.
dd: ' # not a comment '
Comments:
dd: This #ends with a comment.
ee: This also # ends with a comment.