Skip to content

Instantly share code, notes, and snippets.

@mtcoffee
mtcoffee / AWXBackupAndRestore.txt
Created May 28, 2024 18:43
How to Backup/Migrate/Restore AWX
####################How to Backup/Migrate/Restore AWX#############################
#1.Create a postgres backup on the old system
#In K8s
kubectl -n awx exec ansible-awx-postgres-15-0 -- bash -c "pg_dump -U awx awx --format=c" > aws_pg_backup.sql
#In Docker
docker exec tools_postgres_1 /bin/bash -c "pg_dump -U awx awx --format=c" > dockerbackup1.sql
#2. Find the secret_key data from old setup
#In K8s
@mtcoffee
mtcoffee / InstallAWX.sh
Last active June 2, 2024 12:02
Install AWX on K3s
#!/bin/bash
check_sudo() {
if [ "$(id -u)" -ne 0 ]
then echo "Please run as sudo"
exit
fi
}
# List of required packages
@mtcoffee
mtcoffee / removecluster.js
Last active February 29, 2024 18:38
Servicenow K8s cleanup
// Cleanup all Kubernetes tables that are orphaned with no cluster
// Define the tables where records need to be deleted
// MUST BE RUN IN A FIX SCRIPT IN DISCOVERY AND SERVICE MAPPING SCOPE
var k8scluster_sysid = '9c880487475c0a10971497da116d43d1'; //sys_id of cluster
var tables = [
'cmdb_ci_kubernetes_cluster',
'cmdb_ci_kubernetes_service',
'cmdb_ci_kubernetes_replicationcontroller',
'cmdb_ci_kubernetes_replicaset',
'cmdb_ci_kubernetes_daemonset',
@mtcoffee
mtcoffee / ArgoCDonK3s.sh
Created February 11, 2024 00:28
Install ArgoCD on K3s
#This will install the ArgoCD manifest, and add and ingress for traefik so you can access it on http://hostname/argocd
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
kubectl apply -f - << "EOF"
---
#Need to configure argocd to server.insecure: "true"
#https://argo-cd.readthedocs.io/en/stable/operator-manual/ingress/#traefik-v22
apiVersion: v1
kind: ConfigMap
@mtcoffee
mtcoffee / CreatePortainerOnK3s.sh
Last active February 10, 2024 00:34
portainer on K3s with traefik ingress
kubectl create -f - <<EOF
---
kind: Namespace
apiVersion: v1
metadata:
name: portainer
labels:
name: portainer
---
apiVersion: apps/v1
@mtcoffee
mtcoffee / CreateNginxOnK3s.sh
Last active February 10, 2024 00:23
nginx on K3s with traefik ingress
kubectl create -f - <<EOF
---
apiVersion: v1
kind: Namespace
metadata:
name: nginxweb
labels:
name: nginx
---
apiVersion: apps/v1
@mtcoffee
mtcoffee / findrecords.js
Last active December 20, 2023 21:13
Find all references to an existing record in ServiceNow
/*
Borrowing from https://servicenowguru.com/system-definition/find-references-specific-record/
This background script finds all references to an existing record, e.g., a company, or group
and exports them to a CSV saved in the sys_data_source table.
*/
var table = 'core_company';
var rec_sys_id = '0e8b8e650a0a0b3b004f285ffbb1a4fc';
var references = findReferencesToCoreRecord(table, rec_sys_id);
@mtcoffee
mtcoffee / terraform.tfvars
Last active December 10, 2023 17:18
terraform_aws_windows_ec2_t2micro_tfvars
access_key = "SampleAccesKeyAKIA5HQPIDLAFRCZVQ88"
secret_key = "SamplePrivateKeylmy+asdfasdsdfaa3424g32gfasdfaS"
@mtcoffee
mtcoffee / variables.tf
Created December 10, 2023 17:14
terraform_aws_windows_ec2_t2micro_variables
variable "access_key" {
description = "Access key to AWS console"
}
variable "secret_key" {
description = "Secret key to AWS console"
}
variable "instance_name" {
description = "Name of the instance to be created"
@mtcoffee
mtcoffee / main.tf
Created December 10, 2023 17:08
terraform_aws_windows_ec2_t2micro
provider "aws" {
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
region = "us-west-2"
}
resource "aws_instance" "ec2_instance" {
ami = "${var.ami_id}"
instance_type = "${var.instance_type}"
key_name = "${var.ami_key_pair_name}"