This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
find_parent() { | |
f="$(readlink -f "$1")" | |
parent="$(dirname $f)" | |
if [ "$f" != "$parent" ]; then | |
ls -ld "$parent" | |
find_parent "$parent" | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myorg::pdb::class_node_inventory ( | |
Pattern['\A[A-Za-z][A-Za-z0-9]*(::[A-Za-z][A-Za-z0-9]*)*\Z'] $classname, | |
Optional[String[1]] $env = undef, | |
) { | |
$query_template = @(EOT) | |
<%- | String $classname, | |
Optional[String] $env, | |
| -%> | |
inventory { | |
<%- if $env { -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function create_resources_with_metaparameters ( | |
Variant[String, Type[Resource]] $type, | |
Hash[String, Hash[String, Any]] $resources, | |
Optional[Hash[String, Any]] $defaults = undef, | |
) { | |
$resources.each |$resource, $attributes| { | |
Resource[$type] { | |
$resource: * => $attributes.prepare_attributes(); | |
default: * => $defaults.prepare_attributes(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class foobar ( | |
Hash[String, | |
Struct[{ | |
attributes => Hash[String, Data], | |
Optional[requires] => Hash[String, String], | |
Optional[notifies] => Hash[String, String] | |
}]] $files, | |
Hash[String, Data] $file_defaults = {}, | |
) { | |
$files.each |$key, $value| { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file { '/tmp/before_test': | |
ensure => present, | |
before => Exec['/bin/rm /tmp/before_test'], | |
} | |
exec { '/bin/rm /tmp/before_test': | |
refreshonly => true, | |
} | |
file { '/tmp/notify_test': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class alfa { | |
notice("Evaluating Class['alfa']") | |
notify { 'class alfa': } | |
include helium | |
include hydrogen | |
Class['hydrogen'] -> Class['helium'] | |
} | |
class bravo { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo = [1, 3, 5, 2, 3] | |
bar = [1, 3, 5, 2, 4, 8] | |
def generate_checks(num_list): | |
checks = [] | |
if len(num_list) == 0: | |
return checks | |
for i in range(len(num_list[1:])): | |
checks.append(lambda: num_list[0] == num_list[i+1]) | |
return checks + generate_checks(num_list[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pql { | |
tmpfile=$(mktemp) | |
status_code=$(curl --silent --output /dev/stderr --write-out "%{http_code}" -XGET localhost:8080/pdb/query/v4 -d "query=$1" 2>$tmpfile) | |
if [ "$status_code" = "200" ]; then | |
jq $3 "$2" $tmpfile | |
else | |
cat $tmpfile | |
fi | |
rm $tmpfile | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$var = if $facts['os']['family'] == 'Debian' and $facts['os']['release']['major'] == '8' { | |
'foo' | |
} else { | |
'bar' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
require 'json' | |
fixture_dir = File.expand_path(File.join(__FILE__, '..', '..', 'fixtures', 'data')) | |
describe 'jmxtrans::query' do | |
def check_json_string(expected) | |
return Proc.new do |actual| | |
begin | |
expected_obj = JSON.parse(expected) |
NewerOlder