Skip to content

Instantly share code, notes, and snippets.

View a-nldisr's full-sized avatar
📺
Pipe it to bash

Rogier Dikkes a-nldisr

📺
Pipe it to bash
View GitHub Profile
@a-nldisr
a-nldisr / apply_main.tf
Last active November 18, 2022 16:15
terraform_mapped_vars_for_each
# This is the resource to create
module "config_generator" {
source = "map_module_main.tf" // ? usually point to github url or place on disk where the module exists
name = var.config_names
}
variable "config_names" {
type = list(any)
default = [
"app",
# Some containers do not provide netstat or lsof. This command will get you the local IP a session is established on
# In short: This gets the output from namespace 1 (where usually the process is running inside the container), filters out the field where the hex IP is located and converts it into a readable IP in the right format. (some fields are inverted etc)
# Benefit is that you dont need netstat installed to see connections.
printf '%d.%d.%d.%d\n' $(grep -v local /proc/1/net/tcp | awk '{print $2}'|cut -d: -f1| sed -r 's/(..)/0x\1 /g') | awk -F. '{for (i=NF; i>0; --i) printf "%s%s", (i<NF ? "." : ""), $i; printf "\n"}'
# This lists the connections that are established.
printf '%d.%d.%d.%d\n' $(grep -v rem /proc/1/net/tcp | awk '{print $3}'|cut -d: -f1| sed -r 's/(..)/0x\1 /g') | awk -F. '{for (i=NF; i>0; --i) printf "%s%s", (i<NF ? "." : ""), $i; printf "\n"}'
@a-nldisr
a-nldisr / keybase_cp.sh
Last active May 21, 2024 21:00
Keybase CP script.
#!/usr/bin/env bash
# Script created by Rogier Dikkes.
# This script is licensed under the GNU GPL version 3.0.
# This script is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@a-nldisr
a-nldisr / gist:df268155cc52b146853304caefde0bfd
Last active April 20, 2021 07:37
Setup private repo in Rancher Chart repository
Rancher only supports specific SSH key formats. When you try to add a ssh-key it often will fail and give the following error because the format is incorrect:
data does not contain a valid RSA or ECDSA private key
This issue gave the idea that the Rancher interface has limited SSH key support: https://github.com/rancher/fleet/issues/138
Generate the private key and public key:
ssh-keygen -t rsa -b 4096 -m pem -C "Rancher chart ssh-key"
Since there is no password option in the Rancher interface, provide the keys without a passphrase and place the keys to a location of your choice.
Test the key against Github to validate it is correct:
ssh-agent bash -c 'ssh-add /Users/USERNAME/.ssh/id_rsa_rancher_chart; git clone [email protected]:REPOSITORY/charts.git'
# Attach the public ELBs to the instance if they change
resource "aws_elb_attachment" "default" {
depends_on = [var.elb_depends_on]
for_each = toset(local.instance_ids)
elb = aws_elb.default.id
instance = each.value
}
changed: [127.0.0.1] => (item={'changed': False, 'stat': {'exists': False}, 'invocation': {'module_args': {'path': '/Users/rogierdikkes/Git/ansible/roles/role/handlers', 'follow': False, 'get_md5': False, 'get_checksum': True, 'get_mime': True, 'get_attributes': True, 'checksum_algorithm': 'sha1'}}, 'failed': False, 'item': {'dest': 'handlers'}, 'ansible_loop_var': 'item'}) => {
"ansible_loop_var": "item",
"changed": true,
- name: 'Verify if directories already exists'
stat:
path: "{{ playbook_dir }}/roles/{{ new_role_name }}/{{item.dest}}"
register: folder_stats
loop:
- { dest: "tasks" }
- { dest: "templates" }
- { dest: "defaults" }
- { dest: "handlers" }
- name: 'Register Test VPC into a var'
ec2_vpc_net_facts:
filters:
"tag:Name": test-vpc
register: vpctest
# You probably need to change the IP for something at your side
- name: 'Creating Customer Gateway'
ec2_customer_gateway:
- name: set up VPN with tunnel options utilizing 'TunnelInsideCidr' only
ec2_vpc_vpn:
state: present
filters:
vpn: vpn-XXXXXXXX
static_only: true
tunnel_options:
-
TunnelInsideCidr: '169.254.100.1/30'
-
#!/bin/bash
cat >> ./file1.text <<EOF
YOUR_NAME: '$RELEASE_NAME'
YOUR_ADDR: '$RELEASE_NAMESPACE'
EOF
cat >> ./file2.text <<EOF
MY_NAME: '$RELEASE_NAME'
MY_ADDR: '$RELEASE_NAMESPACE'