Skip to content

Instantly share code, notes, and snippets.

View marshyon's full-sized avatar

jon brookes marshyon

View GitHub Profile
@marshyon
marshyon / AnsibleFromDocker.md
Last active October 30, 2022 18:01
running ansible from a container using docker

build the container image with

docker build -t ansible:0.0.1 .

run ansible ping command against hosts defined in an inventory file, noting that

  • the keys file needs to contain id_rsa file with appropriate permissions
  • a known_hosts file needs to be present in the keys folder
@marshyon
marshyon / git-secret.md
Created October 26, 2022 21:25
git secret can be used to secure plain text secrets as gpg encrypted data which may be then commited to git repositories

disclaimer

at your own risk

never commit plain text passwords to Git, even private ones - they can always be leaked without your knowing at some point

where appropriate, dont use git secret, instead use a secret vault as in AWS, Azure or something like Hashicorp vault or secured secrets in pipelines, again when appropriate, you know the drill

@marshyon
marshyon / _run_github_pipeline.md
Last active December 7, 2022 13:32
run_github_pipeline.sh
@marshyon
marshyon / sendgrid.js
Created August 26, 2022 18:07
use sendgid api to send a mail using a preconfigured template in the sendgrid web console
require('dotenv').config()
const sgMail = require('@sendgrid/mail')
sgMail.setApiKey(process.env.SENDGRID_API_KEY)
const msg = {
to: process.env.RECIPIENT,
from: process.env.SENDER,
templateId: process.env.SENDGRID_TEMPLATE_KEY,
dynamicTemplateData: {
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{uid} {
allow read: if request.auth.uid == uid;
match /checkout_sessions/{id} {
allow read, write: if request.auth.uid == uid;
}
match /subscriptions/{id} {
@marshyon
marshyon / StarshipSetup.md
Last active August 12, 2022 12:42
starship prompt setup tldr

run script directly with

apt install -y curl
source <(curl -s https://gist.githubusercontent.com/marshyon/0c5d916d14be7b43d1d7e946073816a6/raw/619bd7581a196173280d745081852b4d3cc461f8/AnsibleControlNodeSetup.sh)

or alternatively manual steps as follows :

install pre-requisite packages ( on a minimal install of Ubuntu 2204 LTS )

@marshyon
marshyon / gh_backup.sh
Created April 24, 2022 15:04
github backup
#!/usr/bin/env bash
# github backup
#
# clone / mirrors $max repos from GitHub - set $max to an appropriate
# value
max=100
# PRE REQUISITES
@marshyon
marshyon / _read_and_write_to_JSON_with_bash.md
Last active September 11, 2022 13:46
bash write and read simple JSON configuration data
@marshyon
marshyon / create_files_based_on_time.ps1
Last active January 30, 2022 15:09
script that runs forever and creates backup files based on time of day
$timeItems = @("09", "13", "18", "22")
Write-Host "starting and waiting for hours [" $timeItems "]"
function New-Backup {
$date = Get-Date
$currentHour = Get-Date -Format HH
$continue = 0