Ask Your Question
1

Use Augeas to modify file

asked 2013-11-12 20:49:30 -0500

spuder gravatar image

updated 2013-11-12 21:00:48 -0500

The puppet documentation gives the following example for modifying a file with augeas. I've found that the example does not work, and I do not know why.

augeas{"test1" :
  context => "/files/etc/sysconfig/firstboot",
  # context => "/etc/sysconfig/firstboot", #Also tried this syntax, with no luck
  changes => "set RUN_FIRSTBOOT YES",
  onlyif  => "match other_value size > 0",
}

My test class

class foo {

  augeas{ 'bar':
    context =>  "/files/etc/sysconfig/firstboot",
    changes =>  "set RUN_FIRSTBOOT YES",
    onlyif  =>  "match other_value size > 0",
  }
}
include foo

Yet, after applying, RUN_FIRSTBOOT is still set to NO

root$ cat /etc/sysconfig/firstboot  
 RUN_FIRSTBOOT=NO

Augeas is installed

[root@learn ~]# augtool ...
(more)
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-11-13 10:33:58 -0500

xtraclass gravatar image

Change

onlyif => "match other_value size > 0",

to

onlyif => "match RUN_FIRSTBOOT == NO",

or something similar.

edit flag offensive delete link more

Comments

Thanks for the tip, I've tried [onlyif => "match RUN_FIRSTBOOT == NO",] and [onlyif => "match RUN_FIRSTBOOT = NO"], and [onlyif => "match RUN_FIRSTBOOT NO",], none of them change the firstboot file. I see ...(more)

spuder gravatar imagespuder ( 2013-11-13 16:13:50 -0500 )edit
1

answered 2013-11-13 18:52:11 -0500

spuder gravatar image

Augeas is very quirky.

The following syntax works.

  augeas{ 'foo':
    context =>  "/files/etc/sysconfig/firstboot/",
    changes =>  "set RUN_FIRSTBOOT YES",
 }

As does this syntax:

  augeas{ 'foo':
    context =>  "/files/etc/sysconfig/firstboot/",
    changes =>  "set RUN_FIRSTBOOT YES",
    onlyif  =>  "match RUN_FIRSTBOOT not_include 'YES' ",
  }

However this syntax does not work

  augeas{ 'foo':
    context =>  "/files/etc/sysconfig/firstboot/",
    changes =>  "set RUN_FIRSTBOOT YES",
    onlyif  =>  "match RUN_FIRSTBOOT include 'NO' ",
  }

Removing the 'onlyif' type is a work around.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 2013-11-12 20:49:30 -0500

Seen: 6,210 times

Last updated: Nov 13 '13