Skip to content

Instantly share code, notes, and snippets.

@gnosek
gnosek / ansible-vault.md
Created September 7, 2015 14:36
ansible-vault diff

git diff ansible-vault

OK, mamy super tajny plik z hasłami, który trzeba zaszyfrować:

$ cat test.yml
foo: bar

Generujemy hasło (w dobrym tonie może być dodać plik z hasłem do .gitignore) i szyfrujemy:

$ pwgen 20 1 > vault.passwd
@gnosek
gnosek / hello.rs
Created February 3, 2015 02:38
Hello, world!
#![feature(libc)]
#![feature(std_misc)]
extern crate libc;
use std::ffi::CString;
fn main() {
let s0 = "/bin/echo".as_bytes();
let s1 = "Hello world".as_bytes();
let argv0 = CString::from_slice(s0);
@gnosek
gnosek / run_playbook.py
Last active May 31, 2019 01:15
Run an ansible playbook from python
from ansible import playbook, callbacks
import logging
import pprint
class LoggingCallbacks(callbacks.PlaybookCallbacks):
def log(self, level, msg, *args, **kwargs):
logging.log(level, msg, *args, **kwargs)
def on_task_start(self, name, is_conditional):
@gnosek
gnosek / elasticsearch_mapping.py
Last active August 29, 2015 14:01
Dynamic ElasticSearch mappings
MAPPING = {
'_default_': {
'_all': {'enabled': False},
'dynamic_templates': [
{
'analyzed_body': {
'match': 'body',
'match_mapping_type': 'string',
'mapping': {
'type': 'string',
@gnosek
gnosek / assh
Created December 3, 2013 18:12
#!/usr/bin/env python
from ansible.inventory import Inventory
import os
import sys
def get_addr(hostname):
inv = Inventory()
host = inv.get_host(hostname)
if not host:
@gnosek
gnosek / ansible_test.py
Last active November 6, 2018 03:12
Weird behaviour in ansible
from ansible import playbook, callbacks
def run_playbook(path, extra_vars):
stats = callbacks.AggregateStats()
playbook_cb = callbacks.PlaybookCallbacks(verbose=1)
runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=1)
pb = playbook.PlayBook(
playbook=path,
>>VVVVVVV+^+^+^+^+^+>v+>v+>v+>^+>^+>^+V+V+V+V+V+
<<+<+<+<+^+^+^+>+>+<<^+^+>+>+>+>
<+<+<+<+V+V+V+V+V+>+>+>+>+^+^+<+
<<VV+^+^+^+^+^+
<<+>+>+>+>+<<+V+V+V+V+V+
>>>>><<+<+<+<+^+^+^+>+>+<<^+^+>+>+>+
VVVVV+^+^+^+^+^+<+<+<+V+V+V+V+V+^^^>+>+
<<<<VVV+^+^+^+^+^+>v+>v+>v+>^+>^+>^+V+V+V+V+V+
infinite{.}
++<=++<=+<=++<=++<=+<=++<=++<=+<=++^^=
++<=++<=+<=++<=++<=+<=++<=++<=+<=++^=
<=++<=++<=++<=++<=++<=++<=++<=++<=++<=++^^
<=++<=++<=++<=++<=++<=++<=++<=++<=++^
++<=++<=+<=++<=++<=+<=++<=++<=+<=++^^=
++<=++<=+<=++<=++<=+<=++<=++<=+<=++^=
<=++<=++<=++<=++<=++<=++<=++<=++<=++<=++^^
<=++<=++<=++<=++<=++<=++<=++<=++<=++^
@gnosek
gnosek / environment.yml
Created August 2, 2013 12:12
Cannot return a dict from custom facts
---
- hosts: $host
tasks:
- environment:
- debug: msg="{{ env_HOME }}"
- debug: msg="{{ environment.HOME }}"
- debug: msg="{{ environment }}"
@gnosek
gnosek / sortdebversions.pl
Created April 30, 2013 09:10
A simple way to sort Debian package versions
#!/usr/bin/env perl
use strict;
use warnings;
use Dpkg::Version;
use Getopt::Long;
my $head;
my $reverse;