Why does the Augeas Puppet resource type require 3 arguments for defnode?

I am trying to add or update a user in an xml configuration file using the augeas resource type in Puppet, here is the manifest:

  augeas { "nexus_user_newadmin":
    lens    => "Xml.lns",
    incl    => "security.xml",
    root    => "/usr/local/nexus/conf",
    changes => [
      "defnode user /files/security.xml/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'",
    ],
  }

The xml file looks like this:

<?xml version="1.0"?>
<security>
          <users>
            ...
            <user>
              <id>deployment</id>
              <firstName>Deployment</firstName>
              <lastName>User</lastName>
              <password>somepasshere</password>
              <status>active</status>
              <email>changeme1@yourcompany.com</email>
            </user>
          </users>
</security>

I get the following error after running the manifest:

Main/Augeas[nexus_user_newadmin]: Could not evaluate: missing string argument 3 for defnode

It appears that the defnode command requires 3 required arguments when used from a puppet, but only 2 (and 1 extra) when used from augtool. ( see my original post )

How can I overcome these limitations in implementing augeas in Puppet?

+1
source share
1 answer

There are a few questions.

-, defnode () augtool, Ruby/Puppet. .

-, $user Puppet, , Augeas ( ). , . , Puppet, .

-, incl lens, root. context Puppet:

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"',
  ],
}
+5

Source: https://habr.com/ru/post/1523573/


All Articles