Feature Friday #8: bundlesequence

Posted by Nick Anderson
May 3, 2024

Ever want to run just a one or a few select bundles from your policy?

While developing policy it’s common to run cf-agent -KI so that you can quickly iterate on changes and the run the policy without locks. But if you are focused on select bundles you may not need the full policy to run, you can use the --bundlesequence option to specify one or more bundles overriding the bundlesequence defined in body common control.

Let’s check out an example using the Masterfiles Policy Framework (MPF).

First, let’s see how long it takes to run the full policy without locks:

for each in $(seq 3); do
    /bin/time -o /dev/tty cf-agent -K > /dev/null 2>&1
6.62user 3.52system 0:14.02elapsed 72%CPU (0avgtext+0avgdata 106144maxresident)k
0inputs+5312outputs (0major+92361minor)pagefaults 0swaps
6.27user 2.75system 0:11.49elapsed 78%CPU (0avgtext+0avgdata 103696maxresident)k
0inputs+2320outputs (0major+90882minor)pagefaults 0swaps
7.28user 3.74system 0:15.26elapsed 72%CPU (0avgtext+0avgdata 104092maxresident)k
0inputs+2576outputs (0major+92528minor)pagefaults 0swaps

From the output we can see that execution time is about 13 seconds.

Now, I am just interested in one bundle, host_info_report. So, let’s see how long running just that bundle takes:

for each in $(seq 3); do
    /bin/time -o /dev/tty cf-agent -K --bundlesequence host_info_report > /dev/null 2>&1
3.00user 0.59system 0:03.72elapsed 96%CPU (0avgtext+0avgdata 105616maxresident)k
0inputs+4920outputs (0major+52900minor)pagefaults 0swaps
2.51user 0.48system 0:03.12elapsed 95%CPU (0avgtext+0avgdata 104676maxresident)k
0inputs+1224outputs (0major+56042minor)pagefaults 0swaps
2.61user 0.44system 0:03.17elapsed 96%CPU (0avgtext+0avgdata 105568maxresident)k
0inputs+1240outputs (0major+57858minor)pagefaults 0swaps

As we can see from the output, execution time was dramatically lower, about 3 seconds for the execution.

Sometimes you need more than one bundle, simply separate the bundles with a comma:

for each in $(seq 3); do
    /bin/time -o /dev/tty cf-agent -K --bundlesequence inventory_autorun,host_info_report > /dev/null 2>&1
2.84user 0.56system 0:03.52elapsed 96%CPU (0avgtext+0avgdata 104204maxresident)k
0inputs+4784outputs (0major+58614minor)pagefaults 0swaps
2.77user 0.42system 0:03.32elapsed 96%CPU (0avgtext+0avgdata 105372maxresident)k
0inputs+1432outputs (0major+57686minor)pagefaults 0swaps
2.68user 0.43system 0:03.22elapsed 96%CPU (0avgtext+0avgdata 104388maxresident)k
0inputs+1416outputs (0major+59159minor)pagefaults 0swaps

We see that adding inventory_autorun to the bundlesequence adds 10ths of a second to our execution time.

Happy Friday! 🎉