Skip to content

Instantly share code, notes, and snippets.

Avatar

Nils Meyer nilsmeyer

  • Freelancer
  • Hamburg, Germany
View GitHub Profile
View gist:b4da931f9907a00cdca872e589cb026f
- name: enrich partition data
set_fact:
_partitions: >
{{
_partitions|combine({_partuuids[item.0.device + '_' + item.1.num|string]:
_partitions[_partuuids[item.0.device + '_' + item.1.num|string]]|combine(item.1)})
}}
with_subelements:
- "{{ layout }}"
- partitions
View gist:2e1396fe5e504b2af20dd54054b3dca5
$database would be the database/schema...
SELECT c.TABLE_NAME, CONSTRAINT_NAME, SUM(CHARACTER_OCTET_LENGTH) AS length FROM KEY_COLUMN_USAGE kcu INNER JOIN COLUMNS c ON c.TABLE_SCHEMA = kcu.TABLE_SCHEMA AND c.TABLE_NAME = kcu.TABLE_NAME AND c.COLUMN_NAME = kcu.COLUMN_NAME WHERE kcu.TABLE_SCHEMA='$database' GROUP BY CONSTRAINT_NAME, c.TABLE_NAME ORDER BY length;
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
@nilsmeyer
nilsmeyer / volumes.yml
Created Mar 25, 2019
volume configuration example
View volumes.yml
volumes:
docker:
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
devices:
- 'volume:docker-enc'
docker-enc:
type: luks2
@nilsmeyer
nilsmeyer / gist:1b703dd4b54157f7cb71b0ff913a5b6f
Created Mar 29, 2019
check if url is reachable in ansible
View gist:1b703dd4b54157f7cb71b0ff913a5b6f
- name: check metadata endpoint
uri:
url: http://169.254.169.254/latest/meta-data/
timeout: 1
return_content: yes
register: _nmiac_metadata
changed_when: no
check_mode: no
failed_when: no
@nilsmeyer
nilsmeyer / userdata.yml
Created May 10, 2019
when the nvme devices schanges
View userdata.yml
#cloud-config
fs_setup:
- 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
nilsmeyer / volumes.txt
Created May 10, 2019
root device is getting attached at different locations
View volumes.txt
----------52.48.95.74--------
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
----------34.254.163.177--------
total 0
@nilsmeyer
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
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": [
"679593333241"
],
"most_recent": true
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)
You can’t perform that action at this time.