This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
from botocore.exceptions import ClientError | |
import datetime | |
from datetime import date | |
import os | |
from ConfigParser import SafeConfigParser | |
access_file = os.path.join(os.environ['HOME'], '.aws', 'credentials') | |
access_list = SafeConfigParser() | |
access_list.read(access_file) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# path default of known_hosts module is home of the user running the playbook, i.e. $HOME/.ssh/known_hosts | |
- name: find public key for stash | |
command: ssh-keyscan "{{ domain }}" | |
register: pub_key | |
- name: add public key for stash to known_hosts | |
known_hosts: | |
name: "{{ domain }}" | |
key: "{{ pub_key.stdout }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function clone_pull { | |
DIRECTORY=$(basename "$1" .git) | |
if [ -d "$DIRECTORY" ]; then | |
cd "$DIRECTORY" | |
git pull | |
cd ../ | |
else | |
git clone "$1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function hurryup () { | |
until ssh -o ConnectTimeout=2 "$1"@"$2" | |
do sleep 1 | |
done | |
} | |
hurryup root "10.10.0.3" | |
# -o ConnectTimeout=2 is a slightly hacky way of getting around not responding to network packets, | |
# reporting ssh: connect to host 10.10.0.3 port 22: Operation timed out until it's responsive. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data "aws_caller_identity" "current" {} | |
resource "aws_s3_bucket" "terraform_state" { | |
bucket = "${data.aws_caller_identity.current.account_id}-tfstate" | |
versioning { | |
enabled = true | |
} | |
policy = <<POLICY | |
{ | |
"Version": "2012-10-17", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pipeline { | |
agent { | |
docker { | |
image 'hashicorp/terraform:latest' | |
label 'LINUX-SLAVE' | |
args '--entrypoint="" -u root -v /opt/jenkins/.aws:/root/.aws' | |
} | |
} | |
options { | |
ansiColor('xterm') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def call () { | |
def map = [:] | |
def causeClass = currentBuild?.getBuildCauses()[0]?._class | |
if(causeClass == "com.cloudbees.jenkins.plugins.pipeline.events.EventTriggerCause") { | |
// This run was triggered by an event and not by a person | |
map = [ | |
event: currentBuild?.getBuildCauses()[0]?.event?.event?.toString(), | |
action: currentBuild?.getBuildCauses()[0]?.event?.action?.toString(), | |
awsprofile: currentBuild?.getBuildCauses()[0]?.event?.awsprofile?.toString(), | |
tfver: currentBuild?.getBuildCauses()[0]?.event?.tfver?.toString(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: product-web | |
spec: | |
type: ClusterIP | |
selector: | |
app: product-web | |
ports: | |
- protocol: TCP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stage ('Release') { | |
steps { | |
script { | |
def apply = true | |
def status = null | |
try { | |
status = sh(script: "aws cloudformation describe-stacks --stack-name WEBAPP-${STACK_ENV} \ | |
--query Stacks[0].StackStatus --output text --profile ${PROFILE}", returnStdout: true) | |
apply = true | |
} catch (err) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
''' | |
Update/create a page containing a table w/ Confluence REST API | |
''' | |
import requests | |
import json | |
# Get api credentials from local config file |