Skip to content

Instantly share code, notes, and snippets.

View felixfontein's full-sized avatar

Felix Fontein felixfontein

View GitHub Profile
@felixfontein
felixfontein / abstract.yaml
Created June 16, 2019 08:11
Abstract for talk at Ansible Meetup in Bern
---
title: How to create a simple Ansible module
author: Felix Fontein
abstract: |
A brief tutorial on how to create a simple Ansible module in Python.
(This talk does not touch Windows PowerShell modules.)
language: Slides (English), Talk (German or English)
@felixfontein
felixfontein / objects.py
Last active April 6, 2019 10:15
Create _OID_MAP for Ansible's module_utils/crypto.py from OpenSSL's objects.txt
#!/usr/bin/python
import re
OIDs = dict()
names_lookup = dict()
def convert_for_lookup(name):
return name.replace('-', '_')
# Can be used in an Ansible module to check whether a certificate is revoked using OCSP.
# Needs filenames of certificate and intermediate certificate.
import base64
import os
import re
import tempfile
import traceback
from ansible.module_utils.basic import AnsibleModule
@felixfontein
felixfontein / cryptography-experiments.py
Last active July 1, 2018 14:16
Playing around with [cryptography](https://cryptography.io/) in preparation of using it to create an ACME client
#!/usr/bin/python
import binascii
import cryptography
import datetime
import math
from cryptography.hazmat.backends import default_backend
@felixfontein
felixfontein / openssl_dhparam.diff
Last active January 23, 2018 14:02
Using module.run_command() and writing into tempfile (context: https://github.com/ansible/ansible/pull/32620)
85,126c85
<
< """Note: We also monkey-patch subprocess for python 2.6 to
< give feature parity with later versions.
< Monkey-patch from http://pydoc.net/pep8radius/0.9.0/ with slight modifications
< MIT Licence
<
< Remove patch when Python 2.6 is no longer supported
< """
< import subprocess
@felixfontein
felixfontein / extended_tags.plugin
Last active September 21, 2015 20:28
Extended tags plugins for Nikola.
[Core]
Name = extended_tags
Module = extended_tags
[Documentation]
Author = Felix Fontein
Version = 1.0
Website = https://spielwiese.fontein.de/
Description = Allows more complex kind of tags.