examples: lang: Update examples to fix imports and port from yaml
Some small fixes that are useful for demos!
This commit is contained in:
30
examples/lang/autoedges1.mcl
Normal file
30
examples/lang/autoedges1.mcl
Normal 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,
|
||||
}
|
||||
17
examples/lang/autogroup1.mcl
Normal file
17
examples/lang/autogroup1.mcl
Normal 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,
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import "datetime"
|
||||
import "sys"
|
||||
import "example"
|
||||
|
||||
$secplusone = datetime.now() + $ayear
|
||||
|
||||
@@ -10,7 +11,7 @@ $tmplvalues = struct{year => $secplusone, load => $theload, vumeter => $vumeter,
|
||||
|
||||
$theload = structlookup(sys.load(), "x1")
|
||||
|
||||
$vumeter = vumeter("====", 10, 0.9)
|
||||
$vumeter = example.vumeter("====", 10, 0.9)
|
||||
|
||||
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),
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import "sys"
|
||||
|
||||
file "/tmp/mgmt/systemload" {
|
||||
content => template("load average: {{ .load }} threshold: {{ .threshold }}\n", $tmplvalues),
|
||||
}
|
||||
|
||||
$tmplvalues = struct{load => $theload, threshold => $threshold,}
|
||||
|
||||
$theload = structlookup(load(), "x1")
|
||||
$theload = structlookup(sys.load(), "x1")
|
||||
$threshold = 1.5 # change me if you like
|
||||
|
||||
# simple hysteresis implementation
|
||||
|
||||
Reference in New Issue
Block a user