Skip to content

Instantly share code, notes, and snippets.

View jriguera's full-sized avatar

José Riguera Lopez jriguera

View GitHub Profile
@jriguera
jriguera / segurity_group_rules.sh
Created February 24, 2016 22:52
Neutron cmd to add security group rules
# Add Neutron security groups for ping and ssh
neutron security-group-rule-create \
--protocol icmp \
--direction ingress \
--remote-ip-prefix 0.0.0.0/0 \
default
neutron security-group-rule-create \
--protocol tcp \
@jriguera
jriguera / openstack_cli_ironic.sh
Last active March 16, 2018 22:56
Example how to deploy a baremetal server using ironic standalone
#!/bin/bash
# Create the initial ramdkisk
export ELEMENTS_PATH="/home/jriguera/diskimage-builder/elements"
ramdisk-image-create ubuntu deploy-ironic grub-install -o my-deploy-ramdisk
# Create the image to deploy on disk (with ConfigDrive support)
DIB_CLOUD_INIT_DATASOURCES="ConfigDrive, OpenStack" disk-image-create ubuntu baremetal dhcp-all-interfaces -o my-image
# Define the parameter for the new server
@jriguera
jriguera / new_tenant.sh
Created November 17, 2015 15:23
Openstack CLI commands to create a new Project/Tenant and networks using identity V3 (with groups)
# Now we are managing the users on a project by using groups. So everything
# is about creating users and add they to the groups.
# A special user is created always with the same name of the project,
# just to reserve the name and avoid confusion and have an email.
############## Define those variables for the tenant (this is just an example)
TENANT=test
PASSWORD=test
TENANT_DESC="Test"
@jriguera
jriguera / 00-openvpn-bittorrent.txt
Last active February 4, 2018 09:39
Split routing for bittorrent in Arch
By doing these steps, transmission will be listening only on the VPN interface/network.
As debian/ubuntu are now using systemd, the following instructions should work on those distros.
1) Copy all shell scripts to /usr/local/bin/ and make them executable
2) Copy systemd service unit to /etc/systemd/system/
3) Install transmission: sudo pacman -Syu transmission-cli
4) Install openvpn: sudo pacman -Syu openvpn
5) Change transmission parameters: sudo vim /var/lib/transmission/.config/transmission-daemon/settings.json
6) Create the openvpn client configuration file: /etc/openvpn/client.conf
7) Enable the new service: sudo systemctl enable openvpn-bittorrent
@jriguera
jriguera / list-dockerhub-images.sh
Last active April 12, 2017 11:53
Listing Docker images in DockerHub
#!/bin/bash
# Based on kizbitz/dockerhub-v2-api-organization.sh at https://gist.github.com/kizbitz/175be06d0fbbb39bc9bfa6c0cb0d4721
# Example for the Docker Hub V2 API
# Returns all images and tags associated with a Docker Hub organization account.
# Requires 'jq': https://stedolan.github.io/jq/
# set username, password, and organization
UNAME=""
UPASS=""
@jriguera
jriguera / cf_org.py
Created October 14, 2016 09:31
Ansibe cf organizations
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Program to create an ansible inventory from all the deployments, jobs and
instances managed by a BOSH Director.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@jriguera
jriguera / bosh_release.md
Last active March 8, 2016 12:29
Creating bosh releases

Start here: http://mariash.github.io/learn-bosh/, then goto: http://bosh.io/docs/create-release.html

  1. Prepare the environment with bosh lite.
  2. Create the workspace for the new release: bosh init release <release_name>
  3. Create the source packages to compile: bosh generate package <package_name>
  4. After defining the compilation steps, add the source packages bosh add blob <package.tgz> <package_name>
  5. Create the job (or jobs) to run: bosh generate job <job_name> and write the monit, spec and startup files
  6. Create a manifest for the new project: http://bosh.io/docs/deployment-manifest.html, using cd templates && make_manifest warden. Option: copy from another simple release like: https://github.com/cloudfoundry-community/carbon-c-relay-boshrelease
  7. bosh status has to be pointing to the deployment manifest created before.
@jriguera
jriguera / interfaces.cfg
Created February 3, 2016 15:02
Debian/Ubuntu interfaces with routing tables
auto bond0.502
# Static interface with an address, will be brought up directly on boot.
iface bond0.502 inet static
address 10.10.11.10
netmask 255.255.248.0
#gateway 10.10.8.1
vlan-raw-device bond0
post-up grep -q " live" /etc/iproute2/rt_tables || echo "202 live" >> /etc/iproute2/rt_tables
post-up ip rule add from 10.10.11.10 table live
post-up ip route add table live default via 10.10.8.1
@jriguera
jriguera / notify_slack_hipchat.sh
Created January 6, 2016 13:59
how to notify slack and hipchat
# Define those variables according to hipchar of slack (in this case is for slack)
ROOM_ID="XXXXX"
ROOM_TOKEN="XXXXXX/XXXXXXX/XXXXXXXXXXXXXXXXXXXX"
notify_hipchat() {
local msg="[$(hostname)] microBOSH/CF $ENVIRONMET $BKPLEVEL backup $BKPSTATUS"
local notify="0"
[ "$STATUS" != "1" ] && notify="1"
curl -H "Content-type: application/json" \
@jriguera
jriguera / iptables_redirect.txt
Created December 17, 2015 12:52
Iptables redirect port
# All incoming trafic (mainly via eth2) will be redirected to 2005 (old graphite relay)
iptables -t nat -A PREROUTING -p tcp --dport 2003 -j REDIRECT --to-port 2005
iptables -t nat -A PREROUTING -p udp --dport 2003 -j REDIRECT --to-port 2005
# Another example using ips
#iptables -t nat -A PREROUTING -i eth2 -p udp -d 10.9.2.197 --dport 2003 -j REDIRECT --to-port 2005
# loopback traffic do not go via PREROUTING chain
iptables -t nat -A OUTPUT -o lo -p tcp --dport 2003 -j REDIRECT --to-port 2005
# just the same but using ips instead of interfaces (for udp)
iptables -t nat -A OUTPUT --src 0/0 --dst 127.0.0.1 -p udp --dport 2003 -j REDIRECT --to-port 2005