Skip to content

Instantly share code, notes, and snippets.

@Szparki
Last active August 14, 2018 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Szparki/8dff778602b615c80b3df492dd0b0db0 to your computer and use it in GitHub Desktop.
Save Szparki/8dff778602b615c80b3df492dd0b0db0 to your computer and use it in GitHub Desktop.
cat test
$(sys.fqhost)
bundle agent main
{
files:
"/etc/test"
copy_from => secure_cp("$(g.configfiles)/etc/test", "$(g.host)");
"/etc/test"
perms => mog("644", "root", "$(g.root_group)"),
edit_template => "$(g.configfiles)/etc/test";
template_method => "mustache";
}
@nickanderson
Copy link

#+BEGIN_SRC cfengine3
bundle agent main
{
files:

  # We need the template before we can expand it.

    "/tmp/example.txt.mustache"
      copy_from => remote_dcp( "/srv/example.txt.mustache", $(g.host) );

# Render the file using the template.
    "/tmp/example.txt"
      edit_template => "/tmp/example.txt.mustache",
      template_method => "mustache";

}
#+END_SRC

@Szparki
Copy link
Author

Szparki commented Aug 14, 2018

  "/etc/test.tpl"
    perms => mog("644", "root", "$(g.root_group)"),
    copy_from => secure_cp("$(g.configfiles)/etc/test.tpl", "$(g.host)");
  "/etc/test"
    edit_template => "/etc/test";

@Szparki
Copy link
Author

Szparki commented Aug 14, 2018

  "/etc/test.tpl"
    copy_from => secure_cp("$(g.configfiles)/etc/test.tpl", "$(g.host)"),
    comment => "We must have a template that we can use to dynamically render our final config file.";
  "/etc/test"
    perms => mog("644", "root", "$(g.root_group)"),
    #edit_template => "$(g.configfiles)/etc/test";
    edit_template => "/etc/test",
    comment => "Render our final config file using the template";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment