Skip to content

Instantly share code, notes, and snippets.

Nils Meyer nilsmeyer

  • Freelancer
  • Hamburg, Germany
View GitHub Profile
View pg_connect
umask 077
if [ "$1" == "" ]
echo "Usage: pg_connect SSH_HOST psql_options"
View gist:c9592c70f555c8d8fc06564fc6afdbdb
The full traceback is:
File "/tmp/ansible_apt_repository_payload_jj6wzfp1/", line 548, in main
File "/usr/lib/python3/dist-packages/apt/", line 562, in update
raise FetchFailedException(e)
fatal: [vger]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"codename": null,
View gist:dcb2cf17b4d8347e0ef0561e0c9b544e
MariaDB [test]> create table t1 (id int unsigned not null auto_increment primary key);
Query OK, 0 rows affected (0.027 sec)
MariaDB [test]> create table t2 (id int unsigned not null auto_increment primary key, t1_id int unsigned not null, foreign key(t1_id) references t1(id));
Query OK, 0 rows affected (0.040 sec)
MariaDB [test]> insert into t2 (t1_id) values (1);
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`t1_id`) REFERENCES `t1` (`id`))
MariaDB [test]> set foreign_key_checks=0;
Query OK, 0 rows affected (0.000 sec)
nilsmeyer / fragment.json
Created Jul 29, 2019
CentOS 7 source ami filter
View fragment.json
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "CentOS Linux 7 x86_64 HVM EBS ENA 1901*",
"root-device-type": "ebs"
"owners": [
"most_recent": true
nilsmeyer / gist:1444eec126046f4fc9b204ef7828b50c
Created Jun 16, 2019
XFS docker volume from sparse file
View gist:1444eec126046f4fc9b204ef7828b50c
root@ip-172-18-21-22:~# dd if=/dev/zero of=myxfs bs=1 count=0 seek=2G
0+0 records in
0+0 records out
0 bytes copied, 0.000199112 s, 0.0 kB/s
root@ip-172-18-21-22:~# mkfs.xfs myxfs
meta-data=myxfs isize=512 agcount=4, agsize=131072 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=0, rmapbt=0, reflink=0
data = bsize=4096 blocks=524288, imaxpct=25
= sunit=0 swidth=0 blks
nilsmeyer / volumes.txt
Created May 10, 2019
root device is getting attached at different locations
View volumes.txt
total 0
lrwxrwxrwx 1 root root 13 May 10 16:25 nvme-Amazon_Elastic_Block_Store_vol01f9d4a5c1497535d -> ../../nvme0n1
lrwxrwxrwx 1 root root 13 May 10 16:25 nvme-Amazon_Elastic_Block_Store_vol0c83712f171fc4151 -> ../../nvme1n1
lrwxrwxrwx 1 root root 15 May 10 16:25 nvme-Amazon_Elastic_Block_Store_vol0c83712f171fc4151-part1 -> ../../nvme1n1p1
lrwxrwxrwx 1 root root 13 May 10 16:25 nvme-nvme.1d0f-766f6c3031663964346135633134393735333564-416d617a6f6e20456c617374696320426c6f636b2053746f7265-00000001 -> ../../nvme0n1
lrwxrwxrwx 1 root root 13 May 10 16:25 nvme-nvme.1d0f-766f6c3063383337313266313731666334313531-416d617a6f6e20456c617374696320426c6f636b2053746f7265-00000001 -> ../../nvme1n1
lrwxrwxrwx 1 root root 15 May 10 16:25 nvme-nvme.1d0f-766f6c3063383337313266313731666334313531-416d617a6f6e20456c617374696320426c6f636b2053746f7265-00000001-part1 -> ../../nvme1n1p1
total 0
nilsmeyer / userdata.yml
Created May 10, 2019
when the nvme devices schanges
View userdata.yml
- label: docker
device: /dev/nvme0n1
filesystem: xfs
partition: none
overwrite: false
extra_opts: ['-n', 'ftype=1', '-l', 'size=256m', '-b', 'size=4096',
'-s', 'size=4096', '-m', 'crc=1,finobt=1,rmapbt=1,reflink=1',
'-i', 'sparse=1']
nilsmeyer / gist:1b703dd4b54157f7cb71b0ff913a5b6f
Created Mar 29, 2019
check if url is reachable in ansible
View gist:1b703dd4b54157f7cb71b0ff913a5b6f
- name: check metadata endpoint
timeout: 1
return_content: yes
register: _nmiac_metadata
changed_when: no
check_mode: no
failed_when: no
nilsmeyer / volumes.yml
Created Mar 25, 2019
volume configuration example
View volumes.yml
type: xfs
mount: /srv/docker
mount_options : defaults
mkfs_options: -s size=4096 -b size=4096 -m crc=1,finobt=1,rmapbt=1,reflink=1 -l size=128m -i sparse=1
- 'volume:docker-enc'
type: luks2
View ssh-keygen sign keys with private key stored in agent
ssh-add -t 300 $ca_private_key_file # key will be available in agent for 5m
ssh-keygen -s $ca_private_key_file -U -I $host_identity_sring -n $hostname -h -V +52w $public_host_key
You can’t perform that action at this time.