Skip to content

Instantly share code, notes, and snippets.

View jpadams's full-sized avatar

Jeremy Adams jpadams

View GitHub Profile
@jpadams
jpadams / windowsrun.rb
Last active December 28, 2015 04:19
Getting closer with windows commmand run
module MCollective
module Agent
class Windowsrun<RPC::Agent
action "run" do
command = "dir"
reply[:status] = run(command, :stdout => :out, :stderr => :err, :chomp => true)
end
def run(command, options)
if MCollective::Util.windows?
@jpadams
jpadams / init.pp
Last active December 28, 2015 08:08
# These two work fine with puppet apply non-root
#class foo ($message=hiera(message)) {
#class foo ($message='default') {
# Hiera Data bindings doesn't work with puppet apply root or non-root
class foo ($message) {
#class foo {
#$message = hiera(message)
#notify { "A message from foo via hiera databindings or class param default: $message": }
class acts {
runyer::posix_command { 'ls':
command => 'ls -al',
}
runyer::posix_command { 'du':
command => 'du -k',
}
module Puppet::Parser::Functions
newfunction(:tr_filename, :type => :rvalue) do |args|
name = args[0]
name.downcase.tr(" ", "_")
end
end
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to parse template runyer/posix_rb.erb:
Filepath: /modules/runyer/templates/posix_rb.erb
Line: 3
Detail: undefined method `capitalize' for nil:NilClass
at /modules/runyer/manifests/posix_command.pp:10 on node master
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
dynamic scoping biting me when I moved from class param $action_name = $title to putting it in body of class.
@action_name in template was no longer in scope.
import os
import random
import treelib
from treelib import Node, Tree
SPACER = '_'
def init_board():
board = [[SPACER for x in xrange(3)] for x in xrange(3)]
return board
node nonrootuser {
file { 'C:\Users\nonrootuser\Desktop\nonroot_Puppet_Agent_run_30m.xml':
ensure => file,
}
exec { 'myscript':
command => 'C:\Windows\System32\schtasks.exe /Create /XML C:\Users\nonrootuser\Desktop\nonroot_Puppet_Agent_run_30m.xml /RU WINDOWS\nonrootuser /RP Pupp3t! /tn nonroot_puppet_agent_run',
unless => 'C:\Windows\System32\schtasks.exe /Query /TN nonroot_puppet_agent_run',
class nonpriv_setup {
define nonpriv_pe_user (
$password,
$nonpriv_user=$name,
$ensure='present', # 'present' or 'absent'
$certname=$nonpriv_user,
$server='puppet', # puppet master
$enable_sched_task=true, # true or false
$run_interval_mins='30', # in minutes, one of 5, 10, 15, 30, 60
# /opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/reports/http.rb
# http://devsops.blogspot.com/2013/04/3.html
def process
raw_urls = Puppet[:reporturl]
url_array = raw_urls.gsub!(/\s+/, "").split(',')
url_array.each do |url|
#url = URI.parse(Puppet[:reporturl])
body = self.to_yaml
headers = { "Content-Type" => "application/x-yaml" }
git push origin --delete dev
git branch -d dev
git branch -D dev