Skip to content

Instantly share code, notes, and snippets.

@beddari
beddari / format_list.py
Created December 2, 2017 18:19
Ansible list formatting filter_plugin
def format_list(list_, pattern):
return [pattern % s for s in list_]
class FilterModule(object):
def filters(self):
return {
'format_list': format_list,
}
@beddari
beddari / learning.yaml
Last active October 30, 2017 09:14
Ansible THW
---
- name: test
hosts: localhost
connection: local
gather_facts: False
tasks:
# Test each key in a hash for existence, works fine ... I'll accept doing this!
- name: do something based on the existence of nested dict key nested.config.hash.key
debug: msg="{{ nested.config.hash.key }}"
@beddari
beddari / dict_merge.py
Created October 17, 2017 13:29 — forked from angstwad/dict_merge.py
Recursive dictionary merge in Python
import collections
def dict_merge(dct, merge_dct):
""" Recursive dict merge. Inspired by :meth:``dict.update()``, instead of
updating only top-level keys, dict_merge recurses down into dicts nested
to an arbitrary depth, updating keys. The ``merge_dct`` is merged into
``dct``.
:param dct: dict onto which the merge is executed
:param merge_dct: dct merged into dct
osadmin ()
{
source <(tpass show "openstack/$1/admin")
}
osuser ()
{
source <(tpass show "$(whoami)/openstack/$1")
}
@beddari
beddari / systemd.md
Created June 8, 2017 13:56
systemd timers

For the timer:

[Unit]
Description=Do something daily

[Timer]
OnCalendar=daily
Persistent=true

[Install]
@beddari
beddari / trello-to-newsletter.py
Created March 28, 2017 11:38 — forked from paulmist/trello-to-newsletter.py
Trello to Newsletter builder
"""
Trello to Newsletter builder
This is heavily inspired by: https://changelog.com/trello-as-a-cms/
To install:
pip install click cached_property markdown py-trello
To run:
export TRELLO_APP_KEY=''
tcli <module> <verb>
tcli <module> <subject> <verb>
tcli os login # show credentials and project
tcli os login <name> # use a predefined cloud config
tcli os compute list
tcli os compute list --enabled
tcli os compute list --disabled
tcli os compute enable x
@beddari
beddari / article.md
Last active December 26, 2016 18:22
Building a team cli with Python

Building a Team CLI with Python: One Alternative to ChatOps

Author: Jan Ivar Beddari @beddari
Editor: Nicholas Valler @nvaller

Introduction

@beddari
beddari / gist:ab96e896ced827b80c7be04f48e7b551
Last active November 1, 2016 14:39
nologin group mapping engine graceful noaccess
openstack group create --domain Default --description "All authenticated users are mapped to nologin which has no role grants" nologin
mapping_rules:
# Always map user name field to OIDC-email
- local:
- user:
name: "{0}"
remote:
- type: OIDC-email
# All authenticated users are mapped to nologin which has no role grants