Skip to content

Instantly share code, notes, and snippets.

View mgedmin's full-sized avatar

Marius Gedminas mgedmin

View GitHub Profile
@mgedmin
mgedmin / tasks.txt
Last active September 13, 2015 15:55
foo: one
foo: two
foo: five?
foo: six?
foo: seven!
foo: eight!
bar: three
bar: four
something else
weeping
@mgedmin
mgedmin / tasks.yml
Created September 10, 2015 13:19
Creating and distributing SSH keys
- name: ssh private key for pushing backups
command: ssh-keygen -q -t rsa -N '' -f {{ backup_pusher_key }} -C backup-script@{{ ansible_fqdn }}
args:
creates: "{{ backup_pusher_key }}"
tags: [ backups, ssh ]
- name: get the ssh public key
command: cat "{{ backup_pusher_key }}.pub"
register: pubkey_result
changed_when: false
@mgedmin
mgedmin / README.rst
Last active September 27, 2015 18:44
Managing /etc/ssh/ssh_known_hosts in Ansible

My group_vars/all has this:

ssh_host_keys:
  github: |
    github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
  myserver1: |
    myserver1.example.com ssh-rsa AAA...
    myserver1.example.com ssh-dss AAA...
    myserver1.example.com ssh-ecdsa-sha2-nistp256 AAA...
  myserver2: |
@mgedmin
mgedmin / Vagrantfile
Created August 26, 2015 13:45
Transparent apt proxy for Vagrant VMs
...
# vagrant plugin install vagrant-proxyconf
# apt-get install squid-deb-proxy-client
if Vagrant.has_plugin?("vagrant-proxyconf")
config.apt_proxy.http = `/usr/share/squid-deb-proxy-client/apt-avahi-discover`
# NB: you must 'vagrant provision' when you change networks, or the
# proxy config may be stale
end
...
@mgedmin
mgedmin / action_plugins_slash_gitconfig.py
Created August 26, 2015 05:21
Ansible 1.9.x module for git config
# action_plugins/gitconfig.py
# Action plugin for Ansible 1.9.2, since that was the only way I could find to implement --diff support for a module
from ansible.runner.action_plugins.normal import ActionModule as _ActionModule
class ActionModule(_ActionModule):
'''Change git settings'''
def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **kwargs):
result = super(ActionModule, self).run(conn, tmp, module_name, module_args, inject, complex_args=complex_args, **kwargs)
@mgedmin
mgedmin / postfix.py
Last active February 6, 2024 14:21
Ansible module for postfix configuration
#!/usr/bin/python
import subprocess
DOCUMENTATION = '''
---
module: postfix
short_description: changes postfix configuration parameters
description:
- The M(postfix) module changes postfix configuration by invoking 'postconf'.

Given tasks like

- command: foo
  when: foo_condition
  register: foo_result
  
- changelog: msg="ran foo"
  when: foo_result|changed
 
- name: gather current postfix configuration
command: postconf
register: postconf_result
tags: postfix
@mgedmin
mgedmin / gist:2f2132ead2999a5e2077
Created August 4, 2015 11:44
"pip install -e foo -r reqs.txt" fails if 'foo' is in reqs.txt;
mg@platonas! ~ $ cd /tmp
mg@platonas! /tmp $ mkdir foo
mg@platonas! /tmp $ vim foo/setup.py
[10s]
mg@platonas! /tmp $ virtualenv venv
Using real prefix '/usr'
New python executable in venv/bin/python

Keybase proof

I hereby claim:

  • I am mgedmin on github.
  • I am mgedmin (https://keybase.io/mgedmin) on keybase.
  • I have a public key whose fingerprint is 8121 AD32 F00A 8094 748A 6CD0 9157 445D E7A6 D78F

To claim this, I am signing this object: