This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
A sample background script to demonstrate the effectiveness of the addExtraField function. | |
Already explained well by Rob Fedoruk in https://www.servicenow.com/community/developer-blog/quot-addextrafield-quot-amazing-performance-improvement-to/ba-p/3127640 | |
but we'll put an ITOM spin on it and query some CMDB tables. | |
*/ | |
var recCI, stringOfCIData, timerStart, timerEnd; | |
timerStart = new Date().getTime(); // Record start time | |
recCI = new GlideRecord('cmdb_ci'); | |
recCI.query(); | |
while (recCI.next()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reference: https://www.servicenow.com/docs/csh?topicname=client-credentials.html&version=latest | |
# Must set property glide.oauth.inbound.client.credential.grant_type.enabled | |
# Configure user in the oauth_entity.user field and set oauth_entity.default_grant_type to client_credential | |
$clientId = "MyClientID" | |
$clientSecret = "MySecret" | |
$serviceNowInstance = "https://dev1234567.service-now.com" | |
$apiQuery = "/api/now/table/incident?sysparm_query=active=true" | |
# Get count of active incidents |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####################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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
check_sudo() { | |
if [ "$(id -u)" -ne 0 ] | |
then echo "Please run as sudo" | |
exit | |
fi | |
} | |
# List of required packages |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl create -f - <<EOF | |
--- | |
kind: Namespace | |
apiVersion: v1 | |
metadata: | |
name: portainer | |
labels: | |
name: portainer | |
--- | |
apiVersion: apps/v1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl create -f - <<EOF | |
--- | |
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: nginxweb | |
labels: | |
name: nginx | |
--- | |
apiVersion: apps/v1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
access_key = "SampleAccesKeyAKIA5HQPIDLAFRCZVQ88" | |
secret_key = "SamplePrivateKeylmy+asdfasdsdfaa3424g32gfasdfaS" |
NewerOlder