There's several issues there.
First, while defnode
takes an optional third argument (a value) in augtool
, this argument is mandatory in Ruby/Puppet. You can however set it to an empty string.
Second, the $user
variable is parsed by Puppet because you're using double quotes, so Augeas doesn't receive it (it's empty). You must either use single quotes or escape the dollar sign. In general, it is recommended to use single quotes in Puppet unless you need variables to be expanded.
Third, it'll be better to use incl
and lens
rather than root
. You will benefit from an automatic context
in Puppet, too:
augeas { 'nexus_user_newadmin':
lens => 'Xml.lns',
incl => '/usr/local/nexus/conf/security.xml',
changes => [
'defnode user security/users/user[id/#text="newadmin"] ""',
'set $user/id/#text "newadmin"',
'set $user/firstName/#text "first name"',
'set $user/lastName/#text "last name"',
'set $user/password/#text "passhere"',
'set $user/status/#text "active"',
'set $user/email/#text "test@domain.com"',
],
}