Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account
List archives

Augeas working inconsistently

Catching failure with templates
(43 lines)
Help with setting facts for MySQL replication
(23 lines)
Jul 27, 2010
Rob McBroom
Rob McBroom
I’ve got this define.

    define sudoentry ($user, $host = "ALL", $command = "ALL", $tag =
false, $runas = "ALL") {
      $sudo_changes = $tag ? {
        false => [
          "set spec[user = '$user']/user $user",
          "set spec[user = '$user']/host_group/host $host",
          "set spec[user = '$user']/host_group/command '$command'",
          "remove spec[user = '$user']/host_group/command/tag",
          "set spec[user = '$user']/host_group/command/runas_user $runas",
        ],
        # this isn't a real tag, but a sneaky *****1 to remove entries
        DELETE => "remove spec[user = '$user']",
        default => [
          "set spec[user = '$user']/user $user",
          "set spec[user = '$user']/host_group/host $host",
          "set spec[user = '$user']/host_group/command '$command'",
          "set spec[user = '$user']/host_group/command/tag $tag",
          "set spec[user = '$user']/host_group/command/runas_user $runas",
        ],
      }
      augeas { "sudo-$user":
        context => "/files/etc/sudoers",
        changes => $sudo_changes,
      }
    }

And I see the following.

If the entry isn’t in `sudoers` at all, this will add it:

    sudoentry { "rob":
      user => "rmcbroom”,
    }

If the entry is already there, this will add the “tag” to it:

    sudoentry { "rob":
      user => "rmcbroom",
      tag => "NOPASSWD",
    }

But if the user doesn’t exist and you try to add the entry with
“tag” set to something, it fails:

    err: //Sudoentry[rob]/Augeas[sudo-rmcbroom]/returns: change from
need_to_run to 0 failed: Save failed with return code false

Any guesses? Am I missing something?

(I realize with the define as written, there are potential uniqueness
problems for users with multiple entries, etc. It’s a work in progress.)







Reply
Tags: setfalse
Similar Threads
DO NOT REPLY New: ForEachSupport handles unsupported items inconsistently
https://issues.apache.org/bugzilla/show_bug.cgi?id=49534

           Summary: ForEachSupport handles unsupported items
                    inconsistently
           Product: Taglibs
           Version: 1.2.0
          Platform: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Standard Taglib
        AssignedTo: d### @tomcat.apache.org
        ReportedBy: jbo### @apache.org


When the "items" attribute contains an unsupported type an exception is
thrown
with a "FOREACH_BAD_ITEMS" error message. However, if it contains a value
expression that evaluates to an unsupported type, no error occurs. An
example
would be the snippet:

  <c:set var="hello" value="${true}"/>
  <c:forEach var="x" items="#{hello}">
      <c:out value="${x}"/>
  </c:forEach>




puppet and augeas to keep ntp.conf
Hi,

Please help me in following:

I'm trying to check ntp.conf files some of which have and some have
not lines like these

server ntp1.example.com
server ntp2.example.com
server ntp3.example.com

How I should form onlyif condition with match to make it working:
now I have either it is not working at all or just accumulating
additional lines.

May be I have to separate this to 3 sets each per server? From other
side using some regexp like ntp[123]  could make it shorter and more
readable.

Sorry for my puppet/augeas stile:

class ntpd{
    service { ntpd:
        name => "ntpd",
        enable => true,
        ensure => running,
        require => File["/etc/ntp.conf"],
    }
    file { "/etc/ntp.conf" :
        owner => "root",
        group => "root",
        mode  => 664,
        require => [Package["ntp"], Augeas["/etc/ntp.conf"]]
    }
    package { ntp: ensure => present }

    augeas{"/etc/ntp.conf":
        context => "/files/etc/ntp.conf",
        changes => [
            "set server[last()+1] ntp1.example.com",
            "set server[last()+1] ntp2.example.com",
            "set server[last()+1] ntp3.example.com",
        ],
        onlyif => "match server[last()] != 'ntp3.logitech.com'",
#        onlyif => "match server != ['ntp1.logitech.com',
'ntp2.logitech.com', 'ntp3.logitech.com']"

    }
}


Also  is any way to check what is happening on REMOTE side at time of
puppet/augeas execution? Any remote debug and some file reference to
accept this debug log?

Please advise,

Alex





augeas and sudo woes
The following function is based on code I found here in an earlier
thread.

define sudoer() {
  augeas { "sudo${name}":
  context => "/files/etc/sudoers",
  changes => [
    "set spec[last() + 1]/user ${name}",
    "set spec[last()]/host_group/host ALL",
    "set spec[last()]/host_group/command NOPASSWD: ALL",
    "set spec[last()]/host_group/command/runas_user ALL",
  ],
}

In that example, the command line looked like this:

"set spec[last()]/host_group/command ALL",

I added NOPASSWD: and it barfs with this message:

err: //user::unixadmins/User::Virtual::Sudoer[joe]/Augeas[sudojoe]/
returns: change from need_to_run to 0 failed: Save failed with return
code false

The problem seems to be the colon ':'  since NOPASSWD:ALL also fails
but this doesn't error:

"set spec[last()]/host_group/command NOPASSWD ALL",

Unfortunately, that doesn't produce a desirable output.

Any suggestions?





Augeas and grub.conf
 I hope that the answer to this isn't posted up somewhere else, I have
looked around and I haven't found much of anything, augeas documentation
seems to be thin. Is there even full documentation for all the augeas
function and language syntax? What I am trying to do is edit the
grub.conf file and modify some parameters for each kernel line, remove
rhgb, add audit = 1. I would like for this to happen on all kernels
listed in /etc/grub.conf, so for audit I have:

        #Set audit=1 for grub.conf
        augeas {"kernel_audit":
                context => "/files/etc/grub.conf",
                changes => "set title[*]/kernel/audit 1",
                onlyif  => "get title[*]/kernel/audit != 1",
        }

This suprisingly works, but only for the first entry in grub.conf I say
surprisingly because running the set  command via augtool fails, so this
behaviour is a bit different for the ruby bindings. Does anyone with
some wicked augeas skill know how to express what I am trying to express
here? Is it even possible?

Second problem, rhgb. This is an empty node, as in it comes back rhgb =
(none) in augtool, I am trying to write an onlyif rule but how do you
match none?

        #Remove rhgb from kernel lines if it exists
        augeas {"kernel_rhgb":
                context => "/files/etc/grub.conf",
                changes => "remove title[*]/kernel/rhgb",
                onlyif  => "match title[1]/kernel/rhgb == ['none']",
                }

Now again I would really like it to match all, and remove from all,
removal from all seems to work, but the match, as I said, fails. I have
tried a lot of variants to the point where I don't think it is a text
match, but I am not sure how to match it. Again I am just getting
started with this stuff, my apologies if the answer is glaringly
obvious, but please at least point me in the right direction.

-Erinn





Setting Augeas values using an array
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)I have a resource
I'd like to manage via augeas (/etc/conf.d/net; it's a bash
variables file) but I"m having problems figuring out how to set the values
so
that all of the values in the array go in.

I would like it to look like this:
# cat /etc/conf.d/net
config_eth4=("192.168.128.2/24")
config_eth5=("192.168.129.2/24")
routes_eth5=("192.168.130.0/24 via 192.168.131.1")

But it ends up looking like this:
config_eth4=192.168.128.2/24
config_eth5=192.168.129.2/24
routes_eth5=192.168.130.0/24

The goal is to be able to assign multiple values to "ip" or "routes" for
an
interface.

Is this something I might have to do w/ a custom type?

-Doug


class net {
        file { "/etc/conf.d/net":
                owner => root, group => root, mode => 0644,
        }

        # TODO remove undefined routes
        define interface($ip, $routes = undef) {
                exec { "net_restart_$name":
                        #TODO: perform restart
                        command => "/bin/true",
                        refreshonly => true,
                }

                augeas { "conf.d_net_ip_$name":
                        notify => Exec["net_restart_$name"],
                        context => "/files/etc/conf.d/net",
                        changes => "set config_$name $ip",
                }
                if $routes {
                        augeas { "conf.d_net_routes_$name":
                                notify => Exec["net_restart_$name"],
                                context => "/files/etc/conf.d/net",
                                changes => "set routes_$name $routes",
                        }
                }
                else {
                        augeas { "conf.d_net_routes_$name":
                                notify => Exec["net_restart_$name"],
                                context => "/files/etc/conf.d/net",
                                changes => "rm routes_$name",
                                onlyif => "match routes_$name size >
0",
                        }
                }
        }
}

node 'example' {
        include net
        net::interface { "eth4": ip => ["192.168.128.2/24"], }
        net::interface { "eth5": ip => ["192.168.129.2/24"],
                routes => ["192.168.130.0/24 via 192.168.131.1"],}
}



File-based Distribution, Module Function Logic and Per Setting (Augeas); Which method do you think

I am having a difficult time understanding and determining  which
module method is best for the env I help to support.

Overview of systems supported:
-There are 17+ clients.
-4+ envs (dev, stage, beta, prod ..) per client
-Several flavors and versions of OS ( Mostly fedora and centos )
-All are apache, some mongrel and most passenger
-code deployments are capistrano
-configurations are done with ssh and vi


A goal is to follow is to have a clean, simple method.  Another goal
is to follow jmeeuwen recommendation and
"stick to a single approach for an entire environment".  Which method
do you think is best for the env i help to support and why?

Another short term goal is setup a module to support monit configs on
a few  test nodes.  I am looking camptocamp monit module
-which method does that module use?
-is there another monit module that you could recommend?

Tony '...wanna be puppetmaster'





Working C example?
Hi, looking in the  http://activemq.apache.org/c-integration.html C
cross-client  implementations  
http://svn.apache.org/repos/asf/activemq/sandbox/openwire-c/ OpenWire  and

http://svn.stomp.codehaus.org/browse/stomp/trunk/c/ STOMP  C
implementations, I see only prototype code, which project would be most
easy
to get running though?

Does anyone have a working example or experience building one of the
prototype C implementations (possibly with brief build/run
instructions)???

It would be GREATLY appreciated! I need to get a JMS consumer/producer
going
using C, like yesterday!!




trying to ban IPs using htaccess - not working
I'm trying to ban certain IPs from visiting my site, so that they 
instead see a message saying "Your IP has been banned, email me if 
you think this is an error."  I've *almost* got it working -- when 
people visit URLs like
http://209.160.28.154/index.html
or
http://209.160.28.154/foo-does-not-exist
they see the "banned IP" message.  However, the problem is that if 
you try to access the front page:
http://209.160.28.154/
from a banned IP address, you see the "Apache Test Page for CentOS" 
page, instead of seeing the "banned IP" message.  Anybody recognize 
this problem or have an idea of what could be causing it?

In my httpd.conf file, I changed "AllowOverride None" to 
"AllowOverride All" in both the default <Directory /> tag and inside

the <Directory "/var/www/html"> tag -- I placed a modified copy of 
httpd.conf at:
http://209.160.28.154/httpd.conf
and in /var/www/html I placed a .htaccess file containing these lines:
 >>>
ErrorDocument 403 /banned_ip.php
order deny,allow
deny from 71.112.32.149
 >>>
and restarted the server.  (The page 
http://209.160.28.154/banned_ip.php shows the message you're supposed 
to see when connecting from a banned IP.  71.112.32.149 is my home 
machine IP which I've "banned" for testing purposes.)

So like I said, that almost works, where 
http://209.160.28.154/index.html gives the right error message, but 
http://209.160.28.154/ does not.  Any idea how to change is to that 
all URLs under http://209.160.28.154/ will give the "banned IP" 
message if connecting from a banned IP?

	-Bennett



SSL Not working on tomcat 5.5.29
Hi All,

I am working on upgrading tomcat from 5.5.28 to 5.5.29 for one of the
applications. I see that the website renders and works fine in 5.5.29 on
port 8080 (non SSL) but with  SSL (port 8443) the website doesnot run at
all. When I try to see what's going on in Fiddle, I see 502 error. Also
nothing is written to the log flies. It is as if tomcat is not even
running
in port 8443.

Under tomcat 5.5.28, the site renders fine with SSL and non SSL.

Is there something I could be missing?

Regards,
Kareem




FileUpload not working
Hi guys,

I'm using the Apache Commons FileUpload lib and I'm getting this strange
behaviour in just one of my servers. All others work perfectly.

servletfileupload.parseRequest(request) always returns an empty list.

But if I check for:

ServletFileUpload.isMultipartContent(request)

This returns true. So, the list should not be empty.

I'm really stuck here. Any ideas?

Thanks,
Fernando




Caching not working
Hi,

I have got a proxy running using ATS. The sole entry in remap.config is -

map http://localhost:8080/ http://localhost:8282/

However caching does not take place. Every query i make is redirected to
the
origin server. The contents of storage.config is -

/usr/local/trafficserver/cache 134217728

A cache.db file in that location exists. But, the value of the cache size
-
proxy.process.cache.bytes_total is shown as 0. What do I need to do to
make
caching work?

Thanks,
Pranav.


Re: anyone working on BCEL ?
On 24/05/2010, Mark Thomas <mar### @apache.org> wrote:
 On 24/05/2010 22:34, sebb wrote:
  > Is anyone working on - or wanting to work on - BCEL at present?


 Try the Jakarta dev list. BCEL isn't a commons component.

Duh -sorry!

  Mark


  >
  > I know that Findbugs are keen to get away from using their
patched version.
  >
  > I can do some tidying up of test cases and basic warnings if
that would help.
  >
  > There seem to have been a lot of fixes since 5.2, so it would
be good
  > to get a new release out.
  >

 > 
Desperate for working AMQ-cpp for VS2005
I am having a terrible time with amq-cpp 3.2.x on VS2005. I used MPC to 
generate the missing VS 2005 files and everything rebuilt ok but there are

still problems:

in Debug mode my app fails to link with the error fatal error LNK1106: 
invalid file or disk full

in Release mode it linked but blew up with a core dump as soon as it tried

to use AMQ (not sure which call).

I think there may be still something wrong with my build env but I do not 
know what. I note that I have to link with the APR libraries. I thought 
these were C libraries so I took prebuilts from sourceforge. Do I need to 
do my own build of these as well. I am wondering if the C++ macros I am 
forced to use also have to be enabled here. They are:

  macros += WIN32
  macros += _WINDOWS
  macros += NOMINMAX

  macros += _SECURE_SCL_THROWS=1
  macros += _SECURE_SCL=1
  macros += _CRT_SECURE_NO_DEPRECATE
  macros += _CRT_NONSTDC_NO_DEPRECATE
  macros += _MBCS

  macros += _VC80_UPGRADE=0x0600

I assumed I wouldn't need these since the APR is coded in C. However, I 
now remember that VS does not provide a separate C compiler. One has to 
run C code through the C++ compiler so maybe these macros might have an 
effect.

I would really appreciate a release of AMQ-cpp with VS files for VS2005.

Regards,

Andrew Marlow


tomcat /manager not working
I downloaded tomcat 5.5.29 and tried to access an application
http://<IP of Tomcat server>:8080/manager
which the doc says
http://tomcat.apache.org/tomcat-5.5-d...v/deployment.html
that it is included and deployed by default it did not showed me any
thing did I miss any thing.




Working example MyBatis 3.0 web application
http://mybatis.googlecode.com/svn/sub-projects/contact_manager

The development stack is stripes+guice+mybatis+hsqldb+junit4+mockito.

It's using a couple of new features:
 - package level configuration by convention available in the
programmatic config API
 - and the new SqlSessionManager (available in the current snapshot
and will be in the next release)

Feel free to check it out and build the war file.  Only have to drop
it into any container and you are good to go.  We have changed it from
pgSql to an in memory DB (hsqldb) to make life even easier.

More to come!  When I get a chance I will add a few more simple table
to show joins and other common features.

MyBatis Team


Simple mybatis3 working example
I just created a very simple example (java konsole output, using
mysql) with the help of mybatis3 user guide,
adding some knowledge I got from ibatis3.

You can check it out from:
https://pl3.projectlocker.com/razorblue/mybatis3_example/svn

using this account
username: gue### @fakemail.com
password: 123456

Hope this helps


Trying to get Ant + JUnit working peaceably
Hello,

I'm attempting to learn Java at present and needed to add some
automation around my build and test cycle.  Coming from Ruby, I've got
a real test-first design discipline.

When I attempted to make a <junit> task call, I started getting this
error (I can hear eyes rolling...).


BUILD FAILED
/Users/stharms/java_card/build.xml:38: Problem: failed to create task
or type junit
Cause: the class
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask was not found.
        This looks like one of Ant's optional components.
Action: Check that the appropriate optional JAR exists in
        -/usr/local/apache-ant-1.8.0/lib
        -/Users/stharms/.ant/lib
        -a directory added on the command line with the -lib argument

OK, I'm open to trying to step through the directions.

Most searches and archives suggested that it was paramount to make
sure that the junit library was in $ANTDIR/lib.

In this directory I have both:

junit-3.8.2.jar : retrieved with ant -f fetch.xml -Ddest=system
junit-4.9-SNAPSHOT-20100512-0041.jar : built from github

I then thought, OK let's go with the instructions strictly, what's in
the lib/optional subdir.  Nothing!  OK, so I used the fetch.xml task
to pull the jars into optional.

Re-try, same error.

OK, IRC.  A kind soul there pointed out that on his debian system this
class file was part of optionals.jar that "just worked" as part of
using apt-get ant-optionals.  Hm, regrettably that answer isn't
portable to my platform.

So, I'm stuck.  Can anyone help me get around this low point.  I'm
excited to start programming Java, but I've wound up programming Ant
most of the day -- not a bad thing, just not the shiny app I had
dreamt of :)

Thanks in advance, mysterious guru with the answer,

Steven


How to enable HTTPS when SSL is working ?
I am using ActiveMQ 5.3.2 embedded into my Spring based application. My
goal
is to configure ActiveMQ in order to be able to commnicate with it in
HTTPS
(requests and responses encapsulated in HTTPS).
The SSL part is done: i have a client test application connection with SSL
to activemq, and the communication is OK with certs on both sides.
When adding the HTTPS connector to activemq configuration, and trying with
my client app to connect using https://localhost:myport, it doesn't work
and
i get the following error:

handling exception: javax.net.ssl.SSLException: Unrecognized SSL message,
plaintext connection?

What could make my HTTPS connnection fails, although the SSL comuncation
seems ok ?

Thanks a lot if you have any clue, that's a very important bug for me
right
now. Thanks a lot for any help.

Max



Group by is not working with Filter
Hello Everyone,

I am trying to execute below mentioned script, but it is throwing error.
Script is:

A = load 'ex_groupby' USING PigStorage(',') as (a1:int,a2:int,a3:int);
G1 = GROUP A by (a1,a2);
describe G1;
*D = Filter G1 by group.$0 > 1;*
dump D;

Error is :

java.lang.ClassCastException: java.lang.Integer cannot be cast to
org.apache.pig.data.Tuple
        at
org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POProject.getNext(POProject.java:389)
        at
org.apache.pig.backend.hadoop.executionengine.physicalLayer.PhysicalOperator.processInput(PhysicalOperator.java:276)
        at
org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POProject.getNext(POProject.java:138)
        at
org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POProject.getNext(POProject.java:276)
        at
org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.GreaterThanExpr.getNext(GreaterThanExpr.java:72)
        at
org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POFilter.getNext(POFilter.java:148)
        at
org.apache.pig.backend.hadoop.executionengine.physicalLayer.PhysicalOperator.processInput(PhysicalOperator.java:276)
        at
org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POLocalRearrange.getNext(POLocalRearrange.java:259)
        at
org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigMapBase.runPipeline(PigMapBase.java:236)
        at
org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigMapBase.map(PigMapBase.java:231)
        at
org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigMapBase.map(PigMapBase.java:53)
        at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:144)
        at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:621)

Any help would be appreciated.

Thanks,
Swati


Puppet_Augeas: Working Examlples
Hello Puppeteers;

for those of us who are still suffering in the darkness of
Puppet_Augeas,
I put  a couple of working examples here:

http://projects.puppetlabs.com/projec...iki/Puppet_Augeas

and those of us who are no longer in the dark, please add there your
working examples - for enlightenment, you know :-)

Thank you;

Andrei