Skip to content

Instantly share code, notes, and snippets.

View ValFadeev's full-sized avatar

Valentin Fadeev ValFadeev

  • Bloomberg LP
  • London
View GitHub Profile
@ValFadeev
ValFadeev / dict_filters.py
Last active May 6, 2016 08:40
Ansible filter plugins to look up pipeline output in a dictionary or find values by keys in the output
"""
Sample usage
- name: find another host to join to form a cluster (e.g. Consul)
set_fact:
host_to_join: >
{{
groups['my_group'] | difference([inventory_hostname])
| list
| random
@ValFadeev
ValFadeev / schemas.py
Created July 15, 2015 00:41
Combining pre/post-conditions and schema validation
import json
from jsonschema import Draft4Validator, SchemaError
from sys import stderr
from os import path
import functools
# JSON schema validator
def validate_against_schema(document, schema):
### Keybase proof
I hereby claim:
* I am ValFadeev on github.
* I am sinlemn (https://keybase.io/sinlemn) on keybase.
* I have a public key whose fingerprint is B889 2C98 5C6F BDDC B6BD 441B 4EE2 C2F6 718E 4808
To claim this, I am signing this object:
@ValFadeev
ValFadeev / jobs.yaml
Last active November 3, 2017 23:28
An example of launching multiple instances of a templated Nomad Docker job in Rundeck (https://github.com/ValFadeev/rundeck-nomad-plugin)
# reusable job running Docker container on Nomad with templated image name and label
- description: ''
executionEnabled: true
id: f3b67ad3-5e86-4bd6-9195-742f35a8af89
loglevel: INFO
name: nomad_step
nodeFilterEditable: false
options:
- name: version
@ValFadeev
ValFadeev / consul_dns
Last active July 12, 2018 13:14
An example of configuring a docker container to use Consul to resolve dns records
# Note: for production use consider setting up forwarding via a standard host-based resolver:
# https://www.consul.io/docs/guides/forwarding.html
# consul 0.9.0
sudo consul agent -dev \
-node consul \
-advertise 192.168.0.2 \
-client 192.168.0.2 \
-dns-port 53
@ValFadeev
ValFadeev / null_resource_template_trigger.tf
Created November 4, 2017 21:11
Trigger null resource based on a rendered template contents
variable "foo" {
default = "bar"
}
data "template_file" "tmpl" {
template = "$${foo}"
vars {
foo = "${var.foo}"
}