Ask Your Question
0

augeas lenses error

asked 2015-02-23 10:58:41 -0500

Chutki gravatar image

Hi,

My requirement is want to use "kernel.sem = 10240 512000 64 9005" value for comparison in puppet. I used augeas sysctl.lns for manifests, but it doesn't support kenl.sem since I want to compare semaphores value one by one. So I am trying to use tests lenses as per my requirement. Below is my test module in augeas

test_systest.aug
===============
module Test_systest =
let semmn = "kernel.semmni = 10240 512000 64 9005"
test Systest.lns get semmn =
  { "kernel.semmni"
    { "1" = "10240" }
    { "2" = "512000" }
    { "3" = "64" }
    { "4" = "9005" }}

sysctest.aug
===========
module Systest =
autoload xfm
let filter = incl "/etc/sysctl.conf"
           . Util.stdexcl
let space     = /[ \t]+/
let comment = Util.comment_generic /[ \t]*[#;][ \t]*/ "# "
let lns = (space | Util.empty | comment | Simplevars.entry)*
let xfm = transform lns filter

I am getting below error

/augparse -t /usr/share/augeas/lenses/tests/test_systest.aug 
Module /usr/share/augeas/lenses/tests/test_systest.aug loaded
Syntax error in lens definition
/usr/share/augeas/lenses/tests/test_systest.aug:5.5-.16:Could not load module Systest for Systest.lns
/usr/share/augeas/lenses/tests/test_systest.aug:5.5-.16:Undefined variable Systest.lns

Below is method 2

test_sysctl.aug
================
module Test_sysctl =
let semmn = "kernel.semmni = 10240 512000 64 9005"
test Systctl.lns get semmn =
  { "kernel.semmni"
    { "1" = "10240" }
    { "2" = "512000" }
    { "3" = "64" }
    { "4" = "9005" }}

sysctl.aug
=========== 
module Sysctl =
autoload xfm
let filter = incl "/etc/sysctl.conf"
           . Util.stdexcl
let space     = /[ \t]+/
let comment = Util.comment_generic /[ \t]*[#;][ \t]*/ "# "
let lns = (space | Util.empty | comment | Simplevars.entry)*
let xfm = transform lns filter

below is the error I got when I ran method 2

/usr/share/augeas/lenses/tests/test_sysctl.aug:5.0-10.21:exception thrown in test
/usr/share/augeas/lenses/tests/test_sysctl.aug:5.5-.25:exception: Iterated lens matched less than it should
    Lens: /opt/puppet/share/augeas/lenses/dist/sysctl.aug:37.10-.52:
    Error encountered at 1:0 (0 characters into string)
                               <|=|kernel.semmni = 10240 512000>
    Tree generated so far:

Syntax error in lens definition
Failed to load /usr/share/augeas/lenses/tests/test_sysctl.aug

In the first sample, I used module name on my own and got error the error what I mention

In the second code, I used sysctl module name just its try.

1) so what is my fist doubt is, should I always use the valid existing lenses as a module name

2) I want to take each semaphores like a augeas tree stucture.

current augeas

print /files/etc/sysctl/kernel.sem
set /files/etc/sysctl/kernel.sem = "10240 512000 64 9005"

I want to be like

print /files/etc/sysctl/kernel.sem
set /files/etc/sysctl/kernel.sem/1 = 10240 
set /files/etc/sysctl/kernel.sem/2 = 512000
set /files/etc/sysctl/kernel.sem/3 =  64 
set /files/etc/sysctl/kernel.sem/4 = 9005

Please correct my augeas lens module if it is wong

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-03-04 19:23:38 -0500

GregLarkin gravatar image

You will definitely get better answers to this question on Stackoverflow instead of here. Just make sure to tag your question with "augeas" like these questions: http://stackoverflow.com/questions/ta... and you should find someone that can help.

edit flag offensive delete link more

Comments

Thanks Greg. I will post my doubts in stackoveflow forum.

Chutki gravatar imageChutki ( 2015-03-06 11:49:18 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-02-23 10:58:41 -0500

Seen: 310 times

Last updated: Mar 04 '15