Skip to content

Instantly share code, notes, and snippets.

View laidbackware's full-sized avatar

Matt laidbackware

View GitHub Profile
@laidbackware
laidbackware / Dockerfile
Created June 10, 2021 10:24
Powershell Docker with PowerCLI
FROM ubuntu:20.04
RUN set -xe \
&& echo "Update the list of packages" \
&& apt-get update \
&& echo "Install pre-requisite packages." \
&& apt-get install -y wget apt-transport-https software-properties-common \
&& echo "Download the Microsoft repository GPG keys" \
&& wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb \
&& echo "Register the Microsoft repository GPG keys" \
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: wcp:administrators:override
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- apiGroup: rbac.authorization.k8s.io
@laidbackware
laidbackware / hackery.md
Last active May 5, 2021 15:35
Various vSphere Hackery
@laidbackware
laidbackware / tkgs-auth.md
Last active October 27, 2023 12:43
Tanzu with Kubernetes Authentication Procedures

How to access the Tanzu with vSphere Products

SSH to the Supervisor Cluster nodes

On the vCenter run to get supervisor creds /usr/lib/vmware-wcp/decryptK8Pwd.py

SSH to supervisor VM as root.

SSH to the Guest Cluster nodes

Commands should be run on the supervisor cluster.

Using private keys

@laidbackware
laidbackware / gist:65ee73cf2c3e26e77187dcf060e57984
Last active November 6, 2023 11:39
VSCode Remtee SSH with GCP Instance

Install VSCode - https://code.visualstudio.com/download Install Remote-SSH plugin inside VSCode from the extensions page

Linux/Mac

  1. If you have the GCP SDK installed on your local machine
    1. Run the following

      gcloud compute config-ssh
      Record the hostname it provides as an the SSH example.
      E.g. $ ssh jumpbox.us-central1-a.pal4pe-1109-mproud

@laidbackware
laidbackware / vcenter_rest_api_example.py
Last active March 24, 2021 09:27
Working with the vCenter Python Rest API client
#!/usr/bin/python
from __future__ import absolute_import, division, print_function
__metaclass__ = type
from com.vmware.cis.tagging_client import CategoryModel
from vmware.vapi.vsphere.client import create_vsphere_client
from pprint import pprint
import requests
@laidbackware
laidbackware / principal-identities-with-certificate.sh
Last active November 25, 2020 10:15
Upload NSX-T principal with Cert
cert_request=$(cat <<END
{
"name": "tkgi-nsx-t-superuser",
"node_id": "node-1",
"role": "enterprise_admin",
"is_protected": "true",
"certificate_pem" : "$(awk '{printf "%s\\n", $0}' tkgi-nsx-t-superuser.crt)"
}
END
)
@laidbackware
laidbackware / nsxt-requests.py
Last active November 15, 2021 13:52
Python requests session basic auth example - NSX-T update machine cert
import requests, urllib3
from pprint import pprint
urllib3.disable_warnings()
s = requests.Session()
s.auth = ('admin', 'password')
s.verify = False
pprint(s.get('https://192.168.0.193/api/v1/node/services/http').json())
@laidbackware
laidbackware / get_s3_file.sh
Last active November 25, 2020 17:00 — forked from davidejones/get_s3_file.sh
Test IAM access to AWS s3 bucket from EC2
#!/bin/bash
instance_profile=`curl http://169.254.169.254/latest/meta-data/iam/security-credentials/`
aws_token_response=`curl --silent http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile}`
aws_access_key_id=`echo "${aws_token_response}" | grep AccessKeyId | cut -d':' -f2 | sed 's/[^0-9A-Z]*//g'`
aws_secret_access_key=`echo "${aws_token_response}" | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
token=`echo "${aws_token_response}" | sed -n '/Token/{p;}' | cut -f4 -d'"'`
echo "${aws_token_response}" | sed -n '/Expiration/{p;}'
file=$2
# 1 liner to check if var is set
: ${VAR_NAME:?"You must st VAR_NAME"}