Skip to content

Instantly share code, notes, and snippets.

View upload.js
var express = require('express')
var multer = require('multer')
var upload = multer({ dest: 'uploads/' })
var app = express()'/upload', upload.single('test'), function (req, res, next) {
console.log('File received...')
console.log(req.file, req.body)
try {
import urllib3
import json
def lambda_handler(event, context):
http = urllib3.PoolManager()
r = http.request('POST', 'http://ip-172-31-72-37.ec2.internal/upload',
View vpc-ecs.template.yaml
AWSTemplateFormatVersion: "2010-09-09"
Description: "Template for ECS VPC in two AZ's"
Description: The name of the VPC being created.
Type: String
Default: "vpc-ecs (VPC For ECS with Public and Private Subnets with a NATGW)"
View ocp-trust-private-registry.yml
# extract private registry CA or cert to a crt file
- hosts: all
become: yes
jairojunior /
Last active Dec 13, 2018
Automating Deployment Strategies with Ansible - Part I

Automating Deployment Strategies with Ansible - Part I

Why Deployment?

When you describe your technology stack, from the bottom to the top layer: hardware, OS, middleware and application - with their respective configurations - it is easy to notice that as we go up in the stack, more frequent are the changes. Your hardware will hardly change, your operating system has a long life cycle and your middleware will keep up with applications needs, the element the most changes, even if your release cycle is long (weeks or months), applications will be the volatile.

tech stack freq of change

In "The Practice of System and Network Administration", the authors categorize the biggest "time sinkholes" in IT as: manual/non-standard provisioning of Operating Systems and application deployments. These time sink holes will consume your time, with either repetitive tasks or unplanned work.

jairojunior /
Created Nov 30, 2018
Change SSH port during instance launching
sed -i -e "/^#*[\\s]*Port\\s.*/s//Port 2222/" /etc/ssh/sshd_config
semanage port -a -t ssh_port_t -p tcp 2222
systemctl restart sshd
jairojunior / fix-docker-bridge.yml
Created Nov 20, 2018
Change docker bridge CIDR
View fix-docker-bridge.yml
- hosts: nodes
- name: Fix bridge
path: /etc/sysconfig/docker
regexp: '^OPTIONS='
line: "OPTIONS='--selinux-enabled --log-driver=journald --bip'"
jairojunior /
Created Nov 16, 2018
Testing Ansible Roles with Molecule

Testing Ansible Roles with Molecule

Tests techniques play an important role in software development, and it's no different when we are talking about Infrastructure as Code (IaC).

While developing you are always testing and constant feedback is necessary to drive your development. If you're taking to long to get feedback on a change, your steps might be too large, making errors hard to spot. Baby steps and fast feedback are the essence of TDD (Test Driven Development), but how do I apply this to the development of ad-hoc playbooks or roles?

When you're developing an automation, a typical workflow would start with a new virtual machine. We will use Vagrant to illustrate this idea, but it could be libvirt, Docker, VirtualBox or VMware used directly in your machine and even an instance in a private or public cloud or a virtual machine provisioned in your data center hypervisor (oVirt, Xen, VMware).

> NOTE: When deciding which one to use you'll have to balance feedback speed and similarity with you

View generate-rollups.rb
def missing_hours(vm_id, day)
present_hours = MetricRollup.where(:resource_id => vm_id, :resource_type => 'VmOrTemplate', :capture_interval_name => 'hourly').where("date_trunc('day', timestamp) = '#{day}'").group("resource_id").group("timestamp").select("timestamp").order("timestamp").collect { |rollup| rollup.timestamp.hour }
day_hours - present_hours
def generate_missing(vm_id, day)
objs = []
jairojunior / jboss.yml
Created Jun 5, 2018
JBoss Ansible Modules
View jboss.yml
- hosts:
connection: local
- name: Configure datasource