Skip to content

Instantly share code, notes, and snippets.

@nickanderson
Last active May 16, 2025 19:55
Show Gist options
  • Save nickanderson/b275dd40f91fb5a8df96c07977ed5c71 to your computer and use it in GitHub Desktop.
Save nickanderson/b275dd40f91fb5a8df96c07977ed5c71 to your computer and use it in GitHub Desktop.
How can you use strings that look like CFEngine variables in CFEngine promises?

You can use $(const.dollar) if you are looking to render a literal $( ) into a file, alternatively you can use backticks.

bundle agent example_subshell_cfengine_files_promise
{
  files:
      "/tmp/using-const.dollar.txt"
        content => "#!/bin/env bash $(const.n)echo $(const.dollar)(hostname)",
        perms => m( "u+rwx" );

     "/tmp/using-backtick.txt"
        content => "#!/bin/env bash $(const.n)echo `hostname`",
        perms => m( "u+rwx" );

    commands:
      "/tmp/using-const.dollar.txt";
      "/tmp/using-backtick.txt";
}
bundle agent __main__
{
      methods: "example_subshell_cfengine_files_promise";
}
    info: Executing 'no timeout' ... '/tmp/using-const.dollar.txt'
  notice: Q: "...dollar.txt": precision-5570
    info: Last 1 quoted lines were generated by promiser '/tmp/using-const.dollar.txt'
    info: Completed execution of '/tmp/using-const.dollar.txt'
    info: Executing 'no timeout' ... '/tmp/using-backtick.txt'
  notice: Q: "...cktick.txt": precision-5570
    info: Last 1 quoted lines were generated by promiser '/tmp/using-backtick.txt'
    info: Completed execution of '/tmp/using-backtick.txt'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment