The following works if servers/* files exist (e.g. servers/web1
servers/web2 servers/haproxy) but if they don't cfengine won't run!
cf-promises segfaults.   (i'm using 3.1.4, by the way).  I've promised
Eystein a gdb backtrace once I learn how to make one.


#############################################
bundle agent cfengine_package_uploaded(desired_servers)
{


vars:
   "public_hostnames" slist =>
   {
      readstringlist("/home/user/cfengine_ec2/servers/haproxy",
"^i-\S+", "\s", 1, 100),
      readstringlist("/home/user/cfengine_ec2/servers/web1",
"^i-\S+", "\s", 1, 100),
      readstringlist("/home/user/cfengine_ec2/servers/web2",
"^i-\S+", "\s", 1, 100),

   };  #treat the instance identifier as a comment and ignore it;
this will result in reading only the public hostname


# use SSH option StrictHostKeyChecking=no to automatically add new host keys

commands: "/usr/bin/scp -o StrictHostKeyChecking=no -i
/home/user/ec2/mysshkey_key.pem
/home/user/cfengine_ec2/cfengine-community_3.1.4-1_ubuntu10_i386.deb
ubuntu@$(public_hostnames):";

commands: "/usr/bin/ssh -o StrictHostKeyChecking=no -i
/home/user/ec2/mysshkey_key.pem ubuntu@$(public_hostnames)
/usr/bin/sudo /usr/bin/dpkg -i
cfengine-community_3.1.4-1_ubuntu10_i386.deb";
}

################################################3

If I comment this part out on the first run, when provisioning takes
place, cfengine does not die; then, after the VM's have been
provisioned and the files in servers/* created, if I uncomment this
bundle, it runs fine.

So here is my workaround: put the bootstrapping of cfengine
into the provisioning script:

user@user-desktop:~/cfengine_ec2$ cat start_micro_instance.sh
#!/bin/sh

INSTANCE_ID=`ec2-run-instances -t t1.micro  ami-6c06f305 -k mysshkey
2>&1 | awk '/^INSTANCE/ {print $2}'`

INSTANCE_HOSTNAME=pending

while [ "${INSTANCE_HOSTNAME}" = "pending" ]
do
        sleep 3
        INSTANCE_HOSTNAME=`ec2-describe-instances $INSTANCE_ID | awk
'/^INSTANCE/ {print $4}'`


done

echo $INSTANCE_ID $INSTANCE_HOSTNAME

nohup sh -c "sleep 60 \
&& \
/usr/bin/scp \
        -o StrictHostKeyChecking=no \
        -i /home/user/ec2/mysshkey_key.pem\
        /home/user/cfengine_ec2/cfengine-community_3.1.4-1_ubuntu10_i386.deb \
        ubuntu@${INSTANCE_HOSTNAME}: \
        && \
        /usr/bin/ssh \
                -o StrictHostKeyChecking=no \
                -i /home/user/ec2/mysshkey_key.pem \
                ubuntu@${INSTANCE_HOSTNAME} \
                '/usr/bin/sudo /usr/bin/dpkg -i
cfengine-community_3.1.4-1_ubuntu10_i386.deb && \
                 /usr/bin/sudo cp
/usr/local/share/doc/cfengine/inputs/* /var/cfengine/inputs/ && \
                 /usr/bin/sudo cf-agent'" >/dev/null 2>/dev/null &
user@user-desktop:~/cfengine_ec2$



This gets the edge VMs into a state where theyhave an cf-execd entry
in the cron script and default promises installed in
/var/cfengine/inputs.

Now to get a bit of sleep...

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

Reply via email to