Skip to content

Instantly share code, notes, and snippets.

View rafaelfelix's full-sized avatar

Rafael Felix Correa rafaelfelix

View GitHub Profile
@rafaelfelix
rafaelfelix / pear.rb
Created December 27, 2011 19:23 — forked from jakemcgraw/pear.rb
Puppet PHP Pear provider
# Puppet PHP PEAR Package support
# Taken from https://raw.github.com/gist/1524864/fdd8fd047aa702587c0b7cce7a77d55dbd781f01/pear.rb
require 'puppet/provider/package'
# PHP PEAR support.
Puppet::Type.type(:package).provide :pear, :parent => Puppet::Provider::Package do
desc "PHP PEAR support. By default uses the installed channels, but you
can specify the path to a pear package via ``source``."
@rafaelfelix
rafaelfelix / verifyAkamaiIp.sh
Last active July 26, 2018 15:59
Shell script to programmatically check if an IP address belongs to Akamai. Requires Akamai login, password and permission to access https://control.akamai.com/partner-tools/index.action?target=VerifyAkamaiIP
#!/bin/bash
#
# Issue request to Akamai tool verifyAkamaiIpInternal to check if
# the given IP address belongs to Akamai
#
## defining helper functions first
# show usage
@rafaelfelix
rafaelfelix / ec2tags.rb
Last active January 17, 2020 08:55 — forked from drohr/ec2tags.rb
Hack to get ec2 tags to facter. Depends on aws-cli (https://github.com/aws/aws-cli), jq (http://stedolan.github.io/jq/) and the JSON RubyGem (http://rubygems.org/gems/json)
require 'facter'
require 'json'
if Facter.value("ec2_instance_id") != nil
instance_id = Facter.value("ec2_instance_id")
region = Facter.value("ec2_placement_availability_zone")[0..-2]
tags = Facter::Util::Resolution.exec("aws ec2 describe-tags --filters \"name=resource-id,values=#{instance_id}\" --region #{region} | jq '[.Tags[] | {key: .Key, value: .Value}]'")
parsed_tags = JSON.parse(tags)
parsed_tags.each do |tag|
@rafaelfelix
rafaelfelix / lame.spec
Last active August 29, 2015 13:57
The simplest RPM spec I know. Unpacks a tar.gz and moves its files to /opt/lame (originally created for the sake of brevity in developing and testing Koji plugins).
Name: lame
Version: 1.0.0
Release: 1%{?dist}
Summary: Lame summary
License: GPLv2+
URL: http://rf4solucoes.com.br/
Source0: http://rf4solucoes.com.br/files/%{name}-%{version}.tar.gz
%description
#!/usr/bin/python
# Script that calls the channels.software.syncRepo Spacewalk API method
#
# Author: Rafael Felix Correa <rafael.felix@gmail.com>
#
# This script is based on https://raw.githubusercontent.com/angrox/spacewalk-api-scripts/master/spacewalk-rhn-sync/spacewalk-rhn-sync.py
# Special thanks to Martin Zehetmayer <angrox@idle.at>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
[Spacewalk]
spw_server = spw_server.domain.com
spw_user = spw_user
spw_pass = spw_pass
channel_label = test_channel
#!/bin/sh
# This script will monitor another NAT instance and take over its routes
# if communication with the other instance fails
# NAT instance variables
# Other instance's IP to ping and route to grab if other node goes down
NAT_ID=
NAT_RT_ID=
# My route to grab when I come back up
@rafaelfelix
rafaelfelix / nat_monitor_existing_vpc.template
Last active October 22, 2015 22:43
Deploy 2 NAT instances using the nat_monitor.sh created by Steve Morad (AWS) inside an existing VPC. Based on the original version nat_monitor_demo.template - http://stevemorad.s3.amazonaws.com/reInvent/demos/nat_template.htm
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Deploy 2 NAT instances using the nat_monitor.sh created by Steve Morad (AWS) inside an existing VPC. Based on the original version nat_monitor_demo.template - http://stevemorad.s3.amazonaws.com/reInvent/demos/nat_template.htm",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type" : "AWS::EC2::KeyPair::KeyName"
@rafaelfelix
rafaelfelix / sync_cloudflare_ips_with_aws_security_group.sh
Last active November 17, 2017 18:54
Syncs Cloudflare IPv4 ranges (https://www.cloudflare.com/ips-v4) with an AWS Security Group. Requires awscli (https://aws.amazon.com/cli/) and jq (https://stedolan.github.io/jq/)
#!/bin/bash
#
# Adds Cloudflare IPV4 addresses to the Inbound rules of a AWS Security Group
#
## defining helper functions first
# show usage
show_usage() {
@rafaelfelix
rafaelfelix / cloudflare_api_client_v4.rb
Created November 19, 2015 21:12
Cloudflare API v4 client class in Ruby (NOT YET FINISHED)
class CloudflareClient
CLOUDFLARE_API_ENDPOINT = "https://api.cloudflare.com/client/v4"
def initialize(email, api_key)
require "rest-client"
require "json"
raise ArgumentError, "Parameters email and api_key are mandatory" if email.to_s.empty? or api_key.to_s.empty?
@auth_headers = {"X-Auth-Email" => email, "X-Auth-Key" => api_key, "Content-Type" => "application/json"}
end