Skip to content

Instantly share code, notes, and snippets.

View raphink's full-sized avatar
🐝
eBPF everything!

Raphaël Pinson raphink

🐝
eBPF everything!
View GitHub Profile
--- !ruby/object:Puppet::Transaction::Report
status: failed
environment: staging3
transaction_uuid: "1334b82a-bbd5-4562-914d-c07cd96139db"
puppet_version: "3.6.2"
logs:
- !ruby/object:Puppet::Util::Log
source: Puppet
tags:
- err
class String
old_format = instance_method(:%)
define_method(:%) do |arg|
return self unless self =~ /%/
if arg.is_a?(Hash)
(self.gsub(/%\{([^%]*?)\}/) {
a = $1
if a =~ /([^\[]+)\[([^\]]*)\](.*)/
h = arg[$1.to_sym][$2.to_sym]
values = {}
format.scan(/%{([^}]+)}/).flatten.map { |e| values[e.to_sym] = eval(e) }
format % values
# Default firewall rules
firewall { '000 accept all icmp':
proto => 'icmp',
action => 'accept',
}
firewall { '001 accept all to lo interface':
proto => 'all',
iniface => 'lo',
action => 'accept',
}
@raphink
raphink / unresponsive.rb
Last active August 29, 2015 14:04
List unresponsive hosts in MCollective using the PuppetDB discovery plugin (https://github.com/ploubser/mcollective-puppetdb-discovery)
#!/usr/bin/ruby
require 'mcollective'
include ::MCollective::RPC
mc = rpcclient('rpcutil')
mc.discovery_method = 'puppetdb'
mc.progress = false
mc.ping
augeas { 'disable-nagios-result-limit':
changes => 'set /files/etc/nagios3/cgi.cfg/result_limit 0',
}
inventory do
format "%s\t|\t%s\t|\t%s\t|\t%s\t|\t%s\t|\t%s"
fields {
[ identity, facts["puppetversion"], facts["facterversion"], facts["augeasversion"], facts["rubyversion"], facts["lsbdistcodename"] ]
}
end
@raphink
raphink / examples.agt
Last active August 29, 2015 14:04
Augeas for aurynn
# Setting up !requiretty
augtool> touch /files/etc/sudoers/Defaults[last()]/requiretty/negate
# For a user alias, the best is to use a variable with defnode
augtool> defnode alias /files/etc/sudoers/User_Alias/alias/name "EXAMPLE_ADMINS"
augtool> set $alias/../user "cslack"
@raphink
raphink / index.html
Last active August 29, 2015 14:04
Venir depuis la gare SNCF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Venir depuis la gare</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="content-script-type" content="text/javascript" />
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-language" content="en" />
<meta name="generator" content="Easymap" />
<link rel="stylesheet" type="text/css" href="map.css" />
#!/usr/bin/ruby
require 'puppetdb'
require 'puppet'
require 'json'
Puppet.initialize_settings
key = Puppet.settings['hostprivkey']
cert = Puppet.settings['hostcert']
ca_file = Puppet.settings['localcacert']