Skip to content

Instantly share code, notes, and snippets.

View michaelact's full-sized avatar
🧐
Who are you?

michaelact

🧐
Who are you?
View GitHub Profile
@michaelact
michaelact / bar-docker-debian.sh
Last active July 5, 2021 04:52
How to backup your Docker Swarm Cluster?
#!/bin/bash
service docker stop
if [ $# -eq 2 ]
then
if [ $1 = 'backup' ]
then
tar -czvf $2 /var/lib/docker/swarm
elif [ $1 = 'restore' ]
@michaelact
michaelact / main.tf
Created August 3, 2021 14:58
Integrate your github.com/localstack/localstack with Terraform!
provider "aws" {
region = "us-east-1"
s3_force_path_style = true
skip_credentials_validation = true
skip_metadata_api_check = true
skip_requesting_account_id = true
endpoints {
apigateway = "http://localhost:4567"
cloudformation = "http://localhost:4581"
@michaelact
michaelact / filebeat.yml
Last active October 1, 2021 15:46
Filebeat configuration depends on environment variables. Use case: when you want to run multiple filebeat service but in 1 created docker image. Let's contribute to provide a lot of flexibility configuration!
filebeat.inputs:
- type: container
paths:
- "/usr/share/dockerlogs/data/*/*.log"
ignore_older: ${IGNORE_OLDER:10m}
multiline.pattern: ${MULTILINE_PATTERN}
multiline.negate: ${MULTILINE_NEGATE:false}
multiline.match: ${MULTILINE_MATCH:after}
processors:
@michaelact
michaelact / build.sh
Last active November 25, 2021 08:51
Install NPM package from artifact registry inside Container Image | Must be have Service Account file!
#!/bin/bash
set -e
gcloud auth activate-service-account \
--project=$GCP_PROJECT \
--key-file=${GCP_KEY_FILENAME:-service_account.json}
gcloud artifacts print-settings npm \
--project=$GCP_PROJECT \
@michaelact
michaelact / Makefile
Last active January 3, 2022 12:08
Example of the documentation produced from https://github.com/michaelact/Ansibila.go
TMPL_DIR ?= .
.PHONY: prepare
prepare: ## Preparing Ansibila Requirements
@ $(MAKE) --no-print-directory log-$@
mkdir -p ${ROLE_DIR}/molecule/default
mkdir -p ${ROLE_DIR}/meta
touch $(ROLE_DIR)/variables.yml
touch $(ROLE_DIR)/molecule/default/playbook.yml
touch $(ROLE_DIR)/meta/main.yml
@michaelact
michaelact / security.tf
Last active December 2, 2021 07:05
Public ...
module "sg-elasticache" {
source = "terraform-aws-modules/security-group/aws"
name = "sg_elasticache"
description = "Guardian of ElastiCache Cluster"
vpc_id = ""
egress_rules = ["all-all"]
ingress_with_cidr_blocks = [
{
@michaelact
michaelact / tflint.sh
Last active March 10, 2022 03:38
TFLint | Running for Recursive Directory | Support Terragrunt
#!/bin/sh
set -e
find . -type d | grep -v .terraform | tail -n +2 > tfdir.txt
cat tfdir.txt | parallel cp .tflint.hcl {}
cat tfdir.txt | parallel 'cd {} && tflint'
cat tfdir.txt | parallel 'cd {} && tflint --module'
cat tfdir.txt | parallel rm {}/.tflint.hcl
rm tfdir.txt
@michaelact
michaelact / install-k8s.sh
Last active December 20, 2021 06:09
Install k8s + CRI-O
#!/bin/bash
# Create the .conf file to load the modules at bootup
cat <<EOF | sudo tee /etc/modules-load.d/crio.conf
overlay
br_netfilter
EOF
sudo modprobe overlay
sudo modprobe br_netfilter
@michaelact
michaelact / route53-extractor.sh
Last active December 27, 2021 08:47
Export all of your zonefile from Amazon Route 53
#!/bin/bash
# Reference: https://stackoverflow.com/questions/20337749/exporting-dns-zonefile-from-amazon-route-53
HOSTED_ZONE_IDS=$(aws route53 list-hosted-zones --query "HostedZones[*].Id" --output text)
for zoneId in $HOSTED_ZONE_IDS; do \
echo $zoneId >> records.txt
aws route53 list-resource-record-sets --hosted-zone-id $zoneId --output json | jq -jr '.ResourceRecordSets[] | "\(.Name) \t\(.TTL) \t\(.Type) \t\(.ResourceRecords[]?.Value)\n"' >> records.txt
done
@michaelact
michaelact / get-lynis.sh
Last active February 7, 2022 09:50
Common utilities to Harden your Linux Server Configuration
#!/bin/bash
# Source:
# - https://linoxide.com/how-to-install-and-run-lynis-on-ubuntu-linux/
# - https://sysadminxpert.com/how-to-do-security-auditing-of-centos-system-using-lynis-tool/#Install_Lynis_on_Fedora
set -e
OS=$(. /etc/os-release && echo "$ID")
if [[ $OS == "ubuntu" ]]; then
wget -O - https://packages.cisofy.com/keys/cisofy-software-public.key | sudo apt-key add -
echo "deb https://packages.cisofy.com/community/lynis/deb/ stable main" | sudo tee /etc/apt/sources.list.d/cisofy-lynis.list