examples: lang: Update examples to fix imports and port from yaml

Some small fixes that are useful for demos!
This commit is contained in:
James Shubin
2019-02-01 03:47:18 -05:00
parent 5d0efce278
commit 78936c5ce8
4 changed files with 52 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
pkg "drbd-utils" {
state => "installed",
Meta:autoedge => true,
Meta:noop => true,
}
file "/etc/drbd.conf" {
content => "this is an mgmt test",
state => "exists",
Meta:autoedge => true,
Meta:noop => true,
}
file "/etc/drbd.d/" {
source => "/dev/null",
state => "exists",
Meta:autoedge => true,
Meta:noop => true,
}
# note that the autoedges between the files and the svc don't exist yet :(
svc "drbd" {
state => "stopped",
Meta:autoedge => true,
Meta:noop => true,
}

View File

@@ -0,0 +1,17 @@
pkg "powertop" {
state => "installed",
Meta:autogroup => true,
}
pkg "sl" {
state => "installed",
Meta:autogroup => true,
}
pkg "cowsay" {
state => "installed",
Meta:autogroup => true,
}

View File

@@ -1,5 +1,6 @@
import "datetime" import "datetime"
import "sys" import "sys"
import "example"
$secplusone = datetime.now() + $ayear $secplusone = datetime.now() + $ayear
@@ -10,7 +11,7 @@ $tmplvalues = struct{year => $secplusone, load => $theload, vumeter => $vumeter,
$theload = structlookup(sys.load(), "x1") $theload = structlookup(sys.load(), "x1")
$vumeter = vumeter("====", 10, 0.9) $vumeter = example.vumeter("====", 10, 0.9)
file "/tmp/mgmt/datetime" { file "/tmp/mgmt/datetime" {
content => template("Now + 1 year is: {{ .year }} seconds, aka: {{ datetime_print .year }}\n\nload average: {{ .load }}\n\nvu: {{ .vumeter }}\n", $tmplvalues), content => template("Now + 1 year is: {{ .year }} seconds, aka: {{ datetime_print .year }}\n\nload average: {{ .load }}\n\nvu: {{ .vumeter }}\n", $tmplvalues),

View File

@@ -1,10 +1,12 @@
import "sys"
file "/tmp/mgmt/systemload" { file "/tmp/mgmt/systemload" {
content => template("load average: {{ .load }} threshold: {{ .threshold }}\n", $tmplvalues), content => template("load average: {{ .load }} threshold: {{ .threshold }}\n", $tmplvalues),
} }
$tmplvalues = struct{load => $theload, threshold => $threshold,} $tmplvalues = struct{load => $theload, threshold => $threshold,}
$theload = structlookup(load(), "x1") $theload = structlookup(sys.load(), "x1")
$threshold = 1.5 # change me if you like $threshold = 1.5 # change me if you like
# simple hysteresis implementation # simple hysteresis implementation