Forum: CFEngine Help
Subject: Re: Forcing variable evaluation after file promises
Author: neilhwatson
Link to topic: https://cfengine.com/forum/read.php?3,27031,27035#msg-27035

Perhaps something like this:

bundle agent add_sshkeys_to_user(u, keys)
{
vars:
        "keystore" string => "/var/cfengine3/ssh_cache";
        "u_home" string   => execresult("/bin/echo ~${u}", "useshell");
load_ssh_keys::
        "key[$(keys)]" string => readfile("$(keystore)/$(keys).pub", "1024");

files:
        "$(keystore)/$(keys).pub"
                comment   => "Copy public keys from remote cache",
                perms     => mog("600","root", "root"),
                classes   => if_ok("load_ssh_keys"), ###<<<<<<<<<<
                copy_from => secure_cp("$(g.mst)/pub/$(keys).pub","$(g.phst)"),
                action    => if_elapsed("30");


You could also put the keys directly in the policy 
(http://watson-wilson.ca/2011/05/ssh-public-key-distribution-using-cfengine.html).

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

Reply via email to