What’s the easiest way to install cfengine? Have you heard of cf-remote
?
cf-remote
was born out of a developer’s itch for an easy way to get CFEngine installed on some host for testing. We have featured cf-remote
in several posts1 since it was first released in 2019, but today is Friday, so let’s review its features.
Overview
cf-remote
(available via the Python Package Index) primarily targets installing CFEngine on a remote host, but it also provides some related conveniences including:
- showing some basic remote host info
- listing URLs for CFEngine packages
- copying files
- running commands
- deploying policy
- spawning and destroying hosts on supported cloud platforms
pip3 install cf-remote --user
Listing package URLs
By default, cf-remote list
shows URLs for CFEngine Enterprise assets from the most recent LTS, but if you want to know where the 3.21.4 packages for Debian 12 hubs are? It’s a simple thing, but cf-remote
really makes it easy:
cf-remote --version 3.21.4 list debian12 hub
Available releases: master, 3.23.0, 3.21.x, 3.21.4, 3.21.3, 3.21.2, 3.21.1, 3.21.0, 3.18.x, 3.18.7, 3.18.6, 3.18.5, 3.18.4, 3.18.3, 3.18.2, 3.18.1, 3.18.0
Using 3.21.4 LTS:
https://cfengine-package-repos.s3.amazonaws.com/enterprise/Enterprise-3.21.4/hub/debian_12_x86_64/cfengine-nova-hub_3.21.4-1.debian12_amd64.deb
https://cfengine-package-repos.s3.amazonaws.com/enterprise/Enterprise-3.21.4/hub/debian_12_arm_64/cfengine-nova-hub_3.21.4-1.debian12_arm64.deb
In addition to released versions, you can get nightly packages using master
or the .x
suffixed versions. For example, to get the URL for the latest nightly masterfiles for 3.18:
cf-remote --version 3.18.x list masterfiles
Available releases: master, 3.23.0, 3.21.x, 3.21.4, 3.21.3, 3.21.2, 3.21.1, 3.21.0, 3.18.x, 3.18.7, 3.18.6, 3.18.5, 3.18.4, 3.18.3, 3.18.2, 3.18.1, 3.18.0
Using 3.18.x LTS:
http://buildcache.cfengine.com/packages/testing-pr/jenkins-3.18.x-nightly-pipeline-685/PACKAGES_x86_64_linux_redhat_7/tarballs/cfengine-masterfiles-3.18.8a.efd0a8cf3-1.pkg.tar.gz
If you are looking for community assets, just specify --edition community
for the list
command:
cf-remote --version 3.18.x list --edition community el7
Available releases: master, 3.23.0, 3.21.x, 3.21.4, 3.21.3, 3.21.2, 3.21.1, 3.21.0, 3.18.x, 3.18.7, 3.18.6, 3.18.5, 3.18.4, 3.18.3, 3.18.2, 3.18.1, 3.18.0
Using 3.18.x LTS:
http://buildcache.cfengine.com/packages/testing-pr/jenkins-community-nightly-3.18.x-519/PACKAGES_x86_64_linux_redhat_7/cfengine-community-3.18.8a.759009f84-31534.el7.x86_64.rpm
Spawning hosts
Let’s see what it’s like to bring up a small environment of test hosts. Run cf-remote spawn --list-platforms
to see the platforms cf-remote
knows how to initialize, then spawn some hosts:
cf-remote spawn --platform ubuntu-22-04-x64 --count 1 --size t2.xlarge --name hub --role hub
cf-remote spawn --platform ubuntu-18-04-x64 --count 1 --name ubuntu18 --role client
cf-remote spawn --platform rhel-7-x64 --count 1 --name rhel7 --role client
cf-remote spawn --platform rhel-9-x64 --count 2 --name rhel9 --role client
Spawning VMs....DONE
Waiting for VMs to get IP addresses...DONE
Details about the spawned VMs can be found in /home/nickanderson/.cfengine/cf-remote/cloud_state.json
Spawning VMs....DONE
Waiting for VMs to get IP addresses...DONE
Details about the spawned VMs can be found in /home/nickanderson/.cfengine/cf-remote/cloud_state.json
Spawning VMs....DONE
Waiting for VMs to get IP addresses...DONE
Details about the spawned VMs can be found in /home/nickanderson/.cfengine/cf-remote/cloud_state.json
Spawning VMs.....DONE
Details about the spawned VMs can be found in /home/nickanderson/.cfengine/cf-remote/cloud_state.json
Now we can use cf-remote show
to see information about spawned hosts:
cf-remote show
@hub: (1 host in eu-west-1, aws)
ubuntu@3.250.76.66
hub, nihub-ubuntu-22-04-x64hub0, ubuntu-22-04-x64, t2.xlarge,
172.31.40.73, 3.250.76.66, d61ec86a6640302a078da276c89cfb139eafd831,
nickanderson-cfengine-dev-eu-west-1, cfengine-test
@ubuntu18: (1 host in eu-west-1, aws)
ubuntu@3.253.129.99
client, niubuntu18-ubuntu-18-04-x64client0, ubuntu-18-04-x64, m3.xlarge,
172.31.1.11, 3.253.129.99, 4c9b0dbaa0d2983f44d85ae071179ee6026e266a,
nickanderson-cfengine-dev-eu-west-1, cfengine-test
@rhel7: (1 host in eu-west-1, aws)
ec2-user@34.243.111.152
client, nirhel7-rhel-7-x64client0, rhel-7-x64, t2.large, 172.31.42.214,
34.243.111.152, 295f5aa1b7f94d60519537bab6e93a916d170bcf,
nickanderson-cfengine-dev-eu-west-1, cfengine-test
@rhel9: (2 hosts in eu-west-1, aws)
ec2-user@54.171.254.178
client, nirhel9-rhel-9-x64client0, rhel-9-x64, m3.xlarge, 172.31.0.193,
54.171.254.178, 12baa67b2527fbdfb8f77d09ad196e3ff855dd9d,
nickanderson-cfengine-dev-eu-west-1, cfengine-test
ec2-user@18.201.38.169
client, nirhel9-rhel-9-x64client1, rhel-9-x64, m3.xlarge, 172.31.5.170,
18.201.38.169, 31847baef8fcaf2a1764beeb51458e2e92c393c3,
nickanderson-cfengine-dev-eu-west-1, cfengine-test
Total: 5 hosts in 4 groups
Host info
With some hosts running, we can use cf-remote
to see some basic host info.
We can look at a single host:
cf-remote info --hosts ec2-user@54.171.254.178
ec2-user@54.171.254.178
OS : RHEL 9
Architecture : x86_64
CFEngine : Not installed
Policy server : None
Binaries : rpm, yum
Or we can look at a group of hosts:
cf-remote info --hosts @rhel9
ec2-user@54.171.254.178
OS : RHEL 9
Architecture : x86_64
CFEngine : Not installed
Policy server : None
Binaries : rpm, yum
ec2-user@18.201.38.169
OS : RHEL 9
Architecture : x86_64
CFEngine : Not installed
Policy server : None
Binaries : rpm, yum
Installing & bootstrapping CFEngine
Let’s use cf-remote
to install and bootstrap our provisioned hosts.
Let’s install an Enterprise hub, we can specify the IP of the host, or we can use the name
specified during the spawn, hub
.
cf-remote --version master install --remote-download --bootstrap hub --hub hub
ubuntu@3.250.76.66
OS : Ubuntu 22
Architecture : x86_64
CFEngine : Not installed
Policy server : None
Binaries : dpkg, apt
Downloading 'http://buildcache.cfengine.com/packages/testing-pr/jenkins-master-nightly-pipeline-1481/PACKAGES_HUB_x86_64_linux_ubuntu_22/cfengine-nova-hub_3.24.0a.8f1bb17ac~31544.ubuntu22_amd64.deb' on 'ubuntu@3.250.76.66' using curl
Installing: 'cfengine-nova-hub_3.24.0a.8f1bb17ac~31544.ubuntu22_amd64.deb' on 'ubuntu@3.250.76.66'
CFEngine 3.24.0a.8f1bb17ac (Enterprise) was successfully installed on 'ubuntu@3.250.76.66'
Bootstrapping: '3.250.76.66' -> '172.31.40.73'
Bootstrap successful: '3.250.76.66' -> '172.31.40.73'
Note the use of --remote-download
: By default, cf-remote
downloads packages to the machine executing cf-remote
and then copies the package to the host. Using --remote-download
the package is downloaded directly by the remote host that is being installed.
Now we can install some clients:
cf-remote --version master install --remote-download --bootstrap hub --clients ubuntu18
cf-remote --version master install --remote-download --bootstrap hub --clients rhel9
ubuntu@3.253.129.99
OS : Ubuntu 18
Architecture : x86_64
CFEngine : Not installed
Policy server : None
Binaries : dpkg, apt
Downloading 'http://buildcache.cfengine.com/packages/testing-pr/jenkins-master-nightly-pipeline-1481/PACKAGES_x86_64_linux_ubuntu_18/cfengine-nova_3.24.0a.8f1bb17ac~31544.ubuntu18_amd64.deb' on 'ubuntu@3.253.129.99' using curl
Installing: 'cfengine-nova_3.24.0a.8f1bb17ac~31544.ubuntu18_amd64.deb' on 'ubuntu@3.253.129.99'
CFEngine 3.24.0a.8f1bb17ac (Enterprise) was successfully installed on 'ubuntu@3.253.129.99'
Bootstrapping: '3.253.129.99' -> '172.31.40.73'
Bootstrap successful: '3.253.129.99' -> '172.31.40.73'
Downloading 'http://buildcache.cfengine.com/packages/testing-pr/jenkins-master-nightly-pipeline-1481/PACKAGES_x86_64_linux_redhat_9/cfengine-nova-3.24.0a.8f1bb17ac-31544.el9.x86_64.rpm' on 'ec2-user@18.201.38.169' using curl
Downloading 'http://buildcache.cfengine.com/packages/testing-pr/jenkins-master-nightly-pipeline-1481/PACKAGES_x86_64_linux_redhat_9/cfengine-nova-3.24.0a.8f1bb17ac-31544.el9.x86_64.rpm' on 'ec2-user@54.171.254.178' using curl
Installing: 'cfengine-nova-3.24.0a.8f1bb17ac-31544.el9.x86_64.rpm' on 'ec2-user@18.201.38.169'
Installing: 'cfengine-nova-3.24.0a.8f1bb17ac-31544.el9.x86_64.rpm' on 'ec2-user@54.171.254.178'
CFEngine 3.24.0a.8f1bb17ac (Enterprise) was successfully installed on 'ec2-user@54.171.254.178'
Bootstrapping: '54.171.254.178' -> '172.31.40.73'
Bootstrap successful: '54.171.254.178' -> '172.31.40.73'
CFEngine 3.24.0a.8f1bb17ac (Enterprise) was successfully installed on 'ec2-user@18.201.38.169'
Bootstrapping: '18.201.38.169' -> '172.31.40.73'
Bootstrap successful: '18.201.38.169' -> '172.31.40.73'
Note there are other interesting options like --demo
and --call-collect
that can be useful in development environments. To see all the options for install run cf-remote install --help
.
Destroying spawned hosts
Now that we are done with our little test infrastructure, we can clean it up with cf-remote destroy
:
cf-remote destroy --all
Destroying all hosts
Happy Friday! 🎉
-
Blog posts about
cf-remote
https://cfengine.com/tags/cf-remote/ ↩︎