> We're likely to have a local repo (or perhaps two...).  So I suspect that a 
> proxy line in "/etc/yum.conf" might not fly.  (I'm no yum expert at all, and 
> would be happy to be shown to be wrong!)

I understand.

> But let's leave aside the "yum" aspects.  In terms of basic cfengine 
> principles, is cfengine itself capable of inserting a common line into all 
> sections (whose section titles are unknown in advance) of an arbitrary INI 
> file?
>
> If so, how?  If not, then should I report a bug?

The reference manual states:  "Editing takes place within a marked
region (which defaults to the whole file if not otherwise specified).
"

You want to edit multiple marked regions.  I don't think Cfengine
supports that at present.  (Correct me if I'm mistaken.)  Cfengine
expects there to be a single region that you want to edit, which,
unless specified, is the whole file.

How about an insert_lines, promise, to insert a "proxy=..." line after
each [repo_name] section header, using the "location" attribute of
insert_lines?  Nope, does not work, I tried that, but due to
first_last attribute, you can only edit the first or last match:

{{{
body common control  {

    inputs => { "/var/cfengine/inputs/cfengine_stdlib.cf" };

}

bundle agent example {

    files:

        "/tmp/test.ini"

            edit_line => setproxy;

}


###############################################################


bundle edit_line setproxy {

     insert_lines:
       "proxy=proxyname"
           location => after("\[.*\]");
}
}}}

So I tried replace_patterns ( to replace each instance of [section] with

[section]
proxy=...
)

but Cfengine complains it is not convergent:

{{{

bundle agent example {

    files:

        "/tmp/test.ini"

            edit_line => setproxy;

}


###############################################################
bundle edit_line setproxy
{
  replace_patterns:

    "(\[.*\])" replace_with => value("$(match.1)$(const.n)proxy=proxyname");
}

########################################


body replace_with value(x)
{
replace_value => "$(x)";
occurrences => "all";
}

}}}

I have to say, davidlee, something does not make sense to me here...
if you are going to
set a proxy only for some repo's, you can use section_INI and
explicitly name out
which repos need a proxy.  If you want to do it for all repos, then
you can set it in yum.conf
as a global setting.   So how do you want your system to look, what is
the desired end state?

The general sequence is:
1. identify the system administration issue/problem
2. envision the desired end state (what configuration do you want?)
3. code up the desired end state in the Cfengine language

State (1) and (2) for us, and we'll help you get to 3.

Best,
Aleksey

Yours truly,
Aleksey
Aleksey
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to