CFEngine Community on Android!

One of the many attractive features with CFEngine is its low resource footprint. Even though the software is running on some of the largest IT installations in the world, CFEngine developers seem to always be focused on doing more with less. Afterall, your IT equipment should spend time and resources on generating value, not on configuration management.

Another attractive feature has been CFEngine’s ability to run on most available platforms. Using one management system across many different server technologies has proven to save time and money for many.

Devices running Android are usually powered directly by batteries and have a scarce resources. Android is basically also a Linux distro, an operating system which CFEngine runs very well on. So, it would seem like CFEngine and Android is a good match and this is why we set out to build an experimental release of CFEngine for Android (available here).

You will need adb and set up your device with debugging and root access (we have used the CyanogenMod Android Community Operating System).

laptop$ adb push cfengine-community_3.5.3_android_armv7l.tgz /sdcard/
laptop$ adb shell
shell@android:/ $ su -
root@android:/ # cp /sdcard/cfengine-community_3.5.3_android_armv7l.tgz /data
root@android:/ # rm /sdcard/cfengine-community_3.5.3_android_armv7l.tgz
root@android:/ # cd /data
root@android:/data # tar xzf cfengine-community_3.5.3_android_armv7l.tgz

The Android linker does not honor RPATH as it uses a hard coded array consisting of “/system/lib” and “/vendor/lib”. However, it honors the LD_LIBRARY_PATH environment variable. So, you either need to copy the CFEngine libraries to one of the forementioned locations or use the LD_LIBRARY_PATH variable.

Copying libraries

This is what you need to do if you don’t want to use the LD_LIBRARY_PATH variable:

root@android:/ # mount -o remount,rw /system
root@android:/ # cp -a /data/cfengine/lib/lib*so* /system/vendor/lib/
root@android:/ # mount -o remount,ro /system

Ignore any error messages while copying.

CFEngine should now be able to execute:

root@android:/ # /data/cfengine/bin/cf-agent -Kf /data/test.cf                 
2014-02-11T13:51:10+0100   notice: R: Hello, I am a android running on a armv7l

Using LD_LIBRARY_PATH

Simply set the LD_LIBRARY_PATH to point to the location of the CFENgine libraries.

root@android:/ # export LD_LIBRARY_PATH=/data/cfengine/lib

CFEngine should now be able to execute:

# /data/cfengine/bin/cf-agent -Kf /data/test.cf                 
2014-02-11T13:55:44+0100   notice: R: Hello, I am a android running on a armv7

Screenshot_2014-02-11-14-17-15

Posted in Android