Skip to content

Instantly share code, notes, and snippets.

View waltervargas's full-sized avatar
🎯
BioHacking(self)

Walter Vargas waltervargas

🎯
BioHacking(self)
View GitHub Profile
jekyll-crosspost_to_medium:
enabled: true
cache: .jekyll-crosspost_to_medium
status: public
license: public-domain
backdate: true
jekyll-crosspost_to_medium:
enabled: true
cache: .jekyll-crosspost_to_medium
status: public
license: public-domain
backdate: true
@waltervargas
waltervargas / install-go1.8.3.sh
Created June 22, 2017 18:32
Installs go version 1.8.3 in your $HOME directory
cd $HOME
wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
tar -zxvf go1.8.3.linux-amd64.tar.gz
mv go go1.8.3
ln -s go1.8.3 go
echo "Done. You need to add $HOME/go/bin to $PATH"
@waltervargas
waltervargas / compile-terraform.sh
Last active June 21, 2017 23:03
Compile Terraform using Docker
git clone [email protected]:hashicorp/terraform.git
cd terraform
docker run --rm -v $(pwd):/go/src/github.com/hashicorp/terraform -w /go/src/github.com/hashicorp/terraform -e XC_OS=linux -e XC_ARCH=amd64 golang:latest bash -c "apt-get update && apt-get install -y zip && make bin"
bin/terraform -v
@waltervargas
waltervargas / ecr_image_commit_id_check.sh
Created June 13, 2017 01:24
Checks if the last commit hash is present as a tag for Docker Images in a particular ECR repository.
NAME=dockercoins
IMAGES=$(aws --region ${REGION} ecr list-images --repository-name ${NAME} --output json)
COMMIT_ID=$(git log --pretty=format:%H -1 . )
IMAGES_TEST_COMMIT_ID=$(echo $IMAGES | jq '.imageIds[] | .imageTag | select (.!=null) | test("$COMMIT_ID")')
if [[ ! ${IMAGES_TEST_COMMIT_ID} == *true* ]]; then
echo "Build and Push to ECR"
fi
@waltervargas
waltervargas / curl-jenkins.sh
Created June 3, 2017 03:35
Jenkins BuildWithParameters from curl
curl -v -X POST "http://admin:[email protected]:8080/job/seed-job/buildWithParameters?GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)"
@waltervargas
waltervargas / Jenkinsfile
Last active May 26, 2017 00:33
Jenkinsfile with a stage to install bats the bash testing suite
node('master'){
stage('Install Bats'){
sh """
if [ ! -d bats ]; then
git clone https://github.com/sstephenson/bats.git
fi
if [ ! -f ~/.local/bin/bats ]; then
cd bats/
./install.sh $HOME/.local
@waltervargas
waltervargas / Jenkinsfile.groovy
Created May 15, 2017 16:57
aws sts assume role from jenkinsfile
// Receive a json and returns a groovy map
def _dict_from_json(json){
json = json.replaceAll("\\{", "[")
json = json.replaceAll("\\}", "]")
def map = evaluate(json)
return map
}
def _aws_assume_role(arn, session_name){
def _script = "aws sts assume-role --role-session-name ${session_name} --role-arn ${arn}"
@waltervargas
waltervargas / ansible-role-test.sh
Created May 7, 2017 20:09 — forked from geerlingguy/ansible-role-test.sh
Ansible Role Test Shim Script
#!/bin/bash
#
# Ansible role test shim.
#
# Usage: [OPTIONS] ./tests/test.sh
# - distro: a supported Docker distro version (default = "centos7")
# - playbook: a playbook in the tests directory (default = "test.yml")
# - cleanup: whether to remove the Docker container (default = true)
# - container_id: the --name to set for the container (default = timestamp)
@waltervargas
waltervargas / ecr-jq.sh
Last active May 2, 2017 23:45
Parse ecr describe-repositories output with jq to see if the repo name is there
$ aws --region us-west-1 ecr describe-repositories | jq -r '.repositories | .[] | .repositoryName | test("^nginx$")'
false
false
false
false
true