« The risk of high uptimes.... | Moving irssi » |
What I had started working on instead just before last weekend ended, was to convert a bunch of processes:
& commands:
actions in services:
actions, after having first come across "bundle common paths"paths" in the COPBL to address a FreeBSD vs Ubuntu path difference and then spotting "bundle agent standard_services(service,state)"
. So, I spend some time convert my "services"
promise to use this, as well as some other promises that have additional supporting actions. Such as my "ssh"
promise. Along the way I also create a "bundle agent extra_services(service,state)"
, to add services that I've created, or services that are missing (either for FreeBSD or Ubuntu, or both) in standard_services
.
Meanwhile, I'm trying to extend my "static"
promise to ubuntu, because its annoying not have my cfengine related aliases not defined for ubuntu servers yet. An example is the alias to run cf-agent
by hand, the alias expands to "cf-agent -f failsafe.cf && cf-agent"
On other systems it has gotten the -q
switch, but the switch doesn't exist in the ubuntu version. Wonder if that something 'new' in CFEngine 3.5.1-3, or just special in how the .deb was put together (see Moving irssi).
So, I'm working through /etc directory first for some reason.... and come to /etc/boinc-client
. Hmmm, I do edit some of these files by hand whenever I install BOINC, I suppose I should promise these as well as promise that BOINC is running.
So, I move the BOINC services promise into its own do-boinc.cf
promise file.
I narrow down to 3 files to promise: gui_rpc_auth.cfg
, remote_hosts.cfg
, and cc_config.xml
. The first to I can just copy into appropriate place (on FreeBSD its /var/db/boinc
). But cc_config.xml
differs across all three of my Ubuntu servers and didn't exist on FreeBSD. But, its only a few lines in the file that I add. And, I've been consistent on where in the XML file that I put the block, though the spacing and such I haven't been. And, not all of them have the exact same options...though in the case of the Ubuntu server that I started with, the missing option was unintentional. Though it also has an extra option (and another Ubuntu system has a related, but different option set.) Conceivably, there might be existing options in a cc_config.xml file that I need to leave in when making my edit.
The intended end result is something like:
XML
<cc_config> | |
<options> | |
<http_1_0>1</http_1_0> | |
<report_results_immediately>1</report_results_immediately> | |
</options> | |
</cc_config> |
So first I'm looking at doing an insert_lines:
action for the block '<options>...</options>'
after '<cc_config>'
...and then wonder how to handle if the file had started empty?
Use a class
?
But, then I think, didn't I see that there's an edit_xml
bundle?
Perhaps I should use that instead.
So I write something up, like this:
bundle edit_xml boinc_cc_config { insert_text: "1" select_xpath => "/cc_config/options/http_1_0"; "1" select_xpath => "/cc_config/options/report_results_immediately"; }
And, give it a whirl.... I get an error to the effect of "cannot edit_xml without LIBXML2", why is that happening. libxml2 is installed on my system.
I go to the port and do a 'make configure'
to see what's up.... its finding and calling xml2-config
, but the test compile fails being unable to find -lxml2
Well, ya...it isn't add ‑L/usr/local/lib
to the command. Well, it needs to call 'xml2-config --libs'libs'
to get that, and looking other configure scripts I patch in something to address this:
Shell
--- configure.orig 2013-07-11 03:26:15.000000000 -0500 | |
+++ configure 2013-07-26 19:51:44.843664757 -0500 | |
@@ -15122,6 +15122,7 @@ | |
if test "x$cross_compiling" = "xno"; then | |
if test x`which $XML2_CONFIG` != x ; then | |
CPPFLAGS="$CPPFLAGS `$XML2_CONFIG --cflags`" | |
+ LDFLAGS="$LDFLAGS `$XML2_CONFIG --libs`" | |
fi | |
fi |
I mull over whether to report it as bug in ports or cfengine, I decide to go with cfengine first... #3207. But later it occurs to me that the port should show libxml2 as a dependency...and while writing up the PR, I notice that for one of the port options, it'll add the '-L'
switch to LDFLAGS
, probably because the configure
doesn't do the right thing for that. ports/180896
Back to edit_xml
, what I've come up with works on zen, because the both options are already present and the value is already right. But, it fails on lhaven, because there's no "/cc_config/options/http_1_0"
xpath to select.
Part of the problem is that I'm not really that knowledgeable on XML and its nomenclature...so I'm not fully sure what all the xpath can be, and CFEngine documentation doesn't show something like before and after with its example of the various edit_xml
actions. And, I couldn't find anything online that showed XML to XPath relationships.
After a lot of trial and error, I come up with this bundle:
Code
bundle edit_xml boinc_cc_config | |
{ | |
build_xpath: | |
| |
"/cc_config/options/http_1_0"; | |
| |
"/cc_config/options/report_results_immediately"; | |
| |
set_text: | |
| |
"1" | |
select_xpath => "/cc_config/options/http_1_0"; | |
| |
"1" | |
select_xpath => "/cc_config/options/report_results_immediately"; | |
| |
} |
That seems to work.... making no change on zen, while make these changes to lhaven:
XML
--- cc_config.xml.cf-before-edit 2012-04-19 10:58:27.000000000 -0500 | |
+++ cc_config.xml 2013-07-27 13:28:10.829730115 -0500 | |
@@ -1,3 +1,4 @@ | |
+<?xml version="1.0"?> | |
<!-- | |
This is a minimal configuration file cc_config.xml of the BOINC core client. | |
For a complete list of all available options and logging flags and their | |
@@ -7,7 +8,7 @@ | |
<options> | |
<report_results_immediately>1</report_results_immediately> | |
<use_all_gpus>1</use_all_gpus> | |
- </options> | |
+ <http_1_0>1</http_1_0></options> | |
<log_flags> | |
<task>1</task> | |
<file_xfer>1</file_xfer> |
Noting that I have the extra "use_all_gpus"
flag set on lhaven...and there's another server where I have "no_gpus"
flag set. I start to create classes to conditionally add these...but then there's the question of what if I want to turn this option on/off later....guess I'll put off the changes to edit_xml to implement for now....
After /etc/boinc-client
on lhaven, came /etc/cups
...so I look to implementing the ubuntu side...and this is when I notice that its an any host promise...which has partially been written for ubuntu, it knows where cupsd
is located. And, that's when I realize the mistake I had made.
Guess its back to my static
promise.