Skip to content

Instantly share code, notes, and snippets.

View deekayen's full-sized avatar
🏡
Working from home

David Norman deekayen

🏡
Working from home
View GitHub Profile
@deekayen
deekayen / runonce.bat
Created July 20, 2018 20:03
Run Once: Start WinRM for Ansible to connect to Windows
powershell.exe -Command "& {[Net.ServicePointManager]::SecurityProtocol = 'tls12'; Invoke-WebRequest -Uri https://raw.githubusercontent.com/ansible/ansible/7963279fc2c3a8cfa6affb70307bac6fa669679c/examples/scripts/ConfigureRemotingForAnsible.ps1 -OutFile C:\Windows\Temp\ConfigureRemotingForAnsible.ps1}"
powershell.exe -ExecutionPolicy Bypass -File C:\Windows\Temp\ConfigureRemotingForAnsible.ps1 -SkipNetworkProfile -EnableCredSSP -ForceNewSSLCert -CertValidityDays 3650
@deekayen
deekayen / vault.sh
Last active July 18, 2018 02:47
Configure a default vault password file for Ansible AWX
docker exec -it awx_task_containerid bash
vi /var/lib/awx/.vault_pass.txt
vi /etc/ansible/ansible.cfg
# add /var/lib/awx/.vault_pass.txt to ansible.cfg
exit
@deekayen
deekayen / upgrade.sh
Last active June 17, 2021 04:41
Upgrade Ansible AWX containers
docker stop awx_task
docker rm awx_task
docker rmi ansible/awx_task:latest
docker stop awx_web
docker rm awx_web
docker rmi ansible/awx_web:latest
git pull
cd installer
@deekayen
deekayen / substr.yml
Created March 21, 2018 17:45
Ansible variable substring from regex_replace
---
# RUN: ansible-playbook -i localhost, substr.yml
- hosts: localhost
vars:
stuff: [email protected]
ansible_user: deekayen
tasks:
@deekayen
deekayen / gen_wildcard_csr.sh
Created March 13, 2018 20:26
Generate a multi subdomain-wildcard CSR.
cat > csr_details.txt <<-EOF
[req]
default_bits = 3072
prompt = no
default_md = sha256
req_extensions = req_ext
distinguished_name = dn
[ dn ]
C=US
@deekayen
deekayen / ConfigureRemotingForAnsible.ps1
Last active March 10, 2022 15:31
Configure WinRM for Ansible powershell using SHA-2 certificate
#Requires -Version 3.0
# Configure a Windows host for remote management with Ansible
# -----------------------------------------------------------
#
# This script checks the current WinRM (PS Remoting) configuration and makes
# the necessary changes to allow Ansible to connect, authenticate and
# execute PowerShell commands.
#
# All events are logged to the Windows EventLog, useful for unattended runs.
@deekayen
deekayen / monitor.ps1
Created September 8, 2017 18:33
Send an email alert with a list of files in a path older than 5 minutes.
# Set-ExecutionPolicy Unrestricted
$src1="\\processing\files"
$sendmail=$false
Get-ChildItem -path $src1 -Recurse -File |
Foreach-Object {
$dtdiff = New-TimeSpan ($_.CreationTime) $(Get-Date)
if ($dtdiff.minutes -gt 5) {
$strbody=$strbody +$_.fullname+ " - Last Modified Time: " +$_.LastWriteTime +"`r`n"
@deekayen
deekayen / ListAllOldBuilds.py
Created September 5, 2017 14:14
A python script you could run in Jenkins to find all jobs which the latest build is older than 6 months.
from jenkins import Jenkins, JenkinsError, Job, Server
# http://jenkins-webapi.readthedocs.org/en/latest/
from jira.client import JIRA
import re
import xml.etree.ElementTree as ET
import sys
import time
import requests
#Jenkins connection
@deekayen
deekayen / clean_properties_files.sh
Created August 8, 2017 19:05
Grep an environment name from tomcat.conf, then delete properties files which don't match that environment.
#!/bin/bash
# Removes the -dev and -prod files.
# /var/config/com/company/thing/drivers/config/thing-dev.properties
# /var/config/com/company/thing/drivers/config/thing-prod.properties
# /var/config/com/company/thing/drivers/config/thing-qa.properties
# /var/config/com/company/thing/drivers/config/database.properties
# Looks for "qa" in tomcat.conf on the JAVA_OPTS line:
# JAVA_OPTS="-Denvironment=qa"
@deekayen
deekayen / vcg_scan_jenkins.ps1
Created August 8, 2017 18:54
Scan a workspace of Java code using Visual Code Grepper and save the result as a CSV file to a Windows network share. Filter for high and critical findings only.
$file = "\\localhost\d$\Reports\Releases\$env:JOB_NAME\$env:BUILD_ID\tfsvcgscan.csv"
cd "C:\Program Files (x86)\VisualCodeGrepper"
Write-Host "Creating destination directory..."
New-Item -Force -ItemType Directory -path "\\localhost\d$\Reports\Releases\$env:JOB_NAME\$env:BUILD_ID"
Write-Host "Writing to \\localhost\d$\Reports\Releases\$env:JOB_NAME\$env:BUILD_ID\tfsvcgscan.csv"
Write-Host "Running VisualCodeGrepper.exe..."