Skip to content

Instantly share code, notes, and snippets.

View luksi1's full-sized avatar

Luke Simmons luksi1

View GitHub Profile
@luksi1
luksi1 / transition.jira.issues.py
Created September 6, 2019 00:16
Transition resolved issues to closed in jira
from jira import JIRA
jiraUrl = ""
username = ""
project = ""
# I'm not sure if this is universal, but it's the ID for closed issues on our instance
closed_issue_id = "701"
# This needs to be an API key
password = ""
@luksi1
luksi1 / puppet-template.rb
Created August 12, 2019 16:50
Testing a template with rspec-puppet
require 'spec_helper'
describe 'foo' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
describe 'foo equals bar' do
let(:pre_condition) do
'class {"::foo":
@luksi1
luksi1 / centos-loopback-interface
Created February 8, 2019 15:06
Add Virtual IP address to a loopback interface in Ubuntu and CentOS/Redhat
# /etc/sysconfig/ifcfg-lo
DEVICE=lo
# localhost
IPADDR0=127.0.0.1
NETMASK0=255.0.0.0
NETWORK0=127.0.0.0
BROADCAST0=127.255.255.255
# virtual ip
IPADDR1=<VIRTUAL IP ADDRESS>
NETMASK1=255.255.255.255
@luksi1
luksi1 / json.ps1
Created September 19, 2018 20:45
PowerShell JSON
$json = '[{
"certname": "foo.domain.com",
"environment": "production",
"name": "keystores",
"value": {
"/usr/local/cert/foo.jks:foo": {
"days_remaining": 396,
"issuer": "C=COM O=Foo Co. CN=Foo Type 3 CA v1",
"owner": "C=COM L=Rome O=Vatican CN=pope.domain.com"
}
@luksi1
luksi1 / custom-class-as-validator.ps1
Last active September 13, 2018 13:35
PowerShell helpers
# Custom validator for one element
class ValidateElementAttribute : System.Management.Automation.ValidateArgumentsAttribute
{
[void] Validate([object]$arguments, [System.Management.Automation.EngineIntrinsics]$engineIntrinsics)
{
# Validation happens here
if ($arguments -ne "foo") {
throw "you should have chosen foo"
@luksi1
luksi1 / handling-nested-json.ps1
Last active September 12, 2018 18:10
handling-nested-json
$json = '{
"keystores": {
"/usr/local/cert/foo/cert1.jks:signing1": {
"days_remaining": 629,
"issuer": "C=SE O=Inera AB CN=SITHS Type 3 CA v1 PP",
"owner": "C=SE L=Vanersborg O=Vastra Gotalands Lans Landsting CN=footest.vgregion.se serialNumber=12345"
},
"/usr/local/cert/foo/cert1.jks:signing2": {
"days_remaining": 629,
"issuer": "C=SE O=Inera AB CN=SITHS Type 3 CA v1 PP",
# Custom validator for one element
class ValidateElementAttribute : System.Management.Automation.ValidateArgumentsAttribute
{
[void] Validate([object]$arguments, [System.Management.Automation.EngineIntrinsics]$engineIntrinsics)
{
# Validation happens here
if ($arguments -ne "foo") {
throw "you should have chosen foo"
function test {
[cmdletbinding()]
param(
[parameter(mandatory)]
[validatescript({test-computer $_})]
[string] $computername
)
write-host $computername
@luksi1
luksi1 / docker.mysql
Created May 21, 2018 11:28
MySQL Docker commands
# Get MySQL CLI
docker exec -it <CONTAINER> sh -c 'mysql -u${MYSQL_USER} --password=${MYSQL_PASSWORD}'
# Run SQL script
cp my.sql /path/to/mysql/volume
docker exec <CONTAINER> sh -c 'mysql -u${MYSQL_USER} --password=${MYSQL_PASSWORD} $MYSQL_DATABASE < /var/lib/mysql/my.sql'
# Backup MySQL database
docker exec <CONTAINER> sh -c 'exec mysqldump -u${MYSQL_USER} --password=${MYSQL_PASSWORD} $MYSQL_DATABASE' > my.backup.sql