Skip to content

Instantly share code, notes, and snippets.

View omerxx's full-sized avatar
🎱
All is as thinking makes it so

Omer Hamerman omerxx

🎱
All is as thinking makes it so
View GitHub Profile
@omerxx
omerxx / create_slave.py
Last active May 6, 2016 12:09
Jenkins SSH node creation with auto registration using python jenkinsapi
from jenkinsapi.jenkins import Jenkins
from jenkinsapi.utils.requester import Requester
from subprocess import check_output
import requests
requests.packages.urllib3.disable_warnings()
# Using AWS AMI allows using the private IP and AWS instance name for the node's registration
# Change these value if you're using other AMI or not using AWS at all
instance_name = check_output(["ec2-metadata", "-i"]).split()[1]
instance_ip = check_output(["ec2-metadata", "-o"]).split()[1]
FROM python
RUN apt-get update && apt-get install -y \
vim \
curl
LABEL image.version="0.0.1-beta"
payload = {"channel": "#general", "username": "webhookbot", "text": "Testing slack webhook", "icon_emoji": ":ghost:"}
url = 'https://hooks.slack.com/services/0000000000/0000000000/0000000000'
requests.post(url, data=json.dumps(payload))
@omerxx
omerxx / chaos.py
Last active April 27, 2017 13:01
Lambda function for killing random task on an ecs family
def lambda_handler(event, context):
import boto3
client = boto3.client('ecs', aws_access_key_id='', aws_secret_access_key='')
response = client.list_tasks(cluster='mycluster', family='myservice', maxResults=1,desiredStatus='RUNNING')
stoptask = response['taskArns'][0].split('/')[1]
print client.stop_task(cluster='mycluster', task=stoptask, reason='chaos monkey')
@omerxx
omerxx / example.yaml
Created August 31, 2017 13:47
Multi Container TaskDefinition in ECS, linked and mounted with Docker daemon
TaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Family: !Ref ServiceName
ContainerDefinitions:
- Name: !Sub ${ServiceName}-container
Essential: true
Image: !Ref DockerImage
Memory: !Ref Memory
PortMappings:
Resources:
ECSCluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: !Ref EnvironmentName
ECSAutoScalingGroup:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
VPCZoneIdentifier: !Ref Subnets
pipeline:
deploy-server-elastic-beanstalk:
image: peloton/drone-elastic-beanstalk
region: us-east-2
application: drone
version_label: ${DRONE_BUILD_NUMBER}-${DRONE_BRANCH}-drone-server
description: Drone server [Deployed with DroneCI]
environment_name: production-drone
environment_update: true
pipeline:
frontend:
image: node
commands:
- npm install
- npm test
backend:
image: golang
commands:
- go test -v
awscli:
image: omerxx/awscli
volumes:
- ~/.aws:/root/.aws
command: tail -f /dev/null
# Usage:
# Save as docker-compose.yml
# Run docker-compose up -d
# Run docker exec -it $(docker ps -q) /bin/sh
import boto3
# Listing all stacks in the AWS account that are currently active
def list_stacks(client):
response = client.list_stacks(
StackStatusFilter=['CREATE_COMPLETE', 'UPDATE_COMPLETE']
)
return response
# Iterate through the list and delete everything