Ask Your Question
1

augeas automaster.aug

asked 2014-03-19 11:53:20 -0500

mikek gravatar image

updated 2014-03-19 22:41:38 -0500

spuder gravatar image

I'm trying to use the automaster.aug lens to change /etc/auto.master I'm having some trouble understanding how it can work in Puppet.

E.g., I want to do something like this:

augeas { "automaster-${name}":
    lens => 'automaster.aug',
    incl => '/etc/auto.master',
    changes => "set /files/etc/auto.master/next() ${mountpoint};
                set /files/etc/auto.master/next()/map /etc/auto.${name}",
    onlyif => "match /files/etc/auto.master/*/map not_include /etc/auto.${name}";
}

There's no next() function and I'm not sure I can run more than one command. Trouble is the nodes are enumerated, and I'm ... (more)

edit retag flag offensive close merge delete

Comments

Most likely you'll need to repeat this for every node. Is that an option?

spuder gravatar imagespuder ( 2014-03-19 22:48:28 -0500 )edit

Every Augeas node in the automount file? It would be an option if there were a way to determine how many nodes there were and iterate over them. I'm ...(more)

mikek gravatar imagemikek ( 2014-03-20 04:40:46 -0500 )edit

I'm not concerned about which Augeas node in the file has the entry, just that one of them does. The match statement successfully determines that and even outputs the ...(more)

mikek gravatar imagemikek ( 2014-03-20 04:42:15 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-04-06 03:01:19 -0500

Use 01 instead of next (see https://github.com/hercules-team/augeas/wiki/Adding-nodes-to-the-tree ).

Also, your Puppet syntax is wrong. changes is an array of commands, not a semi-colon separated list. You can also make use of the context parameter. Finally, the onlyif syntax is wrong, too.

See http://projects.puppetlabs.com/projects/1/wiki/puppet_augeas for the Puppet augeas type reference.

augeas { "automaster-${name}":
    context => '/files/etc/auto.master',
    changes => [
      "set ./01 '${mountpoint}'",
      "set ./01/map '/etc/auto.${name}'",
    ],
    onlyif => "match *[.='${mountpoint}' and map='/etc/auto.${name}'] size==0";
}
edit flag offensive delete link more
0

answered 2014-03-20 08:59:42 -0500

mikek gravatar image

I set aside augeas for this and used an exec.

exec { "echo /auto /etc/auto.${name} >> /etc/auto.master":
    unless => "grep -e '\\/auto\\s\\+\\/etc\\/auto.${name}' /etc/auto.master",
}

Would still love to know how to do it in augeas, it seems like the right tool for the job, maybe just a little too complex for this kind of change right now.

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

1 follower

Stats

Asked: 2014-03-19 11:53:20 -0500

Seen: 316 times

Last updated: Apr 06 '14