While implementing the bootstrap to custom ports and host names functionality I wrote this small "guide" on how to use the features and see if it worked.
Important: I have the repositories ~/cfengine/masterfiles
and ~/cfengine/core
on my machine. If you want to install from source you will need to adjust these paths accordingly to your folder locations.
If you want to test with a custom hostname, you can add it to /etc/hosts
:
sudo emacs /etc/hosts
/etc/hosts
:
127.0.0.1 localhost
192.168.50.50 myhostname
...
(Replace 192.168.50.50 with the IP of the hub & myhostname with a name you want to use). This is probably most useful on the client, but you can do it on both, for simplicity.
If you are not installing from source, but using prebuilt enterprise(or community) you will install in the regular way and can skip this part.
cd ~/cfengine/masterfiles && ./autogen.sh && ./configure.sh && sudo make -j2 install
To install core simply:
cd ~/cfengine/core && sudo make -j2 install
If you want to use a custom port, you will have to edit the cf-serverd
policy:
sudo emacs /var/cfengine/masterfiles/controls/cf_serverd.cf
Add port => "5309";
in body server control
:
body server control
{
port => "5309";
...
There are many ways you can bootstrap now:
sudo /var/cfengine/bin/cf-agent --bootstrap 192.168.50.50:5309
sudo /var/cfengine/bin/cf-agent --bootstrap myhostname:5309
sudo /var/cfengine/bin/cf-agent --bootstrap myhostname
If you do not specify a port the default port will be used (5308). Note: When bootstrapping on the hub it will not care about what port you specify. It will recognize it's bootstrapping to itself and do a local file copy.
sudo emacs /var/cfengine/masterfiles/update.cf
Make some change(comment for testing)
sudo /var/cfengine/bin/cf-agent -f update.cf -K
sudo /var/cfengine/bin/cf-agent
sudo /var/cfengine/bin/cf-agent -f update.cf -K
sudo emacs /var/cfengine/inputs/update.cf
This bash script shows how to stop running processes, reinstall from source(core, not masterfiles) and bootstrap. Assumes you have already installed masterfiles on the hub.
testscript.sh
:
killall cf-execd
killall cf-serverd
killall cf-hub
killall cf-agent
rm -rf /var/cfengine/inputs/
cd ~/cfengine/core
make -j2 install
/var/cfengine/bin/cf-agent --bootstrap myhostname:5309
(This will not undo the change you did to cf_serverd.cf
)
Must run using sudo:
sudo ./testscript.sh
Note that this only runs bootstrap, and thus doesn't test subsequent runs of cf-agent.
@jimis Definitely. I'm working on some fixes now though, so I'll add it after this feature is working as intended.