summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-04-13 15:23:57 +0000
committerLuke Kanies <luke@madstop.com>2005-04-13 15:23:57 +0000
commit5416017c05e44fc635ad14ffdf1ac1163a4cc6e5 (patch)
tree29a33a7dd1389abde8d92219a17beead01ba1f47 /examples
parent54e9b5e3561977ea063417da12c46aad2a4c1332 (diff)
downloadpuppet-5416017c05e44fc635ad14ffdf1ac1163a4cc6e5.tar.gz
puppet-5416017c05e44fc635ad14ffdf1ac1163a4cc6e5.tar.xz
puppet-5416017c05e44fc635ad14ffdf1ac1163a4cc6e5.zip
reorganizing
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@95 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'examples')
-rw-r--r--examples/assignments1
-rw-r--r--examples/code.bl1
-rw-r--r--examples/code/file.bl7
-rw-r--r--examples/cron2.bl57
-rw-r--r--examples/events.bl36
-rw-r--r--examples/facts47
-rw-r--r--examples/objects25
-rw-r--r--examples/one.bl30
-rwxr-xr-xexamples/root/bin/sleeper97
-rw-r--r--examples/root/etc/configfile0
-rwxr-xr-xexamples/root/etc/init.d/sleeper25
-rw-r--r--examples/service.bl52
12 files changed, 378 insertions, 0 deletions
diff --git a/examples/assignments b/examples/assignments
new file mode 100644
index 000000000..d21895392
--- /dev/null
+++ b/examples/assignments
@@ -0,0 +1 @@
+name = "value"
diff --git a/examples/code.bl b/examples/code.bl
new file mode 100644
index 000000000..782991582
--- /dev/null
+++ b/examples/code.bl
@@ -0,0 +1 @@
+$var = "funtest";
diff --git a/examples/code/file.bl b/examples/code/file.bl
new file mode 100644
index 000000000..220a727b9
--- /dev/null
+++ b/examples/code/file.bl
@@ -0,0 +1,7 @@
+# $Id$
+
+file["/etc/sudoers"] {
+ :owner => "root"
+ :group => "root"
+ :mode => "0440"
+}
diff --git a/examples/cron2.bl b/examples/cron2.bl
new file mode 100644
index 000000000..61d48b4dc
--- /dev/null
+++ b/examples/cron2.bl
@@ -0,0 +1,57 @@
+# $Id: cron2.bl,v 1.1 2003/06/19 06:29:53 luke Exp $
+
+# some data definitions
+
+# this kind of sucks because i have two very different syntaxes:
+# one for inside the object, and one for outside
+# that doesn't really seem to make sense.....
+
+# is there a way around it? can i scope all variables automatically
+# inside the objects?
+
+# there's a difference between a collector that joins members of an object
+# and a collector that joins multiple objects together, right?
+cron("cfengine") = {
+ comment => "This is cfengine";
+ command => "/usr/local/sbin/cfexecd -F";
+ minute => ( 0,30 );
+ user => user("root") || "root"; # this sucks
+};
+
+# this is less pure, but it's less muddy at the same time, somehow
+# hmmm
+cron("cfengine") = {
+ $comment = "This is cfengine";
+ $command = "/usr/local/sbin/cfexecd -F";
+ $minute = ( 0,30 );
+ $user = user("root") || "root"; # this sucks; is it a code reference?
+ # a string? i have no idea
+};
+
+# are these hash members? am i assigning a hash, or filling in the members
+# on an object?
+chunk("cronjob") = {
+ separator => "\n";
+ requires => cron;
+ members => (comment || name, command);
+};
+
+# this ends up abstracting the members
+# how do i get to the username now?
+# a chunk is formatting for an individual object; there doesn't need to
+# be an abstraction
+chunk("cronline") = {
+ separator => " ";
+ requires => chunk("cronjob");
+ members => (minute || "*", hour || "*", mday || "*", month || "*", wday || "*",
+ command);
+};
+
+pile("crontab") = {
+ separator => "\n";
+ members => chunk("cronline")->user(user);
+};
+
+# and then some actual logic, and stuff
+
+
diff --git a/examples/events.bl b/examples/events.bl
new file mode 100644
index 000000000..475d66fab
--- /dev/null
+++ b/examples/events.bl
@@ -0,0 +1,36 @@
+load(trigger);
+
+trigger {
+ onchange => {
+ /etc/inetd.conf => process(restart => inetd),
+ /etc/syslog.conf => process(restart => syslogd),
+ /etc/syslog-ng.conf => process(restart => syslog-ng),
+ },
+};
+
+load(process);
+
+process::inetd.binary("/usr/sbin/inetd");
+process::inetd.pattern("inetd");
+process::inetd.arguments("-s -t");
+process::inetd.config("/etc/inet/inetd.conf");
+
+# crap, does this get interpreted at run time, set time, or execution time?
+# ugh
+# and how the hell do I pass that back in to the process?
+# basically, the arguments need to be parsed, and then passed to the
+# method, but it's the method that knows it's dealing with its own object
+process::inetd.start($_.binary, " ", $_.arguments);
+process::inetd.restart("/usr/bin/pkill -HUP ", $_.pattern);
+
+# this is a system-level notification, isn't it? notifies that
+# process is now subscribed to this event
+# we could have both parts do something; the system is responsible
+# for registering the subscription, and the process module is responsible
+# for actually dealing with it
+
+# what i'm trying to say here is "reload inetd if this file changes"
+process::inetd.event(filechange($_.config) => $_.restart);
+process::inetd.subscribe(filechange.{$_.config} => {$_.restart});
+
+*sycamore:: { process(inetd)++ }
diff --git a/examples/facts b/examples/facts
new file mode 100644
index 000000000..de8d83e6e
--- /dev/null
+++ b/examples/facts
@@ -0,0 +1,47 @@
+platform? {
+ :sunos => { thing("name"){ :param => "value" } }
+}
+
+thing("name") {
+ :param => platform{
+ :sunos => "sunosvalue"
+ :aix => "aixvalue"
+ :default => "defaultvalue"
+ }
+}
+
+thing("name") {
+ :param => test ? true : false
+ :param => platform? <
+ :sunos => "sunosvalue"
+ :aix => "aixvalue"
+ hostname?(:myhost) => "hostvalue"
+ >
+ true : false
+}
+
+string = case platform
+ when :sunos then "sunosvalue"
+ when :aix then "aixvalue"
+ when :aix then "aixvalue"
+end
+
+string = platform ? {
+ :sunos => :value1
+ :aix => :value2
+ :hpux => :value3
+}
+
+if platform == :sunos then "sunosvalue"
+string = Fact["platform"] ? {
+ :sunos => "sunosvalue"
+}
+
+platform = retrieve("platform")
+
+ -----------------------
+ / :sunos => :sunosvalue \
+string = platform? < :aix => :aixvalue >
+ \ :hpux => :hpuxvalue /
+ -----------------------
+
diff --git a/examples/objects b/examples/objects
new file mode 100644
index 000000000..4c4e6cf8b
--- /dev/null
+++ b/examples/objects
@@ -0,0 +1,25 @@
+type = filetype["colon-separated"] {
+ :recordseparator => "\n"
+ :fieldseparator => "\n"
+ :fields = %{name password uid gid ....}
+ :namefield = "name"
+}
+
+passwd = filetype["colon-separated"].new("/etc/passwd")
+shadow = filetype["colon-separated"].new("/etc/shadow")
+
+user = jointype {
+ passwd => "name"
+ shadow => "name"
+}
+
+passwd = type["/etc/passwd"]
+
+
+user.new()
+
+
+passwd["yaytest"] = {
+ :uid => 100
+ ...
+}
diff --git a/examples/one.bl b/examples/one.bl
new file mode 100644
index 000000000..428372dd9
--- /dev/null
+++ b/examples/one.bl
@@ -0,0 +1,30 @@
+#!/home/luke/cvs/blink/bin/blink
+
+# okay, we'll have a constraint system later, and it will look something like
+# the following:
+
+# Constraint.isbinary = sub { |path| -x path }
+# binary.constrain(isbinary)
+# protocol.constrain { |string|
+# string == "udp" || string == "tcp"
+# }
+
+class Base {
+ strings = format
+
+}
+
+class Inetd {
+ strings = wait, endpoint, command, binary, protocol, uid, name
+
+}
+
+Inetd::telnet = {
+ wait => "nowait",
+ endpoint => "stream",
+ command => "in.telnetd",
+ binary => "/usr/sbin/in.telnetd",
+ protocol => "tcp6",
+ uid => "root",
+ name => "telnet",
+}
diff --git a/examples/root/bin/sleeper b/examples/root/bin/sleeper
new file mode 100755
index 000000000..6c1495928
--- /dev/null
+++ b/examples/root/bin/sleeper
@@ -0,0 +1,97 @@
+#!/usr/bin/perl -w
+
+###
+# sleep indefinitely as a debug
+
+use strict;
+use Getopt::Long;
+use Pod::Usage;
+
+#-----------------------------------------------------------------
+sub daemonize
+{
+ use POSIX 'setsid';
+ $| = 1;
+ chdir '/' or die "Can't chdir to /: $!\n";
+ open STDIN, "/dev/null" or die "Can't read /dev/null: $!\n";
+ open STDOUT, "> /dev/null" or die "Can't write to /dev/null: $!\n";
+ defined(my $pid = fork()) or die "Can't fork: $!\n";
+ #print STDERR $pid, "\n";
+ exit if $pid;
+ setsid or die "Can't start a new session: $!\n";
+ open STDERR, ">&STDOUT" or die "Can't dup stdout: $!\n";
+}
+#-----------------------------------------------------------------
+
+my ($help,$opt_result,$debug,$fun);
+
+$opt_result = GetOptions
+(
+ "help" => \$help,
+ "debug" => \$debug,
+ "fun" => \$fun,
+);
+
+if (! $opt_result)
+{
+ pod2usage('-exitval' => 1, '-verbose' => 0);
+ exit(1);
+}
+
+if ($help)
+{
+ pod2usage('-exitval' => 1, '-verbose' => 2);
+ exit;
+}
+
+unless ($debug) {
+ daemonize();
+}
+
+while(1){
+ sleep 600;
+}
+
+=head1 NAME
+
+template - this is a template script and should be copied and modded
+
+=head1 SYNOPSIS
+
+template [-help]
+
+=head1 DESCRIPTION
+
+B<template> is a stub script.
+
+=head1 OPTIONS
+
+=over 4
+
+=item help
+
+Prints out help page.
+
+=back
+
+B<Example>
+
+template
+
+=head1 BUGS
+
+This script shouldn't be modified, or has apparently not been documented.
+
+=head1 SEE ALSO
+
+L<Cat>
+
+=head1 AUTHOR
+
+Luke A. Kanies, luke.kanies@cat.com
+
+=for html <hr>
+
+I<$Id$>
+
+=cut
diff --git a/examples/root/etc/configfile b/examples/root/etc/configfile
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/examples/root/etc/configfile
diff --git a/examples/root/etc/init.d/sleeper b/examples/root/etc/init.d/sleeper
new file mode 100755
index 000000000..7a6614087
--- /dev/null
+++ b/examples/root/etc/init.d/sleeper
@@ -0,0 +1,25 @@
+#! /bin/sh
+
+PATH=$PATH:/home/luke/svn/blink/examples/root/bin
+
+case "$1" in
+ start)
+ sleeper
+ ;;
+ stop)
+ kill `ps -ef | grep -v grep | grep sleeper | grep perl | awk '{print $2}'`
+ ;;
+ status)
+ if sh -c "ps -ef | grep -v grep | grep -v init.d | grep sleeper"; then
+ exit 0
+ else
+ exit 1
+ fi
+ ;;
+ *)
+ echo "Usage: $N {start|stop|restart|force-reload}" >&2
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/examples/service.bl b/examples/service.bl
new file mode 100644
index 000000000..0426ff6ec
--- /dev/null
+++ b/examples/service.bl
@@ -0,0 +1,52 @@
+service("ftp") = {
+ port => "21";
+ protocol => "tcp";
+ name => "ftp";
+ comment => "this protocol sucks";
+};
+
+service("telnet") = {
+ port => "23";
+ protocol => "tcp";
+ name => "telnet";
+};
+
+inetsvc("telnet") = {
+ port => "telnet";
+ protocol => "tcp";
+ binary => "/usr/sbin/in.telnetd";
+ command => "in.telnetd"
+};
+
+inetsvc("ftp") = {
+ port => "ftp";
+ protocol => "tcp";
+ binary => "/usr/sbin/in.ftpd";
+ command => "in.ftpdd"
+};
+
+chunk("inetdline") = {
+ separator => " ";
+ members => (port, protocol, binary, command);
+};
+
+chunk("inetdset") = {
+ separator => "\n";
+ members => (comment || name);
+};
+
+# yep, this sucks...
+chunk("service") = {
+ separator => "\n";
+ members => (name, protocol . "/" . name, " " * alias || "", "# " . comment || "");
+};
+
+pile("inetd") = {
+ separator => "\n";
+ members => chunk("inetdset");
+};
+
+pile("services") = {
+ separator => "\n";
+ members => chunk("service");
+};