Skip to content

Instantly share code, notes, and snippets.

View anryko's full-sized avatar
🙃
I may be slow to respond.

Andrej Svenke anryko

🙃
I may be slow to respond.
View GitHub Profile
@anryko
anryko / ansible_aws_integration_tests.md
Last active March 23, 2020 16:09
Instructions for running Ansible AWS module integration tests using vanila docker container.

Start container from ansible git root:

docker run \
    -it \
    -v $PWD:/srv \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -w /srv \
    fedora bash
@anryko
anryko / ec2.sh
Created April 24, 2019 09:02 — forked from kwilczynski/ec2.sh
Lock down EC2 meta-data to root (or others) only.
iptables -t filter -I OUTPUT -d 169.254.169.254 -j EC2
iptables -N EC2
iptables -A EC2 -m owner --uid-owner root -d 169.254.169.254 -j ACCEPT
iptables -A EC2 -j REJECT --reject-with icmp-host-unreachable
@anryko
anryko / aws_asg_collect_tags.sh
Last active August 6, 2018 14:52
aws_asg_collect_tags
# Get AWS ASG tags in one object per ASG.
aws autoscaling describe-auto-scaling-groups \
| jq -r '.AutoScalingGroups[].Tags | reduce .[] as $n ({}; . * {($n.Key): $n.Value})'
@anryko
anryko / ansible_filter_env.yml
Last active March 8, 2018 12:27
Andible filter env vars for docker.
- set_fact:
set_filter: 'aws_'
# set_envs: [{ 'AWS_PROFILE': <value>}, {'AWS_REGION': <value>}, ...]
- set_fact:
set_envs: "{{ set_envs | d([]) | union([{ item.split('=', 1)[0]: item.split('=', 1)[1] }]) }}"
when: item.startswith(set_filter | upper)
with_items: "{{ lookup('pipe', 'env').split('\n') }}"
@anryko
anryko / ansible_combine.yml
Last active February 21, 2018 18:59
ansible_combine.yml
# x → {'a': 111, 'b': 222, 'c': 333}
- set_fact:
x: "{{ x | d({}) | combine({item.0: item.1}) }}"
with_together:
- ['a', 'b', 'c']
- [111, 222, 333]
# y → [{'a':123}, {'b':456}, {'c':789}]
- set_fact:
y: "{{ y | d([]) | union([{item.0: item.1}]) }}"
@anryko
anryko / listeners.yml
Last active February 21, 2018 18:56
Ansible AWS ALB Listeners
---
- name: test
hosts: localhost
connection: local
gather_facts: False
vars:
listeners:
- Protocol: HTTP
# Port: 80
@anryko
anryko / README.txt
Created December 12, 2017 10:04
Run gcc make build in a docker container producing executable on a local filesystem.
Change dir to source directory and run:
$ docker run \
-it \
--rm \
--name gcc \
-v $PWD:/mnt \
-p 9090:9090 \
gcc bash -c 'cd /mnt && make && ./a.out'
@anryko
anryko / mysql_backup.sh
Created March 12, 2017 19:50
Script to backup mysql databases on Debian based OS.
#!/usr/bin/env bash
# by: anryko
# date: 2017.03.12
# description: Script to backup mysql databases on Debian based OS
set -e
set -o pipefail
umask 0077
trap cleanup ERR INT TERM EXIT
@anryko
anryko / Makefile
Created March 29, 2016 20:32
Simple kernel module example. Lists process list and count.
obj-m += lkm_hello1.o
KDIR ?= /lib/modules/$(shell uname -r)/build
all:
make -C $(KDIR) M=$(PWD) modules
clean:
make -C $(KDIR) M=$(PWD) clean