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
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
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
#!/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
#!/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
# 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
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
import boto3 | |
from botocore.exceptions import ClientError | |
import datetime | |
from datetime import date | |
import os, re | |
global DEFAULT_AGE_THRESHOLD_IN_DAYS | |
DEFAULT_AGE_THRESHOLD_IN_DAYS = 7 | |
def main(): |
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() |
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
## Meant to be scheudled on a cron/timer of 90 days (CIS Benchmark) | |
## The target keys need permissions to rotate themselves | |
import boto3 | |
from botocore.exceptions import ClientError | |
import os | |
from datetime import datetime | |
import shutil | |
from ConfigParser import SafeConfigParser |