Problem recognizing existence of directory

2009-12-17 Thread bernd . adamowicz
I guess I'm facing a typical beginners problem, however, I didn't find a 
solution.

I'm checking the existence of a directory. If it's not there, I'm going to 
extract a tarball which creates it and some other files. This works very 
fine. However the extracting of the tarball is done sometimes too, even if 
the directory exists. I couldn't find a deterministic behaviour. Here's 
the code I'm using:

bundle agent check_nagios_installation {

classes:
"nagios_installed" expression => 
fileexists("${nagios_install_dir}/.");

commands:
!nagios_installed::
"/bin/tar xzvf /var/cfengine/artifacts/nagios/nagios.tar.gz -C 
/",
comment => "Going to install Nagios now.";
}

Thanks in advance!

Bernd

InterComponentWare AG:  
Vorstand: Jörg Stadler / Aufsichtsratsvors.: Prof. Dr. Christof Hettich  
Firmensitz: 69190 Walldorf, Industriestraße 41 / AG Mannheim HRB 351761 / 
USt.-IdNr.: DE 198388516  ___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: Problem recognizing existence of directory

2009-12-17 Thread Nicolas Charles
Hi,

Maybe you could use something like this :

bundle agent check_nagios_installation {
files:
"${nagios_install_dir}/"
create => "true",
comment => "Creating nagios directory",
classes => if_repaired("not_nagios_installed");
   commands:
  not_nagios_installed::
"/bin/tar xzvf /var/cfengine/artifacts/nagios/nagios.tar.gz 
-C /",
comment => "Going to install Nagios now.";
}
body classes if_repaired(class)
{
promise_repaired => { "$(class)" };
}




bernd.adamow...@external.icw-global.com wrote:
>
> I guess I'm facing a typical beginners problem, however, I didn't find 
> a solution.
>
> I'm checking the existence of a directory. If it's not there, I'm 
> going to extract a tarball which creates it and some other files. This 
> works very fine. However the extracting of the tarball is done 
> sometimes too, even if the directory exists. I couldn't find a 
> deterministic behaviour. Here's the code I'm using:
>
> bundle agent check_nagios_installation {
>
> classes:
> "nagios_installed" expression => 
> fileexists("${nagios_install_dir}/.");
>
> commands:
> !nagios_installed::
> "/bin/tar xzvf 
> /var/cfengine/artifacts/nagios/nagios.tar.gz -C /",
> comment => "Going to install Nagios now.";
> }
>
> Thanks in advance!
>
> Bernd
> InterComponentWare AG:
> Vorstand: Jörg Stadler / Aufsichtsratsvors.: Prof. Dr. Christof Hettich
> Firmensitz: 69190 Walldorf, Industriestraße 41 / AG Mannheim HRB 
> 351761 / USt.-IdNr.: DE 198388516
> 
>
> ___
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine
>   

___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: Problem recognizing existence of directory

2009-12-17 Thread bernd . adamowicz
Hi Nicolas,

I tried your example and this is what happened:

- the nagios directory is created (which should lead to creating the class 
'not_nagios_installed')
- the extraction of the tarball does not happen at all

Having a look at the output of the agent there's no evidence that anything 
is happening concerning Nagios installation at all. Having a look at the 
output of cf-execd this is what happens:

  10349 * Begin new promise type category files in function
  10350
  10351 Subtype files syntax ok for agent
  10352 Promising object name '/usr/local/nagios/.'
  10353 Recorded LVAL create
  10354 Recorded scalarRVAL true
  10355 Recorded LVAL comment
  10356 Recorded scalarRVAL Creating nagios directory
  10357 Recorded LVAL classes
  10358 Found function identifier if_repaired
  10359 Start FnCall if_repaired args level 1
  10360 Appending scalar to rval-list [not_nagios_installed]
  10361 CopyRvalItem(s)
  10362 End args level 1
  10363 Installing Function Call if_repaired
  10364 Installed if_repaired(not_nagios_installed,)
  10365
  10366 Finished with function call, now at level 0
  10367
  10368 End full promise with promisee /usr/local/nagios/.
  10369
  10370
  10371 * Begin new promise type category commands in function
  10372
  10373 Subtype commands syntax ok for agent
  10374   New class context 'not_nagios_installed' ::
  10375
  10376 Promising object name '/bin/tar xzvf 
/var/cfengine/artifacts/nagios/nagios.tar.gz -C /'
  10377 Recorded LVAL comment
  10378 Recorded scalarRVAL Going to install Nagios now.
  10379 End full promise with promisee /bin/tar xzvf 
/var/cfengine/artifacts/nagios/nagios.tar.gz -C /
  10380
  10381 End promise bundle

I'm not quiet sure how to interpret this. Obviously the promise for 'tar' 
is made, but it's not executed.

Bernd







From:
Nicolas Charles 
To:
bernd.adamow...@external.icw-global.com
Cc:
help-cfengine@cfengine.org
Date:
17.12.2009 13:02
Subject:
Re: Problem recognizing existence of directory



Hi,

Maybe you could use something like this :

bundle agent check_nagios_installation {
files:
"${nagios_install_dir}/"
create => "true",
comment => "Creating nagios directory",
classes => if_repaired("not_nagios_installed");
   commands:
  not_nagios_installed::
"/bin/tar xzvf /var/cfengine/artifacts/nagios/nagios.tar.gz 
-C /",
comment => "Going to install Nagios now.";
}
body classes if_repaired(class)
{
promise_repaired => { "$(class)" };
}




bernd.adamow...@external.icw-global.com wrote:
>
> I guess I'm facing a typical beginners problem, however, I didn't find 
> a solution.
>
> I'm checking the existence of a directory. If it's not there, I'm 
> going to extract a tarball which creates it and some other files. This 
> works very fine. However the extracting of the tarball is done 
> sometimes too, even if the directory exists. I couldn't find a 
> deterministic behaviour. Here's the code I'm using:
>
> bundle agent check_nagios_installation {
>
> classes:
> "nagios_installed" expression => 
> fileexists("${nagios_install_dir}/.");
>
> commands:
> !nagios_installed::
> "/bin/tar xzvf 
> /var/cfengine/artifacts/nagios/nagios.tar.gz -C /",
> comment => "Going to install Nagios now.";
> }
>
> Thanks in advance!
>
> Bernd
> InterComponentWare AG:
> Vorstand: Jörg Stadler / Aufsichtsratsvors.: Prof. Dr. Christof Hettich
> Firmensitz: 69190 Walldorf, Industriestraße 41 / AG Mannheim HRB 
> 351761 / USt.-IdNr.: DE 198388516
> 
>
> ___
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine
> 






InterComponentWare AG:  
Vorstand: Jörg Stadler / Aufsichtsratsvors.: Prof. Dr. Christof Hettich  
Firmensitz: 69190 Walldorf, Industriestraße 41 / AG Mannheim HRB 351761 / 
USt.-IdNr.: DE 198388516  ___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: Problem recognizing existence of directory

2009-12-17 Thread NWatson
Verbose output might be better than debug output for discovering faults. 
Also it might be more efficient to have CF copy the files recursively than 
copying a tar ball and then extracting it.  You'll have greater 
reliability too as CF will log any problems during the copy.

Sincerely,
--
Neil Watson
416-673-3465


CONFIDENTIALITY WARNING 
This communication, including any attachments, is for the exclusive use of 
addressee and may contain proprietary and/or confidential information. If you 
are not the intended recipient, any use, copying, disclosure, dissemination or 
distribution is strictly prohibited. If you are not the intended recipient, 
please notify the sender immediately by return e-mail, delete this 
communication and destroy all copies.

AVERTISSEMENT RELATIF À LA CONFIDENTIALITÉ 
Ce message, ainsi que les pièces qui y sont jointes, est destiné à l’usage 
exclusif de la personne à laquelle il s’adresse et peut contenir de 
l’information personnelle ou confidentielle. Si le lecteur de ce message n’en 
est pas le destinataire, nous l’avisons par la présente que toute diffusion, 
distribution, reproduction ou utilisation de son contenu est strictement 
interdite. Veuillez avertir sur-le-champ l’expéditeur par retour de courrier 
électronique et supprimez ce message ainsi que toutes les pièces jointes.
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: Problem recognizing existence of directory

2009-12-17 Thread bernd . adamowicz
Following your advice concerning copying instead of extracting a tarbal I 
have implemented this:

158 bundle agent check_nagios_installation {
159
160 files:
161 "/usr/local/nagios/."
162 comment => "Creating Nagios installation",
163 depth_search => recurse("inf"),
164 action => immediate,
165 copy_from => 
nagios_copy("/var/cfengine/artifacts/nagios","localhost");
166 }
167
168 body copy_from nagios_copy(from,server) {
169
170 servers => {"${server}"};
171 source  => "$(from)";
172 compare => "digest";
173 verify  => "true";
174 copy_backup => "timestamp";
175 force_update => "true";
176 purge => "true";
177 }

After two different approaches this third one now seems to be a reliable 
solution. Insofar my problem is solved. Thanks to all for helping.

However I've encountered so many situations right now with CF3 where the 
behaviour was not as expected at all. Im working with CF3 for about 6 
weeks now and still feel like a first day novice. It's a little 
frustrating to need so much time and effort for such small problems. I 
know CF3 is a good and helpfull tool, but it's too hard to work with.

Bernd







From:
nwat...@symcor.com
To:
bernd.adamow...@external.icw-global.com
Cc:
Nicolas Charles , help-cfengine@cfengine.org, 
help-cfengine-boun...@cfengine.org
Date:
17.12.2009 14:39
Subject:
Re: Problem recognizing existence of directory



Verbose output might be better than debug output for discovering faults. 
Also it might be more efficient to have CF copy the files recursively than 

copying a tar ball and then extracting it.  You'll have greater 
reliability too as CF will log any problems during the copy.

Sincerely,
--
Neil Watson
416-673-3465


CONFIDENTIALITY WARNING 
This communication, including any attachments, is for the exclusive use of 
addressee and may contain proprietary and/or confidential information. If 
you are not the intended recipient, any use, copying, disclosure, 
dissemination or distribution is strictly prohibited. If you are not the 
intended recipient, please notify the sender immediately by return e-mail, 
delete this communication and destroy all copies.

AVERTISSEMENT RELATIF À LA CONFIDENTIALITÉ 
Ce message, ainsi que les pièces qui y sont jointes, est destiné à l?usage 
exclusif de la personne à laquelle il s?adresse et peut contenir de 
l?information personnelle ou confidentielle. Si le lecteur de ce message 
n?en est pas le destinataire, nous l?avisons par la présente que toute 
diffusion, distribution, reproduction ou utilisation de son contenu est 
strictement interdite. Veuillez avertir sur-le-champ l?expéditeur par 
retour de courrier électronique et supprimez ce message ainsi que toutes 
les pièces jointes.





InterComponentWare AG:  
Vorstand: Jörg Stadler / Aufsichtsratsvors.: Prof. Dr. Christof Hettich  
Firmensitz: 69190 Walldorf, Industriestraße 41 / AG Mannheim HRB 351761 / 
USt.-IdNr.: DE 198388516  ___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


warnings promise classes

2009-12-17 Thread NWatson
Perhaps I'm misunderstanding but it seems to me that warning actions are 
outside of the normal promise classes.  It would be nice if instead they 
were a fourth class.  For example consider this promise.

files: 

any::
"/tmp/foo"
action => warn_now,
perms => system( 
"0600",
"nwatson",
"bin"
),
classes => cdefine(
"/tmp/foo_kept",
"/tmp/foo_repaired",
"/tmp/foo_failed"
);

Using this I can nicely log if the promise is kept, repaired or not kept. 
However, this particular promise is supposed to be passive or warn only. 
Warnings seem to happen outside of any control.  That is they 
automatically log fixed strings with a '!!' prefix.  What if instead these 
acted differently?  I see two possibilities.

First a warning only action defines another class meaning that the promise 
needs to be repaired but only a warning was issued.
 
classes => cdefine(
  "/tmp/foo_warning",
"/tmp/foo_kept",
"/tmp/foo_repaired",
"/tmp/foo_failed"
);

The other option would be to keep the existing three possible classes and 
define the failed class when in warning mode.  Since the promise was not 
kept a failure to keep the promise seems logical.

Is there a way to do this that I haven't seen? 

Sincerely,
--
Neil Watson
416-673-3465


CONFIDENTIALITY WARNING 
This communication, including any attachments, is for the exclusive use of 
addressee and may contain proprietary and/or confidential information. If you 
are not the intended recipient, any use, copying, disclosure, dissemination or 
distribution is strictly prohibited. If you are not the intended recipient, 
please notify the sender immediately by return e-mail, delete this 
communication and destroy all copies.

AVERTISSEMENT RELATIF À LA CONFIDENTIALITÉ 
Ce message, ainsi que les pièces qui y sont jointes, est destiné à l’usage 
exclusif de la personne à laquelle il s’adresse et peut contenir de 
l’information personnelle ou confidentielle. Si le lecteur de ce message n’en 
est pas le destinataire, nous l’avisons par la présente que toute diffusion, 
distribution, reproduction ou utilisation de son contenu est strictement 
interdite. Veuillez avertir sur-le-champ l’expéditeur par retour de courrier 
électronique et supprimez ce message ainsi que toutes les pièces jointes.
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: Problem recognizing existence of directory

2009-12-17 Thread NWatson
We've all been or are still there.  CF's promise theory offers a different 
way of thinking.  It's takes some time to adjust to it.  Think of it like 
calculus.  For a while your brain just explodes but, eventually it starts 
to make sense. 

Sincerely,
--
Neil Watson
416-673-3465


CONFIDENTIALITY WARNING 
This communication, including any attachments, is for the exclusive use of 
addressee and may contain proprietary and/or confidential information. If you 
are not the intended recipient, any use, copying, disclosure, dissemination or 
distribution is strictly prohibited. If you are not the intended recipient, 
please notify the sender immediately by return e-mail, delete this 
communication and destroy all copies.

AVERTISSEMENT RELATIF À LA CONFIDENTIALITÉ 
Ce message, ainsi que les pièces qui y sont jointes, est destiné à l’usage 
exclusif de la personne à laquelle il s’adresse et peut contenir de 
l’information personnelle ou confidentielle. Si le lecteur de ce message n’en 
est pas le destinataire, nous l’avisons par la présente que toute diffusion, 
distribution, reproduction ou utilisation de son contenu est strictement 
interdite. Veuillez avertir sur-le-champ l’expéditeur par retour de courrier 
électronique et supprimez ce message ainsi que toutes les pièces jointes.
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: Problem recognizing existence of directory

2009-12-17 Thread Brendan Strejcek
Regarding your original case, it would be more natural to use isdir()
rather than fileexists() (though both should work). I can't replicate
any problems with either isdir() or fileexists() though. I also tried
interpolating a variable into the path checked for, because that seems
like a likely place that an order bug could creep in, but that did not
give me any problems either.

$ cat .cfagent/inputs/promises.cf
body common control { bundlesequence  => { 'example' }; }
bundle agent example {
classes:
any::
'asdf' expression => isdir('/tmp/asdf');
commands:
!asdf::
'/bin/echo some command';
}
$ file /tmp/asdf
/tmp/asdf: directory
$ /usr/sbin/cf-agent -K
$ rmdir /tmp/asdf
$ /usr/sbin/cf-agent -K
Q: ".../bin/echo some ": some command
I: Last 1 QUOTEed lines were generated by promiser "/bin/echo some command"
I: Made in version 'not specified' of
'/home/brendan/.cfagent/inputs/promises.cf' near line 8
$

On Thu, Dec 17, 2009 at 6:54 AM,
 wrote:
>
> I guess I'm facing a typical beginners problem, however, I didn't find a
> solution.
>
> I'm checking the existence of a directory. If it's not there, I'm going to
> extract a tarball which creates it and some other files. This works very
> fine. However the extracting of the tarball is done sometimes too, even if
> the directory exists. I couldn't find a deterministic behaviour. Here's the
> code I'm using:
>
> bundle agent check_nagios_installation {
>
>     classes:
>         "nagios_installed" expression =>
> fileexists("${nagios_install_dir}/.");
>
>     commands:
>         !nagios_installed::
>             "/bin/tar xzvf /var/cfengine/artifacts/nagios/nagios.tar.gz -C
> /",
>                 comment => "Going to install Nagios now.";
> }
>
> Thanks in advance!
>
> Bernd
> InterComponentWare AG:
> Vorstand: Jörg Stadler / Aufsichtsratsvors.: Prof. Dr. Christof Hettich
> Firmensitz: 69190 Walldorf, Industriestraße 41 / AG Mannheim HRB 351761 /
> USt.-IdNr.: DE 198388516
> ___
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine
>
>
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: Problem recognizing existence of directory

2009-12-17 Thread Brendan Strejcek
This is reliable, but not very efficient. It requires at least 2N file
checksum calculations (where N is the number of files in the tree
being copied or verified) on every pass. You are also using 2N space,
since you are storing a copy in ${sys.workdir} to compare against.

Another suggestion: use your operating system's package manager to
package Nagios, and then use Cfengine to install the package. That
would also probably result in an end system that is not as confusing
for an admin that is not familiar with Cfengine.

I think more community examples would go a long way to helping the
initial learning curve. We are working on that, so stay tuned.

On Thu, Dec 17, 2009 at 9:36 AM,
 wrote:
>
> Following your advice concerning copying instead of extracting a tarbal I 
> have implemented this:
>
> 158 bundle agent check_nagios_installation {
> 159
> 160     files:
> 161         "/usr/local/nagios/."
> 162             comment => "Creating Nagios installation",
> 163             depth_search => recurse("inf"),
> 164             action => immediate,
> 165             copy_from => 
> nagios_copy("/var/cfengine/artifacts/nagios","localhost");
> 166 }
> 167
> 168 body copy_from nagios_copy(from,server) {
> 169
> 170     servers     => {"${server}"};
> 171     source      => "$(from)";
> 172     compare     => "digest";
> 173     verify      => "true";
> 174     copy_backup => "timestamp";
> 175     force_update => "true";
> 176     purge => "true";
> 177 }
>
> After two different approaches this third one now seems to be a reliable 
> solution. Insofar my problem is solved. Thanks to all for helping.
>
> However I've encountered so many situations right now with CF3 where the 
> behaviour was not as expected at all. Im working with CF3 for about 6 weeks 
> now and still feel like a first day novice. It's a little frustrating to need 
> so much time and effort for such small problems. I know CF3 is a good and 
> helpfull tool, but it's too hard to work with.
>
> Bernd
>
>
>
>
>
>
> From:nwat...@symcor.com
> To:
> bernd.adamow...@external.icw-global.com
> Cc:Nicolas Charles , help-cfengine@cfengine.org, 
> help-cfengine-boun...@cfengine.org
> Date:17.12.2009 14:39
> Subject:Re: Problem recognizing existence of directory
> 
>
>
> Verbose output might be better than debug output for discovering faults.
> Also it might be more efficient to have CF copy the files recursively than
> copying a tar ball and then extracting it.  You'll have greater
> reliability too as CF will log any problems during the copy.
>
> Sincerely,
> --
> Neil Watson
> 416-673-3465
>
>
> CONFIDENTIALITY WARNING
> This communication, including any attachments, is for the exclusive use of 
> addressee and may contain proprietary and/or confidential information. If you 
> are not the intended recipient, any use, copying, disclosure, dissemination 
> or distribution is strictly prohibited. If you are not the intended 
> recipient, please notify the sender immediately by return e-mail, delete this 
> communication and destroy all copies.
>
> AVERTISSEMENT RELATIF À LA CONFIDENTIALITÉ
> Ce message, ainsi que les pièces qui y sont jointes, est destiné à l’usage 
> exclusif de la personne à laquelle il s’adresse et peut contenir de 
> l’information personnelle ou confidentielle. Si le lecteur de ce message n’en 
> est pas le destinataire, nous l’avisons par la présente que toute diffusion, 
> distribution, reproduction ou utilisation de son contenu est strictement 
> interdite. Veuillez avertir sur-le-champ l’expéditeur par retour de courrier 
> électronique et supprimez ce message ainsi que toutes les pièces jointes.
>
>
>
> InterComponentWare AG:
> Vorstand: Jörg Stadler / Aufsichtsratsvors.: Prof. Dr. Christof Hettich
> Firmensitz: 69190 Walldorf, Industriestraße 41 / AG Mannheim HRB 351761 / 
> USt.-IdNr.: DE 198388516
> ___
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine
>
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: Problem recognizing existence of directory

2009-12-17 Thread NWatson
Brendan Strejcek  wrote on 2009-12-17 10:44:35:

> This is reliable, but not very efficient. It requires at least 2N file
> checksum calculations (where N is the number of files in the tree
> being copied or verified) on every pass. You are also using 2N space,
> since you are storing a copy in ${sys.workdir} to compare against.

One could skip the localhost copy source and instead copy from the policy 
host to the final destination of /usr/local/.  Packaging is also a good 
idea
as suggested by Brendan assuming infrastructure and resources are 
available.

Sincerely,
--
Neil Watson
416-673-3465


CONFIDENTIALITY WARNING 
This communication, including any attachments, is for the exclusive use of 
addressee and may contain proprietary and/or confidential information. If you 
are not the intended recipient, any use, copying, disclosure, dissemination or 
distribution is strictly prohibited. If you are not the intended recipient, 
please notify the sender immediately by return e-mail, delete this 
communication and destroy all copies.

AVERTISSEMENT RELATIF À LA CONFIDENTIALITÉ 
Ce message, ainsi que les pièces qui y sont jointes, est destiné à l’usage 
exclusif de la personne à laquelle il s’adresse et peut contenir de 
l’information personnelle ou confidentielle. Si le lecteur de ce message n’en 
est pas le destinataire, nous l’avisons par la présente que toute diffusion, 
distribution, reproduction ou utilisation de son contenu est strictement 
interdite. Veuillez avertir sur-le-champ l’expéditeur par retour de courrier 
électronique et supprimez ce message ainsi que toutes les pièces jointes.
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


List iteration within parameterized bundles

2009-12-17 Thread Bryan Ramirez
Here's a very simple example of something that looks like it should work
and doesn't.  My question is should I find a different way of doing
this, or should this work?

This will just put "server 10.90.34.15" into the file, but not the other
line.

bundle agent ntp {

 vars:
 "ntpservers" slist => { "10.90.34.15", "10.91.34.15" };

 files:
 "/etc/ntp.conf"
edit_line => appendifnosuchline("server $(ntpservers)");
}

bundle edit_line appendifnosuchline(line) {
 insert_lines:
 "$(line)";
}
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: List iteration within parameterized bundles

2009-12-17 Thread Mark Burgess


See

http://www.cfengine.org/manuals/cf3-reference.html#List-variable-substitution-and-expansion

Bryan Ramirez wrote:
> Here's a very simple example of something that looks like it should work
> and doesn't.  My question is should I find a different way of doing
> this, or should this work?
> 
> This will just put "server 10.90.34.15" into the file, but not the other
> line.
> 
> bundle agent ntp {
> 
>  vars:
>  "ntpservers" slist => { "10.90.34.15", "10.91.34.15" };
> 
>  files:
>  "/etc/ntp.conf"
>   edit_line => appendifnosuchline("server $(ntpservers)");
> }
> 
> bundle edit_line appendifnosuchline(line) {
>  insert_lines:
>  "$(line)";
> }
> ___
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine

-- 
Mark Burgess

-
Professor of Network and System Administration
Oslo University College, Norway

Personal Web: http://www.iu.hio.no/~mark
Office Telf : +47 22453272
-
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: List iteration within parameterized bundles

2009-12-17 Thread NWatson
You can pass the entire list for greater efficiency.
...
files: 

redhat|suse|sunos_5_10::

"${crontabs}/root"
comment => "Added cron jobs to table.",
edit_line => AppendIfNoLine("@{cron.root_cron_lines}");
}

bundle edit_line AppendIfNoLine(line) {
insert_lines:
"${line}" location => "append";
}

body location append {
before_after => "after";
}

Sincerely,
--
Neil Watson
416-673-3465


CONFIDENTIALITY WARNING 
This communication, including any attachments, is for the exclusive use of 
addressee and may contain proprietary and/or confidential information. If you 
are not the intended recipient, any use, copying, disclosure, dissemination or 
distribution is strictly prohibited. If you are not the intended recipient, 
please notify the sender immediately by return e-mail, delete this 
communication and destroy all copies.

AVERTISSEMENT RELATIF À LA CONFIDENTIALITÉ 
Ce message, ainsi que les pièces qui y sont jointes, est destiné à l’usage 
exclusif de la personne à laquelle il s’adresse et peut contenir de 
l’information personnelle ou confidentielle. Si le lecteur de ce message n’en 
est pas le destinataire, nous l’avisons par la présente que toute diffusion, 
distribution, reproduction ou utilisation de son contenu est strictement 
interdite. Veuillez avertir sur-le-champ l’expéditeur par retour de courrier 
électronique et supprimez ce message ainsi que toutes les pièces jointes.
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: Solaris packages

2009-12-17 Thread Mark Burgess

Simon,

I checked with my guys now, and they claim the standard solaris packages body 
works ok
with solaris 10 (see the one in tests/units)

M

Simon Barrett wrote:
> I'm using Solaris 10 5/09 with standard Solaris pkgadd, pkginfo commands.
> 
> Many Thanks,
> 
> Simon
> 
> 
> 
> 2009/11/12 Mark Burgess  >
> 
> 
> Tell us what kind of solaris you are using, and which package
> manager and we can look into it.
> 
> M
> 
> Simon Barrett wrote:
> > Thanks. I pulled down trunk 615 and compiled it. Is that the latest?
> > Sorry, I not familiar with subversion.
> >
> > I still get the same error if I try and use "package_multiline_start"
> >
> > # ./cf-agent -KI -b packages
> > cf3:/var/cfengine/inputs/packages.cf:33 
> ,53:
> > Constraint lvalue package_multiline_start is not allowed in
> > 'package_method' constraint body, near token '\s*PKGINST:\s+[^\s]+"'
> > Summarizing promises as text to /var/cfengine/inputs/promises.cf.txt
> > Summarizing promises as html to /var/cfengine/inputs/promises.cf.html
> > cf-agent was not able to get confirmation of promises from
> cf-promises,
> > so going to failsafe
> >  >> Using command line specified bundlesequence
> > Bundle "packages" listed in the bundlesequence was not found
> > Fatal cfengine error: Errors in agent bundles
> >
> > If I comment it out, I still don't get a match on my package name or
> > version.
> >
> > cf-agent -V shows this:
> >
> > # ./cf-agent -V
> > This comprises cf-agent core community version 3.0.3 - (C)
> Cfengine AS 2008-
> >
> > Is there a different version I should try?
> >
> > Many thanks for your help,
> >
> > Simon
> >
> >
> >
> > 2009/11/12 Mark Burgess  
> > >>
> >
> >
> > You probably need to upgrade to one of the svn versions of
> cfengine 3.
> > 3.0.2 does not contain the solaris patches
> >
> > M
> >
> > Simon Barrett wrote:
> > > I have a bundle defined for installation of the SUNWsneep
> package (see
> > > below). Whenever I run it the package is re-installed. For
> some reason
> > > it is not picking up the installed version. The supplied
> "pkginfo -l"
> > > will provide multiline output but when I uncomment the
> > > "package_multiline_start" below, I get:
> > >
> > > "Constraint lvalue package_multiline_start is not allowed in
> > > 'package_method' constraint body, near token
> '\s*PKGINST:\s+[^\s]+"'"
> > >
> > > Can anyone point me in the right direction on using packages
> with
> > Solaris?
> > >
> > > The cf-agent output is as follows:
> > >
> > >  
> ???
> > >   Reading package list from /usr/bin/pkginfo
> > >  
> ???
> > >   # Software reporting feature is only available in version Nova
> > and above
> > >   # Patch reporting feature is only available in version
> Nova and
> > above
> > >  
> ???
> > >Done checking packages and patches
> > >  
> ???
> > >   -> Looking for (SUNWsneep,*,*)
> > >   !! Unsatisfied constraints in promise (SUNWsneep,*,*)
> > >   -> Looking for (SUNWsneep,2.6,*)
> > >   !! Unsatisfied constraints in promise (SUNWsneep,2.6,*)
> > >   -> 0 package(s) matching the name "SUNWsneep" already
> installed
> > >   -> 0 package(s) match the promise body's criteria fully
> > >   -> Package promises to refer to itself as "SUNWsneep" to
> the manager
> > >   -> Schedule package for addition
> > >   >>
> > > Offering these package-promise suggestions to the managers
> > >   >>
> > >   -> Deletion schedule...
> > >   -> Addition schedule...
> > >  Execute scheduled package addition
> > >  Command prefix: /usr/sbin/pkgadd -n -a
> /tmp/cfengine_admin_file -r
> > > /tmp/SUNWsneep.response -d /tmp/SUNWsneep.pkg
> > >  Executing /usr/sbin/pkgadd -n -a /tmp/cfengine_admin_file -r
> > /tmp/SUNW...
> > >  Q:pkgadd -n -a /tmp/cf ...:
> > >  Q:pkgadd -n -a /tmp/cf ...:This appears to be an attempt to
> > install the
> > > same architecture and
> >

Updating Solaris cfengine binaries

2009-12-17 Thread Justin Lloyd
I have a theoretical question regarding updates of cfengine binaries on
Solaris systems. I've not tested this yet, so I'm just looking for
comments from anyone who has experience with this. If cfengine is
installed as a package, when cfengine pulls updated binaries from the
policy server, that would screw up the local package database (i.e.
/var/sadm/install/contents) due to differing checksums. On the other
hand, you can't have cfengine do a package uninstall then reinstall
since the uninstall would wipe out the binaries trying to do the update.
(At least Linux can do rpm updates. I've always hated Solaris packages
and patches.)

 

Is my assessment correct or am I missing something?

 

Thanks,

Justin

 


This electronic communication and any attachments may contain confidential and 
proprietary 
information of DigitalGlobe, Inc. If you are not the intended recipient, or an 
agent or employee 
responsible for delivering this communication to the intended recipient, or if 
you have received 
this communication in error, please do not print, copy, retransmit, disseminate 
or 
otherwise use the information. Please indicate to the sender that you have 
received this 
communication in error, and delete the copy you received. DigitalGlobe reserves 
the 
right to monitor any electronic communication sent or received by its 
employees, agents 
or representatives.

___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: List iteration within parameterized bundles

2009-12-17 Thread Bryan Ramirez
This was the approach I was going to try next.  I just didn't know if
what I did should work.

Thanks,
Bryan

On Thu, 17 Dec 2009 nwat...@symcor.com wrote:

> Date: Thu, 17 Dec 2009 11:04:44 -0500
> From: nwat...@symcor.com
> To: Bryan Ramirez 
> Cc: help-cfengine@cfengine.org, help-cfengine-boun...@cfengine.org
> Subject: Re: List iteration within parameterized bundles
> 
> You can pass the entire list for greater efficiency.
> ...
>files:
>
>redhat|suse|sunos_5_10::
>
>"${crontabs}/root"
>comment => "Added cron jobs to table.",
>edit_line => AppendIfNoLine("@{cron.root_cron_lines}");
> }
>
> bundle edit_line AppendIfNoLine(line) {
>insert_lines:
>"${line}" location => "append";
> }
>
> body location append {
>before_after => "after";
> }
>
> Sincerely,
> --
> Neil Watson
> 416-673-3465
>
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: List iteration within parameterized bundles

2009-12-17 Thread NWatson
See this earlier thread.
https://cfengine.org/pipermail/help-cfengine/2009-December/006742.html

Sincerely,
--
Neil Watson
416-673-3465


CONFIDENTIALITY WARNING 
This communication, including any attachments, is for the exclusive use of 
addressee and may contain proprietary and/or confidential information. If you 
are not the intended recipient, any use, copying, disclosure, dissemination or 
distribution is strictly prohibited. If you are not the intended recipient, 
please notify the sender immediately by return e-mail, delete this 
communication and destroy all copies.

AVERTISSEMENT RELATIF À LA CONFIDENTIALITÉ 
Ce message, ainsi que les pièces qui y sont jointes, est destiné à l’usage 
exclusif de la personne à laquelle il s’adresse et peut contenir de 
l’information personnelle ou confidentielle. Si le lecteur de ce message n’en 
est pas le destinataire, nous l’avisons par la présente que toute diffusion, 
distribution, reproduction ou utilisation de son contenu est strictement 
interdite. Veuillez avertir sur-le-champ l’expéditeur par retour de courrier 
électronique et supprimez ce message ainsi que toutes les pièces jointes.
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: Updating Solaris cfengine binaries

2009-12-17 Thread Brendan Strejcek
This is something that you will need to test on a spare box, but I
think you are correct that the Solaris package manager would get in
the way.

You could use Cfengine to schedule an at or cron job to do the upgrade.

On Thu, Dec 17, 2009 at 11:43 AM, Justin Lloyd  wrote:
> I have a theoretical question regarding updates of cfengine binaries on
> Solaris systems. I’ve not tested this yet, so I’m just looking for comments
> from anyone who has experience with this. If cfengine is installed as a
> package, when cfengine pulls updated binaries from the policy server, that
> would screw up the local package database (i.e. /var/sadm/install/contents)
> due to differing checksums. On the other hand, you can’t have cfengine do a
> package uninstall then reinstall since the uninstall would wipe out the
> binaries trying to do the update. (At least Linux can do rpm updates. I’ve
> always hated Solaris packages and patches.)
>
>
>
> Is my assessment correct or am I missing something?
>
>
>
> Thanks,
>
> Justin
>
>
>
> This electronic communication and any attachments may contain confidential
> and proprietary
> information of DigitalGlobe, Inc. If you are not the intended recipient, or
> an agent or employee
> responsible for delivering this communication to the intended recipient, or
> if you have received
> this communication in error, please do not print, copy, retransmit,
> disseminate or
> otherwise use the information. Please indicate to the sender that you have
> received this
> communication in error, and delete the copy you received. DigitalGlobe
> reserves the
> right to monitor any electronic communication sent or received by its
> employees, agents
> or representatives.
>
> ___
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine
>
>
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: Updating Solaris cfengine binaries

2009-12-17 Thread NWatson
If I understand you correctly you have a problem with two masters.   CF is 
updating binaries but so is the Solaris package manager.  Only one service 
should be in charge of keeping CF binaries up to date.  Either is fine but 
be consistent.

Sincerely,
--
Neil Watson
416-673-3465


CONFIDENTIALITY WARNING 
This communication, including any attachments, is for the exclusive use of 
addressee and may contain proprietary and/or confidential information. If you 
are not the intended recipient, any use, copying, disclosure, dissemination or 
distribution is strictly prohibited. If you are not the intended recipient, 
please notify the sender immediately by return e-mail, delete this 
communication and destroy all copies.

AVERTISSEMENT RELATIF À LA CONFIDENTIALITÉ 
Ce message, ainsi que les pièces qui y sont jointes, est destiné à l’usage 
exclusif de la personne à laquelle il s’adresse et peut contenir de 
l’information personnelle ou confidentielle. Si le lecteur de ce message n’en 
est pas le destinataire, nous l’avisons par la présente que toute diffusion, 
distribution, reproduction ou utilisation de son contenu est strictement 
interdite. Veuillez avertir sur-le-champ l’expéditeur par retour de courrier 
électronique et supprimez ce message ainsi que toutes les pièces jointes.
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Setting perms based on server copy?

2009-12-17 Thread Jessica Greer
I could have sworn I read or heard that cf3 would allow for permissions on a
file copy to
be set to match the permissions on the master copy.

I don't see that in the latest manual, though, and I could argue it
impinges, to some
degree, on agent autonomy - so maybe this was wishful thinking on my part?
It would be so
useful for directories containing many files of varying permission settings.

-Jess

~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
Jessica Greer  greer at cs.virginia.edu
Computer Systems Engineer Olsson Hall, rm. 113D
Dept. of Computer ScienceUniversity of Virginia
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: Setting perms based on server copy?

2009-12-17 Thread NWatson
http://www.cfengine.org/manuals/cf3-reference.html#copy_005ffrom-in-files
'preserve'

You are correct however that trusting the perms on the source file is not 
ideal.

Sincerely,
--
Neil Watson
416-673-3465


CONFIDENTIALITY WARNING 
This communication, including any attachments, is for the exclusive use of 
addressee and may contain proprietary and/or confidential information. If you 
are not the intended recipient, any use, copying, disclosure, dissemination or 
distribution is strictly prohibited. If you are not the intended recipient, 
please notify the sender immediately by return e-mail, delete this 
communication and destroy all copies.

AVERTISSEMENT RELATIF À LA CONFIDENTIALITÉ 
Ce message, ainsi que les pièces qui y sont jointes, est destiné à l’usage 
exclusif de la personne à laquelle il s’adresse et peut contenir de 
l’information personnelle ou confidentielle. Si le lecteur de ce message n’en 
est pas le destinataire, nous l’avisons par la présente que toute diffusion, 
distribution, reproduction ou utilisation de son contenu est strictement 
interdite. Veuillez avertir sur-le-champ l’expéditeur par retour de courrier 
électronique et supprimez ce message ainsi que toutes les pièces jointes.
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


RE: Updating Solaris cfengine binaries

2009-12-17 Thread Justin Lloyd
Yes, that's the basic problem. I don't see how it's possible to use Cfengine's 
package management facility to handle updating the Solaris Cfengine package, 
given there's no package update/upgrade command on Solaris, only pkgrm and 
pkgadd. Thus you'd have to have it remove the current package to install the 
new one, wiping out the binaries that are actually performing the upgrade in 
the process. Linux is simpler, given the -U update option to the rpm command. 
Thus, if Cfengine is deployed to Solaris hosts with a package, as is done with 
Nova, and subsequent binary updates are done via the standard update.cf, that 
is going to "break" the Solaris package database.

Justin


-Original Message-
From: nwat...@symcor.com [mailto:nwat...@symcor.com] 
Sent: Thursday, December 17, 2009 12:16 PM
To: Justin Lloyd
Cc: help-cfengine; help-cfengine-boun...@cfengine.org
Subject: Re: Updating Solaris cfengine binaries

If I understand you correctly you have a problem with two masters.   CF is 
updating binaries but so is the Solaris package manager.  Only one service 
should be in charge of keeping CF binaries up to date.  Either is fine but be 
consistent.

Sincerely,
--
Neil Watson
416-673-3465

This electronic communication and any attachments may contain confidential and 
proprietary 
information of DigitalGlobe, Inc. If you are not the intended recipient, or an 
agent or employee 
responsible for delivering this communication to the intended recipient, or if 
you have received 
this communication in error, please do not print, copy, retransmit, disseminate 
or 
otherwise use the information. Please indicate to the sender that you have 
received this 
communication in error, and delete the copy you received. DigitalGlobe reserves 
the 
right to monitor any electronic communication sent or received by its 
employees, agents 
or representatives.

___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


What means tidy in dirlinks on the delete body?

2009-12-17 Thread Jean-Noël Rivasseau
Hello, there are three options for dirlinks: delete, keep and tidy. What
means tidy? This is not explained in the manual; please update the manual
accordingly.

-- 
Jean-Noël Rivasseau
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Uncommenting in cf3?

2009-12-17 Thread Jessica Greer
Can I get examples of uncommenting lines from other cf3 users?

Commenting is straightforward with replace_with, but uncommenting seems
non-trivial.  I thought about using getfields(), using my comment character
as a delimiter, to stuff the remainder of the line into a variable I could
then use with replace_with.  The getfields() function doesn't seem to be
implemented, though (no matter; it was a messy solution anyhow).

I could delete the commented line and replaced with an uncommented one - is
that what others are doing, or am I missing a simpler way?

Thanks,
-Jess
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: Uncommenting in cf3?

2009-12-17 Thread Michael Potter
actually it is very trivial.

just use a regular expression to match the part of the string excluding the
comment, and then replace the string with $(match.1)

i.e. if a commented line was:

# username=password

You could use a regex like:

#\s+(.*)

And replace it with

$(match.1)

to get

username=password

I think I have a generic function called replace_with_first_match for this
kind of thing

On Fri, Dec 18, 2009 at 2:08 PM, Jessica Greer wrote:

> Can I get examples of uncommenting lines from other cf3 users?
>
> Commenting is straightforward with replace_with, but uncommenting seems
> non-trivial.  I thought about using getfields(), using my comment character
> as a delimiter, to stuff the remainder of the line into a variable I could
> then use with replace_with.  The getfields() function doesn't seem to be
> implemented, though (no matter; it was a messy solution anyhow).
>
> I could delete the commented line and replaced with an uncommented one - is
> that what others are doing, or am I missing a simpler way?
>
> Thanks,
> -Jess
>
>
> ___
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine
>
>
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine


Re: Uncommenting in cf3?

2009-12-17 Thread Mark Burgess
Jessica, try this...

##
#
# Uncomment lines
#
##

body common control

{
version => "1.2.3";
bundlesequence  => { "testbundle"  };
}

# try this on some test data like

# one
# two
# mark one
#mark two



bundle agent testbundle

{
files:

  "/home/mark/tmp/comment_test"

   create=> "true",
   edit_line => uncomment_lines_matching("\s*mark.*","#");
}



bundle edit_line uncomment_lines_matching(regex,comment)
{
replace_patterns:

 "#($(regex))$" replace_with => uncomment;
}



body replace_with uncomment
{
replace_value => "$(match.1)";
occurrences => "all";
}



Jessica Greer wrote:
> Can I get examples of uncommenting lines from other cf3 users? 
> 
> Commenting is straightforward with replace_with, but uncommenting seems
> non-trivial.  I thought about using getfields(), using my comment
> character as a delimiter, to stuff the remainder of the line into a
> variable I could then use with replace_with.  The getfields() function
> doesn't seem to be implemented, though (no matter; it was a messy
> solution anyhow).
> 
> I could delete the commented line and replaced with an uncommented one -
> is that what others are doing, or am I missing a simpler way?
> 
> Thanks,
> -Jess
> 
> 
> 
> 
> ___
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine

-- 
Mark Burgess

-
Professor of Network and System Administration
Oslo University College, Norway

Personal Web: http://www.iu.hio.no/~mark
Office Telf : +47 22453272
-
___
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine