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
@raphink
raphink / crm.rb
Last active December 26, 2015 09:59 — forked from mbornoz/crm.rb
# crm_support: true/nil
# Whether there is Pacemaker installed
Facter.add('crm_support') do
confine :kernel => :linux
setcode do
not Facter::Util::Resolution.exec('which crm_resource').empty?
end
end
export GH_USER="raphink"
## Github helpers
function gh_exists_remote {
local repo="$1"
git remote | grep -q "^${repo}$" \
&& return 0 || return 1
}
1.9.2-p320 :001 > require 'puppet/file_serving/metadata'
=> true
1.9.2-p320 :002 > metadata = Puppet::FileServing::Metadata.new('/etc/passwd', :path => '/etc/passwd')
=> #<Puppet::FileServing::Metadata:0x00000003ec5538 @owner=nil, @group=nil, @mode=nil, @checksum_type="md5", @ftype=nil, @destination=nil, @path="/etc/passwd", @links=:manage>
1.9.2-p320 :003 > metadata.collect
=> "{md5}dddc7650ed8195d4c3738c4bbe1beebd"
$ augtool -I lenses/ --transform "Desktop.lns incl /usr/share/app-install/desktop/vagalume:vagalume.desktop" print /files/usr/share/app-install/desktop/vagalume:vagalume.desktop/files/usr/share/app-install/desktop/vagalume:vagalume.desktop
/files/usr/share/app-install/desktop/vagalume:vagalume.desktop/Desktop Entry
/files/usr/share/app-install/desktop/vagalume:vagalume.desktop/Desktop Entry/X-AppInstall-Package = "vagalume"
/files/usr/share/app-install/desktop/vagalume:vagalume.desktop/Desktop Entry/X-AppInstall-Popcon = "41"
/files/usr/share/app-install/desktop/vagalume:vagalume.desktop/Desktop Entry/X-AppInstall-Section = "universe"
/files/usr/share/app-install/desktop/vagalume:vagalume.desktop/Desktop Entry/Version = "1.0"
/files/usr/share/app-install/desktop/vagalume:vagalume.desktop/Desktop Entry/Type = "Application"
/files/usr/share/app-install/desktop/vagalume:vagalume.desktop/Desktop Entry/Categories = "Audio;AudioVideo;GNOME;GTK;Application;Player;"
/files/usr/share/app-install/desktop/vagalume:vagal
require 'mcollective'
include MCollective::RPC
c = rpcclient("rpcutil")
c.discovery_method="mc"
all_nodes = c.discover.clone
all_nodes.in_groups_of(5) do |nodes|
#!/usr/bin/env ruby
require 'mcollective'
include MCollective::RPC
mc = rpcclient('fsfreeze')
mc.discovery_method = 'mc'
all_nodes = mc.discover.clone
@raphink
raphink / download.sh
Created December 10, 2013 22:49
Download tarballs from the Puppet Forge to put in a local forge for https://github.com/dalen/simple-puppet-forge
#!/bin/bash
URL=$1
# ugly parsing
IFS='/' read prot empty serv user mod tarball <<<"$URL"
mkdir -p "$user/$mod"
wget "$URL" -O "$user/$mod/$user-$mod-$tarball"
Augeas.open do |aug|
aug.match('/files/etc/default//#comment').each_with_index do |p, i|
aug.set("/comments/raw/#{i}", "#{aug.get(p)}\n")
aug.text_store('Shellvars.lns', "/comments/raw/#{i}", "/comments/tree/#{i}")
end
end
<augeas match="/files/etc/fstab">
<node label="fstab" file="/etc/fstab" span_label_start="0" span_label_end="0" span_value_start="0" span_value_end="0" span_span_start="0" span_span_end="692" path="/files/etc/fstab">
<node label="#comment" file="/etc/fstab" span_label_start="0" span_label_end="0" span_value_start="2" span_value_end="45" span_span_start="0" span_span_end="46">
<value>/etc/fstab: static file system information.</value>
</node>
<node label="#comment" file="/etc/fstab" span_label_start="0" span_label_end="0" span_value_start="50" span_value_end="121" span_span_start="48" span_span_end="122">
<value>Use 'blkid -o value -s UUID' to print the universally unique identifier</value>
</node>
<node label="#comment" file="/etc/fstab" span_label_start="0" span_label_end="0" span_value_start="124" span_value_end="194" span_span_start="122" span_span_end="195">
<value>for a device; this may be used with UUID= as a more robust way to name</value>
define sudo::defaults::env_keep {
augeas { "set env_keep defaults for ${name}":
context => '/files/etc/sudoers',
changes => [
"defnode s Defaults[env_keep/var='${name}']/env_keep[var='${name}']/append 'blah'",
'clear $s',
"set \$s/../var[.='${name}'] '${name}'",
],
}
}