Skip to content

Instantly share code, notes, and snippets.

@nanliu
nanliu / AutoAlign.vim
Created February 23, 2011 11:59
Puppet AutoAlign
" AutoAlign: ftplugin support for Puppet
" Author: Nan Liu
" Date: Feb 23, 2011
" Version: 1
" ---------------------------------------------------------------------
let b:loaded_autoalign_puppet = "v1"
" overloading '=>' to keep things lined up {{{1
ino <silent> => =><c-r>=AutoAlign(1)<cr>
let b:autoalign_reqdpat1 = '=>'
@nanliu
nanliu / gist:1353458
Created November 9, 2011 23:01
Puppet Manifest Cleanup
#!/usr/bin/ruby
require 'parser-emit'
class Puppet::Parser::AST::Definition
attr_accessor :name
end
class Manifest
class << self
#include Enumerable
@nanliu
nanliu / future.pp
Created November 15, 2011 22:05
Puppet future
class a {
$var = ''
}
class c {
include a
notice ($a::var)
}
class b {
@nanliu
nanliu / gist:2605292
Created May 5, 2012 20:14
file resource purge.
define mytype {
# resource type that I don't want file to purge:
# vhost { $name: ... }
file { "/tmp/www/${name}":
}
}
file { '/tmp/www':
@nanliu
nanliu / gist:2789895
Created May 25, 2012 19:02
Install Puppet Opensource on Ubuntu
apt-key adv --recv-key --keyserver pool.sks-keyservers.net 4BD6EC30
apt-get update
apt-get -y install lsb-release
distro=$(lsb_release -i | cut -f 2 | tr "[:upper:]" "[:lower:]")
release=$(lsb_release -c | cut -f 2)
cat > /etc/apt/sources.list.d/puppetlabs.list <<EOFAPTREPO
deb http://apt.puppetlabs.com/${distro}/ ${release} main
EOFAPTREPO
@nanliu
nanliu / gist:3170626
Created July 24, 2012 15:20
Puppet Installation
#!/bin/bash
# This script is intended to be used with the install action
# of puppet-cloudpack
set -u
set -e
function fedora_repo() {
cat >/etc/yum.repos.d/puppet.repo <<'EOFYUMREPO'
[puppetlabs]
@nanliu
nanliu / gist:3174705
Created July 25, 2012 06:18
Puppet Master F5
f5_key { 'puppet.key':
ensure => 'present',
content => file("${settings::ssldir}/ca/ca_key.pem"),
mode => 'MANAGEMENT_MODE_DEFAULT',
}
f5_profileclientssl { 'puppetmaster':
ensure => present,
certificate_file => 'puppet.crt',
key_file => 'puppet.key',
Puppet::Parser::Functions::newfunction(:module_file, :type => :rvalue, :doc => "
Function module_file:
load file from relative or absolute path, relative path will search puppet modules files directory.
") do |args|
raise Puppet::ParseError, "module_file(): wrong number of arguments #{args.length}, expecting (filename)." if args.length != 1
raise Puppet::ParseError, "module_file(): does not accept empty file path." unless args[0]
file = args[0]
begin
$data = ['1', '2', '3', '4']
define loop (
$data
) {
$var = parsejson(inline_template("<%= (data.collect{|x| name+'/'+x}).to_pson %>"))
hack { $var:
}
}
@nanliu
nanliu / files.pp
Created February 17, 2013 06:37
dot::files
define dot::file {
file { "${my_homedir}/.${name}":
ensure => link,
mode => '0644',
target => "${my_sourcedir}/dotfiles/${name}",
require => Repository["${my_sourcedir}/dotfiles"],
}
}
dot::file {