Forum: Cfengine Help
Subject: Re: Cfengine Help: Inherit shell variables in "commands:"
Author: berntjernberg
Link to topic: https://cfengine.com/forum/read.php?3,19966,19967#msg-19967

Hi,

As I understand it the variables are "imported" to cfengine with module but I 
need the variables to stay in shell context.
Great info though. :-)

I came up with this code:



bundle agent remove_file(file)
{
    files:
        # Delete file.
        "$(file)"
        delete => tidy,
        file_select => plain;
}

bundle agent run_vip_script
{
    vars:
        "wrapper_content"  string =>
"#!/usr/bin/bash
export VAR1=val1
export VAR2=val2
export VAR3=val3
export VAR4=val4
export VAR5=val5
export VAR6=val6
export VAR7=val7
export VAR8=val8
export VAR9=val9
export VAR10=val10

/path/to/external_script arg";


    files:
        !wrapper_created::
            "/tmp/wrapper"
            perms => mog(0700,root,root),
            create => "true",
            edit_defaults => std_defs,
            edit_line => create_file("$(wrapper_content)"),
            classes => if_repaired("wrapper_created");

    commands:
        wrapper_created::
             "/tmp/wrapper"
             classes => if_repaired("wrapper_has_run");

    methods:
        wrapper_has_run::
            "remove_wrapper" usebundle => remove_file("/tmp/wrapper");
}



_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to