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 / 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: deekayen@WINDOMAIN.COM
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..."
@deekayen
deekayen / web.config
Created June 8, 2017 21:35
Secure options for IIS web.config files to require SSL in cookies and enable strict transport security.
<?xml version="1.0"?>
<configuration>
<system.web>
<httpCookies requireSSL="true" />
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=31536000"/>
@deekayen
deekayen / appcmd-X-Frame-Options-SAMEORIGIN.bat
Created June 8, 2017 21:32
Add X-Frame-Options: SAMEORIGIN HTTP header to all websites on IIS web servers.
c:\windows\system32\inetsrv\appcmd.exe set config /section:httpProtocol /+customHeaders.[name='X-Frame-Options',value='SAMEORIGIN']