From MAILER-DAEMON Tue Aug 01 01:33:39 2006 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1G7mst-0004m3-NS for mharc-help-cfengine@gnu.org; Tue, 01 Aug 2006 01:33:39 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G7mss-0004lv-NC for help-cfengine@gnu.org; Tue, 01 Aug 2006 01:33:38 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G7msq-0004lP-VZ for help-cfengine@gnu.org; Tue, 01 Aug 2006 01:33:38 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G7msq-0004lM-T8 for help-cfengine@gnu.org; Tue, 01 Aug 2006 01:33:36 -0400 Received: from [158.36.161.27] (helo=mail-out.hio.no) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1G7mvf-00067I-CW for help-cfengine@gnu.org; Tue, 01 Aug 2006 01:36:31 -0400 Received: from [192.168.1.100] ([84.208.83.202]) (user=mark mech=CRAM-MD5 bits=0 port=587) by mail-out.hio.no (8.13.7/8.13.7) with ESMTP id k715XPZP023207 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 1 Aug 2006 07:33:26 +0200 Message-ID: <44CEE7A5.1080109@iu.hio.no> Date: Tue, 01 Aug 2006 07:33:25 +0200 From: Mark Burgess User-Agent: Mozilla Thunderbird 1.0.8 (X11/20060411) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jason Martin References: <20060724193714.GF16461@mal.toger.us> In-Reply-To: <20060724193714.GF16461@mal.toger.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: help-cfengine@gnu.org Subject: Re: Defining Classes based on hostname? X-BeenThere: help-cfengine@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for GNU cfengine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Aug 2006 05:33:38 -0000 Jason Martin wrote: > On Mon, Jul 24, 2006 at 03:32:23PM -0400, Brian E. Seppanen wrote: >> Is there a means of defining that a host with a specific hostname prefix >> will belong to a specific class? > SOMECLASS = ( Regcmp("^cd","${fqhost}") ) > > -Jason Martin > > > ------------------------------------------------------------------------ > > _______________________________________________ > Help-cfengine mailing list > Help-cfengine@gnu.org > http://lists.gnu.org/mailman/listinfo/help-cfengine Don't forget that regexs match the whole string, not just part of it, M From MAILER-DAEMON Tue Aug 01 12:37:12 2006 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1G7xF2-0007s7-3E for mharc-help-cfengine@gnu.org; Tue, 01 Aug 2006 12:37:12 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G7xEz-0007r8-R2 for help-cfengine@gnu.org; Tue, 01 Aug 2006 12:37:09 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G7xEy-0007qG-1W for help-cfengine@gnu.org; Tue, 01 Aug 2006 12:37:08 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G7xEx-0007q8-Pv for help-cfengine@gnu.org; Tue, 01 Aug 2006 12:37:07 -0400 Received: from [69.93.127.87] (helo=mal.toger.us) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1G7xHs-0008Du-Um for help-cfengine@gnu.org; Tue, 01 Aug 2006 12:40:09 -0400 Received: from mal.toger.us (localhost [127.0.0.1]) by mal.toger.us (Postfix) with ESMTP id A220C4229 for ; Tue, 1 Aug 2006 09:37:04 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; b=lWu1O6BL41LaRMx0ow1DfwA+S+xSgvhsoxHNKYY25Vt7QecYlcuSQHMzEqHfcHccGRk1vVNmJl41WzzvnzHpHoY4H7KXdXeyBwRKxsDXIZKKRGBNTgjaYJYmcxHE42noLZ/KIlIjNFEKJHsnToa4pa8Y+YoIJ5/2S8JVEVtw/Mk=; c=nofws; d=toger.us; q=dns; s=selector1 Received: by mal.toger.us (Postfix, from userid 1002) id 2AA184230; Tue, 1 Aug 2006 09:37:02 -0700 (PDT) Received: by mal.toger.us (tmda-sendmail, from uid 1002); Tue, 01 Aug 2006 09:37:00 -0700 (PDT) Date: Tue, 1 Aug 2006 09:36:59 -0700 To: Mark Burgess Message-ID: <20060801163659.GD19089@mal.toger.us> References: <20060724193714.GF16461@mal.toger.us> <44CEE7A5.1080109@iu.hio.no> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="FEz7ebHBGB6b2e8X" Content-Disposition: inline In-Reply-To: <44CEE7A5.1080109@iu.hio.no> User-Agent: Mutt/1.5.11 X-Delivery-Agent: TMDA/1.0.3 (Seattle Slew) From: Jason Martin Mail-Followup-To: Mark.Burgess@iu.hio.no, seppy@chartermi.net, help-cfengine@gnu.org Cc: help-cfengine@gnu.org Subject: Re: Defining Classes based on hostname? X-BeenThere: help-cfengine@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for GNU cfengine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Aug 2006 16:37:10 -0000 --FEz7ebHBGB6b2e8X Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 01, 2006 at 07:33:25AM +0200, Mark Burgess wrote: > Jason Martin wrote: > >SOMECLASS =3D ( Regcmp("^cd","${fqhost}") ) > Don't forget that regexs match the whole string, not just part of it, Yes, so it is important to use the appropriate anchros (^, $ and so on) to make sure you are matching just the portion of interest. -Jason Martin --=20 This message is PGP/MIME signed. --FEz7ebHBGB6b2e8X Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: --no-verbose iD8DBQFEz4MqeDShAkRw0YoRAoaAAJ9uIubig3yCKZSNRwKDxrq9afqjQACfQmoI mRtY2X6cXx3RRGZk4hdIVGU= =7pr8 -----END PGP SIGNATURE----- --FEz7ebHBGB6b2e8X-- From MAILER-DAEMON Sun Aug 06 19:40:16 2006 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1G9sEC-0002t6-In for mharc-help-cfengine@gnu.org; Sun, 06 Aug 2006 19:40:16 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G9sEB-0002rY-B1 for help-cfengine@gnu.org; Sun, 06 Aug 2006 19:40:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G9sEA-0002qb-Id for help-cfengine@gnu.org; Sun, 06 Aug 2006 19:40:14 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G9sEA-0002qQ-Ek for help-cfengine@gnu.org; Sun, 06 Aug 2006 19:40:14 -0400 Received: from [69.17.124.7] (helo=culain.madstop.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1G9sIH-00066O-EL for help-cfengine@gnu.org; Sun, 06 Aug 2006 19:44:29 -0400 Received: from [192.168.0.164] (unknown [192.168.0.164]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by culain.madstop.com (Postfix) with ESMTP id 00BD9EE783 for ; Sun, 6 Aug 2006 18:40:12 -0500 (CDT) Mime-Version: 1.0 (Apple Message framework v750) Content-Transfer-Encoding: 7bit Message-Id: Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: help-cfengine@gnu.org From: Luke Kanies Date: Sun, 6 Aug 2006 18:40:11 -0500 X-Mailer: Apple Mail (2.750) Subject: Puppet module for cfengine X-BeenThere: help-cfengine@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for GNU cfengine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Aug 2006 23:40:15 -0000 Hi all, There has been a module for using Puppet[1] from within Cfengine for a long time now, but I only just now got around to writing up a how- to on it: http://reductivelabs.com/projects/puppet/documentation/ cfengine_module.html Basically, you can reuse your existing class structure within Puppet, since the module will load all Puppet classes that are set within Cfengine. This is useful because Puppet supports many high-level types that are difficult to manage within Cfengine, like users, groups, and packages, and it also supports defined types that resemble functions but create first-class Puppet types. For instance, this is how I create the Apache configurations for my Trac sites: define tracsite(path = "/etc/apache2/trac", owner) { file { "trac-$name": path => "/etc/apache2/trac/$name.conf", owner => $owner, group => root, mode => 644, require => file[apacheconf], content => template("tracsite.erb"), notify => service[apache2] } symlink { "tracsym-$name": path => "/export/docroots/reductivelabs.com/cgi-bin/$name.cgi", ensure => "/usr/share/trac/cgi-bin/trac.cgi" } } Then I can call it as many times as I want: tracsite { puppet: owner => apache } This is actually an internal type that I use from within a larger definition that actually creates the Trac database and configuration; you can find it here: http://prmweb.hezmatt.org/recipes/show/4 Feel free to contact me with any questions, or you can join the user list[2] or #puppet in irc.freenode.net and look for me as lkanies (or 'laktop', sometimes). 1 - http://reductivelabs.com/projects/puppet 2 - https://mail.madstop.com/mailman/listinfo/puppet-users -- Luke Kanies http://madstop.com 615-594-8199 From MAILER-DAEMON Tue Aug 08 10:01:41 2006 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1GAS9N-0004Rg-4s for mharc-help-cfengine@gnu.org; Tue, 08 Aug 2006 10:01:41 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GAS9K-0004RY-UY for help-cfengine@gnu.org; Tue, 08 Aug 2006 10:01:39 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GAS9I-0004RM-Dn for help-cfengine@gnu.org; Tue, 08 Aug 2006 10:01:37 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GAS9I-0004RJ-9G for help-cfengine@gnu.org; Tue, 08 Aug 2006 10:01:36 -0400 Received: from [64.233.162.199] (helo=nz-out-0102.google.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GASDl-0000Uo-By for help-cfengine@gnu.org; Tue, 08 Aug 2006 10:06:13 -0400 Received: by nz-out-0102.google.com with SMTP id r28so265675nza for ; Tue, 08 Aug 2006 07:01:35 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=T22XerL7YKq66VxchUliIgLQxtAmxn1fHZdKb9l8uaFy0b5NS4fW9qiGIBcovMh9XqLeHXPGqM9gwn+9EQGrlouLbyajZpWI0V1dryoxCYWNsHz66gZjIGiImNEPXmfJRnXCCm6xH6EtYW28ipq1UiWHIGhos7T3XcmxHYMpamk= Received: by 10.64.204.3 with SMTP id b3mr6855678qbg; Tue, 08 Aug 2006 07:01:34 -0700 (PDT) Received: by 10.64.250.12 with HTTP; Tue, 8 Aug 2006 07:01:34 -0700 (PDT) Message-ID: <872c5faa0608080701lc6e3bd7gc38ab8765d4fc791@mail.gmail.com> Date: Tue, 8 Aug 2006 16:01:34 +0200 From: "John van Zantvoort" To: help-cfengine@gnu.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_5113_13446746.1155045694121" Subject: editfiles mistery X-BeenThere: help-cfengine@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for GNU cfengine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Aug 2006 14:01:39 -0000 ------=_Part_5113_13446746.1155045694121 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, I read http://cfwiki.org/cfwiki/index.php/Managing_Blocks_of_Code_with_Editfilesand tried it, with weird results This is the config: control: actionsequence = ( editfiles ) RCSFile = (ExecResult("/bin/sh -c \"echo \'$RCSfile: cf.redhat,v $\' | /usr/bin/cut -f2 -d\' \'\"")) RCSRev = (ExecResult("/bin/sh -c \"echo \'$Revision: 1.40 $\' | /usr/bin/cut -f2 -d\' \'\"")) EditHeader = ( 'CFEngine $(host) $(RCSFile)' ) editfiles: any:: { /etc/hosts AutoCreate Backup "single" LocateLineMatching "##### BEGIN $(EditHeader).*" BeginGroupIfNoMatch "##### BEGIN $(EditHeader) $(RCSRev)" DeleteToLineMatching "##### END $(EditHeader).*" DeleteNLines '1' EndGroup CatchAbort BeginGroupIfNoLineMatching "##### BEGIN $(EditHeader) $(RCSRev)" Append "##### BEGIN $(EditHeader) $(RCSRev)" Append "# mandatory loopback address" Append "127.0.0.1 localhost.localdomain localhost" Append "" Append "#####" Append "## revision: $(RCSRev)" Append "## file: $(RCSFile)" Append "##### END $(EditHeader) $(RCSRev)" EndGroup } And this the result: ##### BEGIN CFEngine hagar cf.redhat,v # mandatory loopback address 127.0.0.1 localhost.localdomain localhost ##### ## revision: ## file: cf.redhat,v ##### END CFEngine hagar cf.redhat,v I've been beating my head against this and can't figure out where is goes wrong. Any tips or hints are welcome. -- Met vriendelijke groeten/with kind regards John van Zantvoort --- Paranoia is simply an optimistic outlook on life. GCM d- s+:+ a- C+ UL+++ P+++ L++ E--- W++ N+ o K- w-- O- M- V- PS+ PE- Y+ PGP+ t+ 5 X- R- tv b+ DI++ D+ G e h- r++ y+ ------=_Part_5113_13446746.1155045694121 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi,

I read http://cfwiki.org/cfwiki/index.php/Managing_Blocks_of_Code_with_Editfiles and tried it, with weird results

This is the config:
control:
  actionsequence = ( editfiles )
  RCSFile        = (ExecResult("/bin/sh -c \"echo \'$RCSfile: cf.redhat,v $\' | /usr/bin/cut -f2 -d\' \'\""))
  RCSRev         = (ExecResult("/bin/sh -c \"echo \'$Revision: 1.40 $\' | /usr/bin/cut -f2 -d\' \'\""))
  EditHeader     = ( 'CFEngine $(host) $(RCSFile)' )
editfiles:
  any::
    { /etc/hosts
      AutoCreate
      Backup "single"
      LocateLineMatching "##### BEGIN $(EditHeader).*"
      BeginGroupIfNoMatch "##### BEGIN $(EditHeader) $(RCSRev)"
        DeleteToLineMatching "##### END $(EditHeader).*"
        DeleteNLines '1'
      EndGroup
      CatchAbort
      BeginGroupIfNoLineMatching "##### BEGIN $(EditHeader) $(RCSRev)"
        Append "##### BEGIN $(EditHeader) $(RCSRev)"
        Append "# mandatory loopback address"
        Append "127.0.0.1       localhost.localdomain localhost"
        Append ""
        Append "#####"
        Append "## revision: $(RCSRev)"
        Append "## file:     $(RCSFile)"
        Append "##### END $(EditHeader) $(RCSRev)"
      EndGroup
    }

And this the result:

##### BEGIN CFEngine hagar cf.redhat,v
# mandatory loopback address
127.0.0.1       localhost.localdomain localhost

#####
## revision:
## file:     cf.redhat,v
##### END CFEngine hagar cf.redhat,v

I've been beating my head against this and can't figure out where is goes wrong. Any tips or hints are welcome.

--
Met vriendelijke groeten/with kind regards

        John van Zantvoort

---

Paranoia is simply an optimistic outlook on life.

GCM d- s+:+ a- C+ UL+++ P+++ L++ E--- W++ N+ o K-
w-- O- M- V- PS+ PE- Y+ PGP+ t+ 5 X- R- tv b+ DI++
D+ G e h- r++ y+
------=_Part_5113_13446746.1155045694121-- From MAILER-DAEMON Wed Aug 23 18:59:43 2006 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1GG1hH-0000rw-NZ for mharc-help-cfengine@gnu.org; Wed, 23 Aug 2006 18:59:43 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GG1hF-0000rj-Gr for help-cfengine@gnu.org; Wed, 23 Aug 2006 18:59:41 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GG1hC-0000rX-VJ for help-cfengine@gnu.org; Wed, 23 Aug 2006 18:59:40 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GG1hC-0000rU-PA for help-cfengine@gnu.org; Wed, 23 Aug 2006 18:59:38 -0400 Received: from [209.191.85.40] (helo=web36706.mail.mud.yahoo.com) by monty-python.gnu.org with smtp (Exim 4.52) id 1GG1p8-0003HI-47 for help-cfengine@gnu.org; Wed, 23 Aug 2006 19:07:50 -0400 Received: (qmail 98146 invoked by uid 60001); 23 Aug 2006 22:59:28 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=srQdQ1GUxiKYaIZI1mKJqqBoWt4WIgSOtWEpmwOSdPZjJf2kI6lpySlhqnebIXZrEuWhxpgBEfmxA0Tkz9HGvmZZU+/9vEQM+HJ1O4j9XzB66eEPz7ye/SWZkwNsiuBHg/1kCGuFjiuWb2Z9Ea/hP9bD2iUXjNm+ZGNXng4GOdY= ; Message-ID: <20060823225928.98144.qmail@web36706.mail.mud.yahoo.com> Received: from [209.237.236.227] by web36706.mail.mud.yahoo.com via HTTP; Wed, 23 Aug 2006 15:59:28 PDT Date: Wed, 23 Aug 2006 15:59:28 -0700 (PDT) From: Robinson Tiemuqinke To: help-cfengine@gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Subject: defining classes based on returning results of (shell) commands? X-BeenThere: help-cfengine@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for GNU cfengine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Aug 2006 22:59:41 -0000 Hi, If there are any ways to define groups/classes with the return results of (shell) commands? Currently there is a function called ReturnZero can be used to define classes based on exit code, like explained in the online reference: ReturnsZero(command) True if the named shell command returns with exit code zero (success). But what I’d like to have is something like the following: strCmpReturn(identificationString, command) True if the named shell command returns with (exactly) the identificationString(or number). If there is already a function like the above? If not, anyone can suggest another way to workaround it? Thanks a lot. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From MAILER-DAEMON Wed Aug 23 19:54:25 2006 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1GG2YD-000686-9s for mharc-help-cfengine@gnu.org; Wed, 23 Aug 2006 19:54:25 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GG2YB-00066u-Me for help-cfengine@gnu.org; Wed, 23 Aug 2006 19:54:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GG2YA-00066L-0G for help-cfengine@gnu.org; Wed, 23 Aug 2006 19:54:23 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GG2Y9-00066A-Qg for help-cfengine@gnu.org; Wed, 23 Aug 2006 19:54:21 -0400 Received: from [12.130.29.196] (helo=golden-rule.prod.upromise.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GG2g5-0007QV-Ot for help-cfengine@gnu.org; Wed, 23 Aug 2006 20:02:33 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by golden-rule.prod.upromise.com (Postfix) with ESMTP id D214243E47 for ; Wed, 23 Aug 2006 19:54:20 -0400 (EDT) Received: from golden-rule.prod.upromise.com ([127.0.0.1]) by localhost (golden-rule-cc [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 27119-02-6; Wed, 23 Aug 2006 19:54:20 -0400 (EDT) Received: from fenris.corp.upromise.com (unknown [65.244.78.22]) by golden-rule.prod.upromise.com (Postfix) with ESMTP id 871AB43E43; Wed, 23 Aug 2006 19:54:20 -0400 (EDT) Received: by fenris.corp.upromise.com (Postfix, from userid 500) id 5F76760059; Wed, 23 Aug 2006 19:54:20 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=unknown Message-ID: <17644.60073.287448.86255@fenris.corp.upromise.com> Date: Wed, 23 Aug 2006 19:54:17 -0400 To: help-cfengine@gnu.org In-Reply-To: <20060823225928.98144.qmail@web36706.mail.mud.yahoo.com> References: <20060823225928.98144.qmail@web36706.mail.mud.yahoo.com> X-Mailer: VM 7.17 under 21.4 (patch 15) "Security Through Obscurity" XEmacs Lucid From: Josh Smith X-Attribution: JBS Organization: Enterprise Operations, Upromise Inc X-Virus-Scanned: amavisd-new at upromise.com Content-Transfer-Encoding: quoted-printable Subject: defining classes based on returning results of (shell) commands? X-BeenThere: help-cfengine@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for GNU cfengine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Aug 2006 23:54:24 -0000 RT =3D=3D Robinson Tiemuqinke RT> But what I=92d like to have is something like the RT> following: RT> RT> strCmpReturn(identificationString, command) RT> RT> True if the named shell command returns with RT> (exactly) the identificationString(or number). If nothing else, you could wrap it in a tiny script that parses the outpu= t of that command, and exits with an exit status of zero if and only if the string matches what you expect, and then check that with ReturnsZero. In fact, something as simple as #!/bin/bash [ $($1) =3D $2 ] should do the trick... -Josh (josh@upromise.com) From MAILER-DAEMON Wed Aug 23 20:40:22 2006 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1GG3Gg-0005jU-Dn for mharc-help-cfengine@gnu.org; Wed, 23 Aug 2006 20:40:22 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GG3Gf-0005j8-2n for help-cfengine@gnu.org; Wed, 23 Aug 2006 20:40:21 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GG3Gd-0005hS-HM for help-cfengine@gnu.org; Wed, 23 Aug 2006 20:40:20 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GG3Gd-0005hE-DE for help-cfengine@gnu.org; Wed, 23 Aug 2006 20:40:19 -0400 Received: from [130.164.46.253] (helo=mailserv96-us.natinst.com) by monty-python.gnu.org with smtp (Exim 4.52) id 1GG3OZ-0005Me-OF for help-cfengine@gnu.org; Wed, 23 Aug 2006 20:48:31 -0400 Received: from mailserv96-us (mailserv96-usa [130.164.46.253]) by mailserv96-us.natinst.com (Postfix) with ESMTP id 531D0143609; Wed, 23 Aug 2006 19:40:17 -0500 (CDT) Received: from draconix.amer.corp.natinst.com (10.0.7.222) by mailserv96-us (F-Secure/fsigk_smtp/488/mailserv96-us); Wed, 23 Aug 2006 19:40:17 -0600 (CST) X-Virus-Status: clean(F-Secure/fsigk_smtp/488/mailserv96-us) Received: by draconix.amer.corp.natinst.com (Postfix, from userid 1631) id 48AAB2D434; Wed, 23 Aug 2006 19:40:17 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by draconix.amer.corp.natinst.com (Postfix) with ESMTP id 3B42B2D433; Wed, 23 Aug 2006 19:40:17 -0500 (CDT) Date: Wed, 23 Aug 2006 19:40:17 -0500 (CDT) From: "David E. Nelson" X-X-Sender: dnelson@draconix.amer.corp.natinst.com To: Robinson Tiemuqinke In-Reply-To: <20060823225928.98144.qmail@web36706.mail.mud.yahoo.com> Message-ID: References: <20060823225928.98144.qmail@web36706.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="712199-1785215718-1156380017=:2374" Cc: help-cfengine@gnu.org Subject: Re: defining classes based on returning results of (shell) commands? X-BeenThere: help-cfengine@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for GNU cfengine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2006 00:40:21 -0000 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --712199-1785215718-1156380017=:2374 Content-Type: TEXT/PLAIN; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi Robinson, How about leveraging 'egrep'? For example, I use something like the follow= ing=20 in my 'groups:' section: WrongOptLocal =3D ( ReturnsZero(/bin/sh -c "PATH=3D/bin:/usr/bin:/sbin:/usr= /sbin ;=20 mount | egrep 'filer:/vol/vol0/opt/local' > /dev/null 2>&1") ) Use regex w/ egrep to get as specific as you want. And then in 'alerts:' I have: alerts: WrongOptLocal:: "WARNING: System is mounting /opt/local from the wrong filer" Regards, =09 /\/elson On Wed, 23 Aug 2006, Robinson Tiemuqinke wrote: > Hi, > > If there are any ways to define groups/classes with > the return results of (shell) commands? Currently > there is a function called ReturnZero can be used to > define classes based on exit code, like explained in > the online reference: > > ReturnsZero(command) > True if the named shell command returns with exit code > zero (success). > > But what I=92d like to have is something like the > following: > > strCmpReturn(identificationString, command) > > =09True if the named shell command returns with > (exactly) the identificationString(or number). > > If there is already a function like the above? If > not, anyone can suggest another way to workaround it? > > Thanks a lot. > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > > _______________________________________________ > Help-cfengine mailing list > Help-cfengine@gnu.org > http://lists.gnu.org/mailman/listinfo/help-cfengine > --=20 ~~ ** ~~ Research has shown that Mondays account for 1/7th of your time ~~ = ** ~~ --712199-1785215718-1156380017=:2374-- From MAILER-DAEMON Wed Aug 23 20:47:34 2006 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1GG3Ne-0004pE-DP for mharc-help-cfengine@gnu.org; Wed, 23 Aug 2006 20:47:34 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GG3Nb-0004la-LT for help-cfengine@gnu.org; Wed, 23 Aug 2006 20:47:31 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GG3NZ-0004id-OL for help-cfengine@gnu.org; Wed, 23 Aug 2006 20:47:31 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GG3NZ-0004iT-J1 for help-cfengine@gnu.org; Wed, 23 Aug 2006 20:47:29 -0400 Received: from [209.237.236.228] (helo=karl.presidio.alexa.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GG3VV-00063r-WE for help-cfengine@gnu.org; Wed, 23 Aug 2006 20:55:42 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Wed, 23 Aug 2006 17:47:16 -0700 Message-ID: <41089CB27BD8D24E8385C8003EDAF7AB0485EC9C@karl.presidio.alexa.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: defining classes based on returning results of (shell) commands? Thread-Index: AcbHFf7t7NeBsJ/gTmagh9seokaYjgAAG3GA From: "Guolin Cheng" To: "David E. Nelson" , "Robinson Tiemuqinke" Cc: help-cfengine@gnu.org Subject: RE: defining classes based on returning results of (shell) commands? X-BeenThere: help-cfengine@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for GNU cfengine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2006 00:47:32 -0000 David,=20 Good idea. I tried the following but it fails. checkCommand =3D ReturnsZero(/usr/bin/test "`sysctl -e -n = net.ipv4.tcp_abc 2>/dev/null` " =3D '1') Error messages are: ... cf:cfengine::/var/lib/cfengine/inputs/cf.groups:102: syntax error ... The #102 line is the checkCommand class definition line. Any ideas? Thanks. --Guolin -----Original Message----- From: help-cfengine-bounces+guolin=3Dalexa.com@gnu.org [mailto:help-cfengine-bounces+guolin=3Dalexa.com@gnu.org] On Behalf Of David E. Nelson Sent: Wednesday, August 23, 2006 5:40 PM To: Robinson Tiemuqinke Cc: help-cfengine@gnu.org Subject: Re: defining classes based on returning results of (shell) commands? Hi Robinson, How about leveraging 'egrep'? For example, I use something like the following=20 in my 'groups:' section: WrongOptLocal =3D ( ReturnsZero(/bin/sh -c "PATH=3D/bin:/usr/bin:/sbin:/usr/sbin ;=20 mount | egrep 'filer:/vol/vol0/opt/local' > /dev/null 2>&1") ) Use regex w/ egrep to get as specific as you want. And then in 'alerts:' I have: alerts: WrongOptLocal:: "WARNING: System is mounting /opt/local from the wrong filer" Regards, /\/elson On Wed, 23 Aug 2006, Robinson Tiemuqinke wrote: > Hi, > > If there are any ways to define groups/classes with > the return results of (shell) commands? Currently > there is a function called ReturnZero can be used to > define classes based on exit code, like explained in > the online reference: > > ReturnsZero(command) > True if the named shell command returns with exit code > zero (success). > > But what I'd like to have is something like the > following: > > strCmpReturn(identificationString, command) > > True if the named shell command returns with > (exactly) the identificationString(or number). > > If there is already a function like the above? If > not, anyone can suggest another way to workaround it? > > Thanks a lot. > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > > _______________________________________________ > Help-cfengine mailing list > Help-cfengine@gnu.org > http://lists.gnu.org/mailman/listinfo/help-cfengine > --=20 ~~ ** ~~ Research has shown that Mondays account for 1/7th of your time ~~ ** ~~ From MAILER-DAEMON Thu Aug 24 02:13:31 2006 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1GG8T5-0001QD-Dd for mharc-help-cfengine@gnu.org; Thu, 24 Aug 2006 02:13:31 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GG8T4-0001Or-1P for help-cfengine@gnu.org; Thu, 24 Aug 2006 02:13:30 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GG8Sy-0001Gl-Dq for help-cfengine@gnu.org; Thu, 24 Aug 2006 02:13:29 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GG8Sy-0001GV-67 for help-cfengine@gnu.org; Thu, 24 Aug 2006 02:13:24 -0400 Received: from [199.232.41.67] (helo=mx20.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GG8ax-0000HC-Nj for help-cfengine@gnu.org; Thu, 24 Aug 2006 02:21:39 -0400 Received: from [158.36.161.27] (helo=mail-out.hio.no) by mx20.gnu.org with esmtp (Exim 4.52) id 1GG8Sk-0007IM-Jw for help-cfengine@gnu.org; Thu, 24 Aug 2006 02:13:11 -0400 Received: from [192.168.1.100] (cm-84.208.83.202.chello.no [84.208.83.202]) (user=mark mech=CRAM-MD5 bits=0 port=587) by mail-out.hio.no (8.13.8/8.13.8) with ESMTP id k7O5w9rI012022 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 24 Aug 2006 07:58:36 +0200 Message-ID: <44ED3FD9.4030208@iu.hio.no> Date: Thu, 24 Aug 2006 07:57:45 +0200 From: Mark Burgess User-Agent: Thunderbird 1.5.0.5 (X11/20060725) MIME-Version: 1.0 To: Robinson Tiemuqinke References: <20060823225928.98144.qmail@web36706.mail.mud.yahoo.com> In-Reply-To: <20060823225928.98144.qmail@web36706.mail.mud.yahoo.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mail-out.hio.no id k7O5w9rI012022 Cc: help-cfengine@gnu.org Subject: Re: defining classes based on returning results of (shell) commands? X-BeenThere: help-cfengine@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for GNU cfengine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2006 06:13:30 -0000 Robinson Tiemuqinke wrote: > Hi, >=20 > If there are any ways to define groups/classes with > the return results of (shell) commands? Currently > there is a function called ReturnZero can be used to > define classes based on exit code, like explained in > the online reference: >=20 > ReturnsZero(command)=20 > True if the named shell command returns with exit code > zero (success).=20 >=20 > But what I=92d like to have is something like the > following: >=20 > strCmpReturn(identificationString, command) >=20 > True if the named shell command returns with > (exactly) the identificationString(or number). >=20 > If there is already a function like the above? If > not, anyone can suggest another way to workaround it? >=20 > Thanks a lot. First you get the outputs into variables and then Use RegCmp(). M --=20 Mark Burgess Professor of Network and System Administration Oslo University College ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Work: +47 22453272 Email: Mark.Burgess@iu.hio.no Fax : +47 22453205 WWW : http://www.iu.hio.no/~mark ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From MAILER-DAEMON Thu Aug 24 09:41:56 2006 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1GGFT1-0007bY-Sh for mharc-help-cfengine@gnu.org; Thu, 24 Aug 2006 09:41:55 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GGFSz-0007Wu-Kx for help-cfengine@gnu.org; Thu, 24 Aug 2006 09:41:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GGFSx-0007St-PT for help-cfengine@gnu.org; Thu, 24 Aug 2006 09:41:53 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GGFSx-0007Sc-KI for help-cfengine@gnu.org; Thu, 24 Aug 2006 09:41:51 -0400 Received: from [130.164.46.253] (helo=mailserv96-us.natinst.com) by monty-python.gnu.org with smtp (Exim 4.52) id 1GGFb1-0001uX-Hu for help-cfengine@gnu.org; Thu, 24 Aug 2006 09:50:11 -0400 Received: from mailserv96-us (mailserv96-usa [130.164.46.253]) by mailserv96-us.natinst.com (Postfix) with ESMTP id A3B3414363E; Thu, 24 Aug 2006 08:41:46 -0500 (CDT) Received: from draconix.amer.corp.natinst.com (10.0.7.222) by mailserv96-us (F-Secure/fsigk_smtp/488/mailserv96-us); Thu, 24 Aug 2006 08:41:46 -0600 (CST) X-Virus-Status: clean(F-Secure/fsigk_smtp/488/mailserv96-us) Received: by draconix.amer.corp.natinst.com (Postfix, from userid 1631) id 9902C2D434; Thu, 24 Aug 2006 08:41:46 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by draconix.amer.corp.natinst.com (Postfix) with ESMTP id 948AB2D42F; Thu, 24 Aug 2006 08:41:46 -0500 (CDT) Date: Thu, 24 Aug 2006 08:41:46 -0500 (CDT) From: "David E. Nelson" X-X-Sender: dnelson@draconix.amer.corp.natinst.com To: Guolin Cheng In-Reply-To: <41089CB27BD8D24E8385C8003EDAF7AB0485EC9C@karl.presidio.alexa.com> Message-ID: References: <41089CB27BD8D24E8385C8003EDAF7AB0485EC9C@karl.presidio.alexa.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: help-cfengine@gnu.org Subject: RE: defining classes based on returning results of (shell) commands? X-BeenThere: help-cfengine@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: "David E. Nelson" List-Id: Users list for GNU cfengine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2006 13:41:54 -0000 Hi Guolin, Looks to be missing a pair of parens: checkCommand = ( ReturnsZero(/usr/bin/test "`sysctl -e -n net.ipv4.tcp_abc 2>/dev/null` " = '1') ) ^ ^ | | Regards, /\/elson On Wed, 23 Aug 2006, Guolin Cheng wrote: > David, > > Good idea. > > I tried the following but it fails. > > > Error messages are: > ... > cf:cfengine::/var/lib/cfengine/inputs/cf.groups:102: syntax error > ... > > The #102 line is the checkCommand class definition line. > > Any ideas? > > Thanks. > > --Guolin > > > > -----Original Message----- > From: help-cfengine-bounces+guolin=alexa.com@gnu.org > [mailto:help-cfengine-bounces+guolin=alexa.com@gnu.org] On Behalf Of > David E. Nelson > Sent: Wednesday, August 23, 2006 5:40 PM > To: Robinson Tiemuqinke > Cc: help-cfengine@gnu.org > Subject: Re: defining classes based on returning results of (shell) > commands? > > > Hi Robinson, > > How about leveraging 'egrep'? For example, I use something like the > following > in my 'groups:' section: > > WrongOptLocal = ( ReturnsZero(/bin/sh -c > "PATH=/bin:/usr/bin:/sbin:/usr/sbin ; > mount | egrep 'filer:/vol/vol0/opt/local' > /dev/null 2>&1") ) > > Use regex w/ egrep to get as specific as you want. > > And then in 'alerts:' I have: > > alerts: > > WrongOptLocal:: > > "WARNING: System is mounting /opt/local from the wrong filer" > > Regards, > /\/elson > > > On Wed, 23 Aug 2006, Robinson Tiemuqinke wrote: > >> Hi, >> >> If there are any ways to define groups/classes with >> the return results of (shell) commands? Currently >> there is a function called ReturnZero can be used to >> define classes based on exit code, like explained in >> the online reference: >> >> ReturnsZero(command) >> True if the named shell command returns with exit code >> zero (success). >> >> But what I'd like to have is something like the >> following: >> >> strCmpReturn(identificationString, command) >> >> True if the named shell command returns with >> (exactly) the identificationString(or number). >> >> If there is already a function like the above? If >> not, anyone can suggest another way to workaround it? >> >> Thanks a lot. >> >> >> >> __________________________________________________ >> Do You Yahoo!? >> Tired of spam? Yahoo! Mail has the best spam protection around >> http://mail.yahoo.com >> >> >> _______________________________________________ >> Help-cfengine mailing list >> Help-cfengine@gnu.org >> http://lists.gnu.org/mailman/listinfo/help-cfengine >> > > -- ~~ ** ~~ Research has shown that Mondays account for 1/7th of your time ~~ ** ~~ From MAILER-DAEMON Fri Aug 25 04:19:01 2006 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1GGWu4-0004uk-Jw for mharc-help-cfengine@gnu.org; Fri, 25 Aug 2006 04:19:00 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GGWu0-0004sJ-BI for help-cfengine@gnu.org; Fri, 25 Aug 2006 04:18:56 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GGWtr-0004ea-6c for help-cfengine@gnu.org; Fri, 25 Aug 2006 04:18:54 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GGWtr-0004eM-1x for help-cfengine@gnu.org; Fri, 25 Aug 2006 04:18:47 -0400 Received: from [209.191.85.37] (helo=web36703.mail.mud.yahoo.com) by monty-python.gnu.org with smtp (Exim 4.52) id 1GGX25-0007aM-Qn for help-cfengine@gnu.org; Fri, 25 Aug 2006 04:27:18 -0400 Received: (qmail 18984 invoked by uid 60001); 25 Aug 2006 08:18:45 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=fS3e7ILL2D/N2bZLrQ2lilDbTSOp0unKu50QMm5aNiYKMaAdOBsS3lc+Ht22a4ezvRT3e2OW/H6rKxVhlFG7mgTVJEYbt9sAWjm08CBRPo8qzF8419v1bRunl1NofoSBD3mISf/L4dCsZ2wjCJBbPcW1DI9t4DHdI+aoG1MbAE8= ; Message-ID: <20060825081845.18982.qmail@web36703.mail.mud.yahoo.com> Received: from [67.107.182.2] by web36703.mail.mud.yahoo.com via HTTP; Fri, 25 Aug 2006 01:18:45 PDT Date: Fri, 25 Aug 2006 01:18:45 -0700 (PDT) From: Robinson Tiemuqinke To: david.nelson@ni.com, help-cfengine@gnu.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Cc: Subject: Odd ReturnsZero function problem -- Re: defining classes based on returning results of (shell) commands? X-BeenThere: help-cfengine@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for GNU cfengine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2006 08:18:56 -0000 Hi, Thanks for example. But which version of cfengine are you running? I'm using cfengine 2.1.18 and the ReturnsZero function always thinks that the included commands returns zero (success)!! -- pretty Odd and Funny! See my example: ... netBoot = ( ReturnsZero(/bin/sh -c "PATH=/bin:/usr/bin:/sbin:/usr/sbin ; mount | egrep '^/dev/ram.*?[ \t]+on[ \t]*/[ \t]*' > /dev/null 2>&1") ) localBoot = ( ReturnsZero(/bin/sh -c "PATH=/bin:/usr/bin:/sbin:/usr/sbin ; mount | egrep '^/dev/[sh]da.*?[ \t]+on[ \t]*/[ \t]*' > /dev/null 2>&1") ) ... Only one shoud be true, either from ramdisk (/dev/ram?) or local disk (/dev/[sh]da) my machines will find its root file system. But see what? cfengine sets both netBoot and localBoot classes at the same time on any machines! from command line we can see that one command returns exit code 0, anther one returns 1 if we run the above encolsed commands manually. Please help. --- "David E. Nelson" wrote: > > Hi Robinson, > > How about leveraging 'egrep'? For example, I use > something like the following > in my 'groups:' section: > > WrongOptLocal = ( ReturnsZero(/bin/sh -c > "PATH=/bin:/usr/bin:/sbin:/usr/sbin ; > mount | egrep 'filer:/vol/vol0/opt/local' > > /dev/null 2>&1") ) > > Use regex w/ egrep to get as specific as you want. > > And then in 'alerts:' I have: > > alerts: > > WrongOptLocal:: > > "WARNING: System is mounting /opt/local from > the wrong filer" > > Regards, > /\/elson > > > On Wed, 23 Aug 2006, Robinson Tiemuqinke wrote: > > > Hi, > > > > If there are any ways to define groups/classes > with > > the return results of (shell) commands? Currently > > there is a function called ReturnZero can be used > to > > define classes based on exit code, like explained > in > > the online reference: > > > > ReturnsZero(command) > > True if the named shell command returns with exit > code > > zero (success). > > > > But what I’d like to have is something like the > > following: > > > > strCmpReturn(identificationString, command) > > > > True if the named shell command returns with > > (exactly) the identificationString(or number). > > > > If there is already a function like the above? If > > not, anyone can suggest another way to workaround > it? > > > > Thanks a lot. > > > > > > > > __________________________________________________ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam > protection around > > http://mail.yahoo.com > > > > > > _______________________________________________ > > Help-cfengine mailing list > > Help-cfengine@gnu.org > > > http://lists.gnu.org/mailman/listinfo/help-cfengine > > > > -- > ~~ ** ~~ Research has shown that Mondays account for > 1/7th of your time ~~ ** ~~ __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From MAILER-DAEMON Fri Aug 25 05:30:00 2006 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1GGY0m-0001i2-2N for mharc-help-cfengine@gnu.org; Fri, 25 Aug 2006 05:30:00 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GGY0k-0001hP-TC for help-cfengine@gnu.org; Fri, 25 Aug 2006 05:29:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GGY0j-0001gZ-Kl for help-cfengine@gnu.org; Fri, 25 Aug 2006 05:29:58 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GGY0j-0001gQ-Cw for help-cfengine@gnu.org; Fri, 25 Aug 2006 05:29:57 -0400 Received: from [158.36.161.27] (helo=mail-out.hio.no) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GGY8y-0006U7-ME for help-cfengine@gnu.org; Fri, 25 Aug 2006 05:38:29 -0400 Received: from [128.39.89.232] (slogans.iu.hio.no [128.39.89.232]) (user=mark mech=CRAM-MD5 bits=0 port=587) by mail-out.hio.no (8.13.8/8.13.8) with ESMTP id k7P9TgGh032624; Fri, 25 Aug 2006 11:29:42 +0200 Message-ID: <44EEC2DF.2040401@iu.hio.no> Date: Fri, 25 Aug 2006 11:29:03 +0200 From: Mark Burgess User-Agent: Thunderbird 1.5.0.5 (X11/20060725) MIME-Version: 1.0 To: Robinson Tiemuqinke References: <20060825081845.18982.qmail@web36703.mail.mud.yahoo.com> In-Reply-To: <20060825081845.18982.qmail@web36703.mail.mud.yahoo.com> X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: help-cfengine@gnu.org Subject: Re: Odd ReturnsZero function problem -- Re: defining classes based on returning results of (shell) commands? X-BeenThere: help-cfengine@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for GNU cfengine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2006 09:29:59 -0000 Robinson Tiemuqinke wrote: > Hi, > > Thanks for example. But which version of cfengine are > you running? > > I'm using cfengine 2.1.18 and the ReturnsZero > function always thinks that the included commands > returns zero (success)!! -- pretty Odd and Funny! > > See my example: > ... > netBoot = ( ReturnsZero(/bin/sh -c > "PATH=/bin:/usr/bin:/sbin:/usr/sbin ; > mount | egrep '^/dev/ram.*?[ \t]+on[ \t]*/[ \t]*' >> /dev/null 2>&1") ) > localBoot = ( ReturnsZero(/bin/sh -c > "PATH=/bin:/usr/bin:/sbin:/usr/sbin ; > mount | egrep '^/dev/[sh]da.*?[ \t]+on[ \t]*/[ > \t]*' > /dev/null 2>&1") ) > ... > > Only one shoud be true, either from ramdisk > (/dev/ram?) or local disk (/dev/[sh]da) my machines > will find its root file system. But see what? cfengine > sets both netBoot and localBoot classes at the same > time on any machines! > > from command line we can see that one command returns > exit code 0, anther one returns 1 if we run the above > encolsed commands manually. > > Please help. > You are using a shell wrapper -- the shell can exit cleanly evn though the child process doesn't... From MAILER-DAEMON Fri Aug 25 13:16:38 2006 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1GGfIM-0002JZ-8Z for mharc-help-cfengine@gnu.org; Fri, 25 Aug 2006 13:16:38 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GGfIJ-0002ID-QL for help-cfengine@gnu.org; Fri, 25 Aug 2006 13:16:35 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GGfII-0002HI-Eb for help-cfengine@gnu.org; Fri, 25 Aug 2006 13:16:35 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GGfII-0002H5-7T for help-cfengine@gnu.org; Fri, 25 Aug 2006 13:16:34 -0400 Received: from [199.232.41.67] (helo=mx20.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1GGfQc-0002wJ-0B for help-cfengine@gnu.org; Fri, 25 Aug 2006 13:25:10 -0400 Received: from [64.233.162.203] (helo=nz-out-0102.google.com) by mx20.gnu.org with esmtp (Exim 4.52) id 1GGf3h-0006wc-SM for help-cfengine@gnu.org; Fri, 25 Aug 2006 13:01:30 -0400 Received: by nz-out-0102.google.com with SMTP id z31so690672nzd for ; Fri, 25 Aug 2006 10:01:28 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=UJPDlwoMP9TScNTgV5iQiUU97WsBvaXWddJBwy4e9/+nq1nbQ/Lrji3HvIfNB08n/XsP2qBrz/w55Fa9hziL3Te2oAcdeew41od2NUNkevZp7+66mBCww05DaAqFzWuA9OmFf/I4lhWmft1nXoIoMYPqtacJAomoAsFe102HSk0= Received: by 10.35.113.12 with SMTP id q12mr5420159pym; Fri, 25 Aug 2006 10:01:28 -0700 (PDT) Received: by 10.35.114.18 with HTTP; Fri, 25 Aug 2006 10:01:28 -0700 (PDT) Message-ID: <30997e260608251001n5958d1ceo4c7719c76dceb1d3@mail.gmail.com> Date: Fri, 25 Aug 2006 10:01:28 -0700 From: stucky To: "Robinson Tiemuqinke" In-Reply-To: <20060825081845.18982.qmail@web36703.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_186123_13220637.1156525288357" References: <20060825081845.18982.qmail@web36703.mail.mud.yahoo.com> Cc: help-cfengine@gnu.org Subject: Re: Odd ReturnsZero function problem -- Re: defining classes based on returning results of (shell) commands? X-BeenThere: help-cfengine@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for GNU cfengine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Aug 2006 17:16:36 -0000 ------=_Part_186123_13220637.1156525288357 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I had the same problem using grep directly in the class definition so instead I wrote a shell wrapper that exits correctly and defined that wrapper in the class definition instead. Worked like a charm. On 8/25/06, Robinson Tiemuqinke wrote: > > Hi, > > Thanks for example. But which version of cfengine are > you running? > > I'm using cfengine 2.1.18 and the ReturnsZero > function always thinks that the included commands > returns zero (success)!! -- pretty Odd and Funny! > > See my example: > ... > netBoot = ( ReturnsZero(/bin/sh -c > "PATH=/bin:/usr/bin:/sbin:/usr/sbin ; > mount | egrep '^/dev/ram.*?[ \t]+on[ \t]*/[ \t]*' > > /dev/null 2>&1") ) > localBoot = ( ReturnsZero(/bin/sh -c > "PATH=/bin:/usr/bin:/sbin:/usr/sbin ; > mount | egrep '^/dev/[sh]da.*?[ \t]+on[ \t]*/[ > \t]*' > /dev/null 2>&1") ) > ... > > Only one shoud be true, either from ramdisk > (/dev/ram?) or local disk (/dev/[sh]da) my machines > will find its root file system. But see what? cfengine > sets both netBoot and localBoot classes at the same > time on any machines! > > from command line we can see that one command returns > exit code 0, anther one returns 1 if we run the above > encolsed commands manually. > > Please help. > > > > > > --- "David E. Nelson" wrote: > > > > > Hi Robinson, > > > > How about leveraging 'egrep'? For example, I use > > something like the following > > in my 'groups:' section: > > > > WrongOptLocal = ( ReturnsZero(/bin/sh -c > > "PATH=/bin:/usr/bin:/sbin:/usr/sbin ; > > mount | egrep 'filer:/vol/vol0/opt/local' > > > /dev/null 2>&1") ) > > > > Use regex w/ egrep to get as specific as you want. > > > > And then in 'alerts:' I have: > > > > alerts: > > > > WrongOptLocal:: > > > > "WARNING: System is mounting /opt/local from > > the wrong filer" > > > > Regards, > > /\/elson > > > > > > On Wed, 23 Aug 2006, Robinson Tiemuqinke wrote: > > > > > Hi, > > > > > > If there are any ways to define groups/classes > > with > > > the return results of (shell) commands? Currently > > > there is a function called ReturnZero can be used > > to > > > define classes based on exit code, like explained > > in > > > the online reference: > > > > > > ReturnsZero(command) > > > True if the named shell command returns with exit > > code > > > zero (success). > > > > > > But what I'd like to have is something like the > > > following: > > > > > > strCmpReturn(identificationString, command) > > > > > > True if the named shell command returns with > > > (exactly) the identificationString(or number). > > > > > > If there is already a function like the above? If > > > not, anyone can suggest another way to workaround > > it? > > > > > > Thanks a lot. > > > > > > > > > > > > __________________________________________________ > > > Do You Yahoo!? > > > Tired of spam? Yahoo! Mail has the best spam > > protection around > > > http://mail.yahoo.com > > > > > > > > > _______________________________________________ > > > Help-cfengine mailing list > > > Help-cfengine@gnu.org > > > > > http://lists.gnu.org/mailman/listinfo/help-cfengine > > > > > > > -- > > ~~ ** ~~ Research has shown that Mondays account for > > 1/7th of your time ~~ ** ~~ > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > > _______________________________________________ > Help-cfengine mailing list > Help-cfengine@gnu.org > http://lists.gnu.org/mailman/listinfo/help-cfengine > -- stucky ------=_Part_186123_13220637.1156525288357 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline I had the same problem using grep directly in the class definition so instead I wrote a shell wrapper that exits correctly and defined that wrapper in the class definition instead. Worked like a charm.

On 8/25/06, Robinson Tiemuqinke <hahaha_30k@yahoo.com> wrote:
Hi,

Thanks for example. But which version of cfengine are
you running?

I'm using cfengine 2.1.18 and the ReturnsZero
function always thinks that the included commands
returns zero (success)!! -- pretty Odd and Funny!

See my example:
...
  netBoot = ( ReturnsZero(/bin/sh -c
"PATH=/bin:/usr/bin:/sbin:/usr/sbin ;
    mount | egrep '^/dev/ram.*?[ \t]+on[ \t]*/[ \t]*'
> /dev/null 2>&1") )
  localBoot = ( ReturnsZero(/bin/sh -c
"PATH=/bin:/usr/bin:/sbin:/usr/sbin ;
    mount | egrep '^/dev/[sh]da.*?[ \t]+on[ \t]*/[
\t]*' > /dev/null 2>&1") )
...

Only one shoud be true, either from ramdisk
(/dev/ram?) or local disk (/dev/[sh]da) my machines
will find its root file system. But see what? cfengine
sets both netBoot and localBoot classes at the same
time on any machines!

from command line we can see that one command returns
exit code 0, anther one returns 1 if we run the above
encolsed commands manually.

Please help.





--- "David E. Nelson" <david.nelson@ni.com> wrote:

>
> Hi Robinson,
>
> How about leveraging 'egrep'?  For example, I use
> something like the following
> in my 'groups:' section:
>
> WrongOptLocal = ( ReturnsZero(/bin/sh -c
> "PATH=/bin:/usr/bin:/sbin:/usr/sbin ;
> mount | egrep 'filer:/vol/vol0/opt/local' >
> /dev/null 2>&1") )
>
> Use regex w/ egrep to get as specific as you want.
>
> And then in 'alerts:' I have:
>
> alerts:
>
>    WrongOptLocal::
>
>      "WARNING: System is mounting /opt/local from
> the wrong filer"
>
> Regards,
>        /\/elson
>
>
> On Wed, 23 Aug 2006, Robinson Tiemuqinke wrote:
>
> > Hi,
> >
> > If there are any ways to define groups/classes
> with
> > the return results of (shell) commands? Currently
> > there is a function called ReturnZero can be used
> to
> > define classes based on exit code, like explained
> in
> > the online reference:
> >
> > ReturnsZero(command)
> > True if the named shell command returns with exit
> code
> > zero (success).
> >
> > But what I'd like to have is something like the
> > following:
> >
> > strCmpReturn(identificationString, command)
> >
> >     True if the named shell command returns with
> > (exactly) the identificationString(or number).
> >
> > If there is already a function like the above? If
> > not, anyone can suggest another way to workaround
> it?
> >
> > Thanks a lot.
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around
> > http://mail.yahoo.com
> >
> >
> > _______________________________________________
> > Help-cfengine mailing list
> > Help-cfengine@gnu.org
> >
> http://lists.gnu.org/mailman/listinfo/help-cfengine
> >
>
> --
> ~~ ** ~~ Research has shown that Mondays account for
> 1/7th of your time ~~ ** ~~


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


_______________________________________________
Help-cfengine mailing list
Help-cfengine@gnu.org
http://lists.gnu.org/mailman/listinfo/help-cfengine



--
stucky ------=_Part_186123_13220637.1156525288357--