Skip to content

Instantly share code, notes, and snippets.

View laidbackware's full-sized avatar

Matt laidbackware

View GitHub Profile
@laidbackware
laidbackware / part1_answers.yml
Last active May 30, 2019 19:18
nsxt_tutorials_1_answers
---
nsxt_ip_sets:
- display_name: google_dns
ip_addresses:
- '8.8.8.8'
- '8.8.4.4'
state: present
nsxt_firewall_section:
- display_name: Default rules
stateful: True
@laidbackware
laidbackware / manager.yml
Last active May 29, 2019 20:55
nsxt_tutorial1_manager
---
hostname: nsxt-manager.lab.local
username: admin
password: nsxt-password
validate_certs: False
@laidbackware
laidbackware / firewall_ipsets.yml
Last active May 29, 2019 20:49
nsxt_tutorials_1_playbook
---
- hosts: 127.0.0.1
connection: local
tasks:
- name: Create a new IP Set
nsxt_ip_sets:
hostname: "{{ hostname }}"
username: "{{ username }}"
password: "{{ password }}"
validate_certs: "{{ validate_certs }}"
@laidbackware
laidbackware / nsxt_part2_answers.yml
Last active August 25, 2019 16:53
nsxt_part2_answers
---
nsxt_services:
- display_name: HTTPS-Alt
nsservice_element:
destination_ports:
- 8443
l4_protocol: TCP
resource_type: L4PortSetNSService
state: present
nsxt_ip_sets:
---
- hosts: 127.0.0.1
connection: local
tasks:
- name: Create service
nsxt_services:
hostname: "{{ hostname }}"
username: "{{ username }}"
password: "{{ password }}"
validate_certs: "{{ validate_certs }}"
import ssl, atexit, os, time, sys
try:
from pyVim import connect
except:
from pyvim import connect
from pyVmomi import vim
from getpass import getpass
try:
vc_fqdn = sys.argv[1]
except IndexError:
@laidbackware
laidbackware / update_protected_router.py
Last active December 13, 2019 11:07
How to update a protected NSX-T object
import requests, json
from pprint import pprint
from urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
# Setup session object
s = requests.Session()
s.verify = False
# The X-Allow-Overwrite parameter will allow the admin user to update protected objects
@laidbackware
laidbackware / om_pks_prep.sh
Last active February 11, 2020 15:51
Ops Man tools
#!/bin/bash
set -euxo pipefail
OM_TOKEN=$1
OM_VERSION=4.4.2
UAA_CLI_VERSION=0.10.0
PKS_VERSION=1.6.1
@laidbackware
laidbackware / parent_branch.sh
Last active March 12, 2020 09:05
Find parent branch
#!/bin/bash
git show-branch -a \
| grep '\*' \
| grep -v `git rev-parse --abbrev-ref HEAD` \
| head -n1 \
| sed 's/.*\[\(.*\)\].*/\1/' \
| sed 's/[\^~].*//'
# Get machine cert from $HOSTNAME on $PORT
echo -n | openssl s_client -connect ${HOSTNAME}:${PORT} 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'