Skip to content

Instantly share code, notes, and snippets.

@neilhwatson
Forked from tzz/gist:ba215a1e49df140eec1d
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilhwatson/d0b62f566ab13eb2afe8 to your computer and use it in GitHub Desktop.
Save neilhwatson/d0b62f566ab13eb2afe8 to your computer and use it in GitHub Desktop.
CFE policy:
body common control
{
bundlesequence => { holder, test_datastate_mustache };
}
bundle common holder
{
classes:
"holderclass" expression => "any"; # will be global
vars:
"s" string => "Hello!";
"d" data => parsejson('[4,5,6]');
"list" slist => { "element1", "element2" };
}
bundle agent test_datastate_mustache
{
files:
"/tmp/myfile.txt"
create => "true",
edit_template => "$(this.promise_filename).mustache",
template_method => "mustache";
}
CFE Mustache template:
{{%vars}}
{{%classes}}
Output:
{
"sys": {
"systime": "1416221536",
"flavour": "ubuntu_14",
"hardware_addresses": [
"ff:ff:4e:8c:ff:f1",
"ff:ff:27:00:ff:00"
],
"fqhost": "flea",
"uptime": "38787",
"bindir": "/home/tzz/.cfagent/bin",
"nova_version": "3.7.0a1.62bfb77",
"arch": "x86_64",
"ipv4": "192.168.1.48",
"ipv4_2[eth0]": "192.168",
"maildir": "/var/spool/mail",
"logdir": "/home/tzz/.cfagent",
"ipv4_1[lo]": "127",
"ipv6_addresses": [
"fe80::e2cb:4eff:fe8c:5f1",
"fe80::800:27ff:fe00:0"
],
"crontab": "/var/spool/cron/crontabs/tzz",
"interface": "vboxnet0",
"cf_monitord": "\"/home/tzz/.cfagent/bin/cf-monitord\"",
"key_digest": "SHA=a79c242b4e6e0e5678452d8fc9ffffff8ae3a311af2dcf3e0d5ed145efb0a554",
"local_libdir": "lib/3.7",
"interface_flags[vboxnet0]": "up broadcast running multicast",
"cpus": "8",
"cf_version_minor": "7",
"ipv4[vboxnet0]": "192.168.33.1",
"class": "linux",
"ip_addresses": [
"127.0.0.1",
"192.168.1.48",
"192.168.33.1"
],
"cf_serverd": "\"/home/tzz/.cfagent/bin/cf-serverd\"",
"date": "Mon Nov 17 05:52:16 2014",
"interface_flags[lo]": "up loopback running",
"ipv4_1[vboxnet0]": "192",
"interfaces": [
"eth0",
"vboxnet0"
],
"cf_runagent": "\"/home/tzz/.cfagent/bin/cf-runagent\"",
"flavor": "ubuntu_14",
"ostype": "linux_x86_64",
"uqhost": "flea",
"os": "linux",
"interface_flags[eth0]": "up broadcast running multicast",
"enterprise_version": "3.7.0a1.62bfb77",
"piddir": "/home/tzz/.cfagent",
"failsafe_policy_path": "/home/tzz/.cfagent/inputs/failsafe.cf",
"exports": "/etc/exports",
"ipv4[eth0]": "192.168.1.48",
"release": "3.11.0-15-generic",
"cf_version": "3.7.0a1.c639fe1",
"domain": "",
"ipv4_1[eth0]": "192",
"fstab": "/etc/fstab",
"hardware_flags": [
"up loopback running",
"up broadcast running multicast",
"up broadcast running multicast"
],
"ipv4_3[vboxnet0]": "192.168.33",
"cf_promises": "\"/home/tzz/.cfagent/bin/cf-promises\"",
"cf_version_patch": "0",
"ipv4_2[vboxnet0]": "192.168",
"version": "#25-Ubuntu SMP Thu Jan 30 17:22:01 UTC 2014",
"hardware_mac[eth0]": "ff:ff:ff:ff:ff:ff",
"cf_version_major": "3",
"doc_root": "/var/www",
"cf_key": "\"/home/tzz/.cfagent/bin/cf-key\"",
"ipv4_3[lo]": "127.0.0",
"masterdir": "/home/tzz/.cfagent/masterfiles",
"cf_twin": "\"/home/tzz/.cfagent/bin/cf-twin\"",
"cf_execd": "\"/home/tzz/.cfagent/bin/cf-execd\"",
"ipv4_3[eth0]": "192.168.1",
"cf_upgrade": "\"/home/tzz/.cfagent/bin/cf-upgrade\"",
"ipv4_2[lo]": "127.0",
"update_policy_path": "/home/tzz/.cfagent/inputs/update.cf",
"hardware_mac[vboxnet0]": "ff:ff:ff:00:00:00",
"cdate": "Mon_Nov_17_05_52_16_2014",
"libdir": "/home/tzz/.cfagent/inputs/lib/3.7",
"workdir": "/home/tzz/.cfagent",
"long_arch": "linux_x86_64_3_11_0_15_generic__25_Ubuntu_SMP_Thu_Jan_30_17_22_01_UTC_2014",
"ipv4[lo]": "127.0.0.1",
"host": "flea",
"inputdir": "/home/tzz/.cfagent/inputs",
"cf_agent": "\"/home/tzz/.cfagent/bin/cf-agent\"",
"resolv": "/etc/resolv.conf",
"sysday": "16391"
},
"holder": {
"list": [
"element1",
"element2"
],
"s": "Hello!",
"d": [
4,
5,
6
]
},
"const": {
"t": "\t",
"n": "\n",
"dollar": "$",
"dirsep": "/",
"endl": "\n",
"r": "\r"
},
"control_common": {
"bundlesequence": [
"holder",
"test_datastate_mustache"
]
}
}
{
"flea_local": true,
"agent": true,
"Lcycle_1": true,
"192_168_1_48": true,
"Hr5": true,
"x86_64": true,
"GMT_Min52": true,
"ubuntu_14": true,
"mac_ff_ff_ff_ff_ff_ff": true,
"GMT_Yr2014": true,
"ipv4_192_168": true,
"nova": true,
"linux_x86_64": true,
"enterprise_3_7_0a1_62bfb77": true,
"GMT_Q4": true,
"ubuntu": true,
"Min50_55": true,
"nova_edition": true,
"GMT_Hr10_Q4": true,
"enterprise_3_7": true,
"enterprise_edition": true,
"GMT_Lcycle_1": true,
"Q4": true,
"Hr05": true,
"inform_mode": true,
"localhost": true,
"Monday": true,
"linux_x86_64_3_11_0_15_generic": true,
"linux_x86_64_3_11_0_15_generic__25_Ubuntu_SMP_Thu_Jan_30_17_22_01_UTC_2014": true,
"PK_SHA_edited": true,
"debian_jessie": true,
"GMT_Monday": true,
"Min52": true,
"November": true,
"enterprise": true,
"ipv4_192_168_33_1": true,
"compiled_on_linux_gnu": true,
"192_168_33_1": true,
"ipv6_fe80__800_27ff_fe00_0": true,
"8_cpus": true,
"cfengine_3_7_0a1_c639fe1": true,
"linux": true,
"GMT_Hr10": true,
"nova_3_7_0a1_62bfb77": true,
"ipv6_fe80__e2cb_4eff_fe8c_5f1": true,
"64_bit": true,
"net_iface_vboxnet0": true,
"cfengine_3_7_0a1": true,
"nova_3": true,
"Night": true,
"ipv4_192": true,
"ubuntu_14_4": true,
"linux_3_11_0_15_generic": true,
"Hr05_Q4": true,
"fe80__e2cb_4eff_fe8c_5f1": true,
"cfengine": true,
"cfengine_3": true,
"ipv4_127_0": true,
"nova_3_7_0a1": true,
"mac_ff_ff_ff_00_00_00": true,
"Day17": true,
"GMT_Morning": true,
"ipv4_127": true,
"127_0_0_1": true,
"Yr2014": true,
"nova_3_7": true,
"ipv4_192_168_1_48": true,
"enterprise_3": true,
"holderclass": true,
"GMT_November": true,
"cfengine_3_7": true,
"enterprise_3_7_0a1": true,
"debian": true,
"flea": true,
"net_iface_eth0": true,
"any": true,
"cfdc_utilities_run_once:_special_script___activation_id_": true,
"ipv4_192_168_1": true,
"fe80__800_27ff_fe00_0": true,
"ipv4_192_168_33": true,
"net_iface_lo": true,
"ipv4_127_0_0_1": true,
"ipv4_127_0_0": true,
"GMT_Day17": true,
"GMT_Min50_55": true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment