mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Support of the .pp extension for Pascal
This commit is contained in:
26
samples/Puppet/expiringhost.pp
Normal file
26
samples/Puppet/expiringhost.pp
Normal file
@@ -0,0 +1,26 @@
|
||||
define example::expiringhost($ip, $timestamp) {
|
||||
|
||||
# Calculate the age of this resource by comparing 'now' against $timestamp
|
||||
$age = inline_template("<%= require 'time'; Time.now - Time.parse(timestamp) %>")
|
||||
|
||||
# Max age, in seconds.
|
||||
$maxage = 60
|
||||
|
||||
if $age > $maxage {
|
||||
$expired = true
|
||||
notice("Expiring resource $class[$name] due to age > $maxage (actual: $age)")
|
||||
} else {
|
||||
$expired = false
|
||||
notice("Found recently-active $class[$name] (age: $age)")
|
||||
}
|
||||
|
||||
# I set target to a /tmp path so you can run this example as non-root.
|
||||
# In production, you probabyl won't set target as it defaults to /etc/hosts
|
||||
# (or wherever puppet thinks your platform wants it)
|
||||
host {
|
||||
$name:
|
||||
ip => $ip,
|
||||
target => "/tmp/expiring-hosts-example-output",
|
||||
ensure => $expired ? { true => absent, false => present };
|
||||
}
|
||||
}
|
||||
26
samples/Puppet/stages-example.pp
Normal file
26
samples/Puppet/stages-example.pp
Normal file
@@ -0,0 +1,26 @@
|
||||
class foo {
|
||||
notify {
|
||||
"foo": ;
|
||||
}
|
||||
}
|
||||
|
||||
class bar {
|
||||
notify {
|
||||
"bar": ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
node default {
|
||||
stage {
|
||||
"one": ;
|
||||
"two": ;
|
||||
}
|
||||
|
||||
class {
|
||||
"foo": stage => "one";
|
||||
"bar": stage => "two";
|
||||
}
|
||||
|
||||
Stage["one"] -> Stage["two"]
|
||||
}
|
||||
22
samples/Puppet/unmanaged-notify-puppet25.pp
Normal file
22
samples/Puppet/unmanaged-notify-puppet25.pp
Normal file
@@ -0,0 +1,22 @@
|
||||
# Manually manage /tmp/original
|
||||
# Each puppet run will copy it to /tmp/flag if there's a change and notify
|
||||
# the exec when it changes.
|
||||
#
|
||||
# The idea here is you might need (in some case) to manually manage a file outside
|
||||
# of puppet (in this case, "/tmp/original"). Using this example, you can make puppet
|
||||
# signal other parts of your catalog based on changes to that file.
|
||||
|
||||
file {
|
||||
# This will, when different, copy /tmp/original to /tmp/flag and notify our
|
||||
# exec.
|
||||
"/tmp/flag":
|
||||
source => "file:///tmp/original",
|
||||
notify => Exec["hello world"];
|
||||
}
|
||||
|
||||
exec {
|
||||
"hello world":
|
||||
command => "/bin/echo hello world",
|
||||
refreshonly => true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user