Skip to content

Instantly share code, notes, and snippets.

View jpadams's full-sized avatar

Jeremy Adams jpadams

View GitHub Profile
@jpadams
jpadams / nonrootweb.pp
Created January 21, 2015 00:51
nonroot setup for 3 named vhosts. make sure to add site1.pdx.puppetlabs.demo etc to your mac's /etc/hosts
node /centos65a/ {
nonpriv::user_created_by_admin { 'web':
server => 'master.inf.puppetlabs.demo',
password => '$1$Bp8B.dWo$DUVekjsAsU0ttWZmS37P5.',
}
class { 'apache': }
apache::vhost { 'site1.pdx.puppetlabs.demo':
// compile this with javac to get MyCustomFact.class
class MyCustomFact {
public static void main(String[] args) {
System.out.println("mycustomfact=foo");
}
}
// then wrap it in a shell script like this
// #! /bin/bash
@jpadams
jpadams / connect_ds.sh
Created January 27, 2015 22:26
directory server setup script example
PUPPET='/opt/puppet/bin/puppet'
curl -X PUT -H 'Content-Type: application/json' \
-d \
'{
"base_dn": "ou=system",
"connect_timeout": 10,
"display_name": "Sample Directory",
"group_lookup_attr": "cn",
"group_member_attr": "uniqueMember",
@jpadams
jpadams / update_classes.sh
Created January 29, 2015 05:16
Simple script to hit update-classes endpoint of PE Node Classifier API
#!/bin/bash
declare -x PE_CERT=$(/opt/puppet/bin/puppet agent --configprint hostcert)
declare -x PE_KEY=$(/opt/puppet/bin/puppet agent --configprint hostprivkey)
declare -x PE_CA=$(/opt/puppet/bin/puppet agent --configprint localcacert)
declare -x NC_CURL_OPT="-s --cacert $PE_CA --cert $PE_CERT --key $PE_KEY --insecure"
curl -X POST -H 'Content-Type: application/json' $NC_CURL_OPT --insecure https://localhost:4433/classifier-api/v1/update-classes
PUPPET='/opt/puppet/bin/puppet'
curl -k -X GET -H 'Content-Type: application/json' \
--cacert `$PUPPET config print localcacert` \
--cert `$PUPPET config print hostcert` \
--key `$PUPPET config print hostprivkey` \
https://localhost:4433/activity-api/v1/events.csv?service_id=classifier
# 1) run this as ./get_classifier_csv.sh > out.csv
# 2) open in excel or similar
wget -r -l 1 http://www.puppetlogs.com/puppet/
cd www.puppetlogs.com/
cd puppet/
grep -i satellite * > results.html
# stuff to do newlines and <p>
cat results.html | sed 's/puppet-.*html/<a href=\"file:\/\/\/Users\/jeremy\/src\/irc_logs\/www.puppetlogs.com\/puppet\/&\">&<\/a>/' > final.html
ls -1 | while read file; do newfile=$(echo $file | sed 's/#//'); mv $file $newfile; done
open final.html
@jpadams
jpadams / vms.yaml
Created March 4, 2015 17:25
Centos 6.6 vagrant box update on https://vagrantcloud.com/puppetlabs
---
vms:
- name: "master.inf.puppetlabs.demo"
box: "puppetlabs/centos-6.6-64-nocm"
roles: [ "master" ]
- name: "centos66a.pdx.puppetlabs.demo"
box: "puppetlabs/centos-6.6-64-nocm"
roles: [ "posix_agent" ]
#! /bin/bash
# node deactivation for an all-in-one (aka monolithic) PE master
# ignores mcollective deactivation
# read certnames from STDIN (one per line) and deactivate
while read certname; do
/opt/puppet/bin/puppet license 2>&1 | head - -n2
/bin/su - peadmin -c "/opt/puppet/bin/mco service stop pe-puppet -I $certname"
/opt/puppet/bin/puppet node deactivate $certname
/opt/puppet/bin/puppet cert revoke $certname
jeremys-mbp-2:windows_essentials jeremy$ rake print
Generating handouts pdf for WindowsEssentials v1.0.5...
prince: static/index.html: error: can't open input file: No such file or directory
prince: static/index.html: error: could not load input file
prince: error: no input documents to process
Generating exercise guide for WindowsEssentials v1.0.5...
prince: static/index.html: error: can't open input file: No such file or directory
prince: static/index.html: error: could not load input file
prince: error: no input documents to process
Generating solutions guide for WindowsEssentials v1.0.5...
@jpadams
jpadams / json_fun.md
Last active August 29, 2015 14:18
API call in browser RBAC/NC

Just found this fun way to do Node Manger REST API GETs in your browser #####if you're logged into the PE console as a user with the right privs.##### Looks pretty with a browser plugin to handle JSON :) I'm using "JSON View".

Jonathan Newman on the dev team cautions: Be aware that these paths will not (necessarily -jeremy) be the same for the next version of PE, so it might be worth that caveat. We reserve the right to remove/change/update any of the web APIs to better fit the webapp. :)