Score:2

How to set value of ipa_hostname directive in sssd.conf using Augeas

tn flag

Using Puppet versions

Master: puppetserver 6.7

Client: puppet-agent 6.10

I have other Augeas code in other modules that works just fine.

Example sssd.conf

[sssd]
services = nss, sudo, pam, ssh
config_file_version = 2
domains = abc.def.net

[domain/abc.def.net]
cache_credentials = True
id_provider = ipa
auth_provider = ipa
access_provider = ipa
ipa_hostname = xxx.abc.def.net

...

I need to update/verify the ipa_hostname value in the [domain/abc.def.net] section. I can't figure out what I'm doing wrong with this augeas code

    augeas { "sssd.conf":
      context => "/files/etc/sssd/sssd.conf",
      changes => [
                "set ipa_hostname xxx",
                ],
      notify    => Service["sssd"]
    }

Here is the debug output:

Debug: Augeas[sssd.conf](provider=augeas): Opening augeas with root /, lens path , flags 64
Debug: Augeas[sssd.conf](provider=augeas): Augeas version 1.12.0 is installed
Debug: Augeas[sssd.conf](provider=augeas): Will attempt to save and only run if files changed
Debug: Augeas[sssd.conf](provider=augeas): sending command 'set' with params ["/files/etc/sssd/sssd.conf/ipa_hostname", "no"]
Debug: Augeas[sssd.conf](provider=augeas): Put failed on one or more files, output from /augeas//error:
Debug: Augeas[sssd.conf](provider=augeas): /augeas/files/etc/sssd/sssd.conf/error = put_failed
Debug: Augeas[sssd.conf](provider=augeas): /augeas/files/etc/sssd/sssd.conf/error/path = /files/etc/sssd/sssd.conf/
Debug: Augeas[sssd.conf](provider=augeas): /augeas/files/etc/sssd/sssd.conf/error/lens = /opt/puppetlabs/puppet/share/augeas/lenses/dist/sssd.aug:33.13-.53:
Debug: Augeas[sssd.conf](provider=augeas): /augeas/files/etc/sssd/sssd.conf/error/message = Failed to match tree under /

     { "target" = "sssd" }
     { "target" = "domain/test.hfgs.net" }
     { "target" = "nss" }
     { "target" = "pam" }
     { "target" = "sudo" }
     { "target" = "autofs" }
     { "target" = "ssh" }
     { "target" = "pac" }
     { "ipa_hostname" = "xxx" }

  with pattern
   (    { /#comment/ = /[^\t\n\r ].*[^\t\n\r ]|[^\t\n\r ]/ }
      | { })*
    { /target/ = /[^]\n\r]+/ }*

Debug: Augeas[sssd.conf](provider=augeas): Closed the augeas connection
Error: /Stage[main]/Testaugeas/Augeas[sssd.conf]: Could not evaluate: Save failed, see debug output for details
Score:2
tn flag

Took a couple days but I finally figured this out. I added some extra code to show how to address another section in the same file. Hope this helps.

  $domain = abc.net
  augeas { "sssd.conf ipa_hostname":
    lens    => 'sssd.lns',
    incl    => '/etc/sssd/sssd.conf',
    changes => [
      "set target[ . = 'sssd']/services 'nss, sudo, pam, ssh'",
      "set target[ . = 'sssd']/config_file_version 2",
      "set target[ . = 'sssd']/domains ${domain}",
      "set target[ . = 'domain/${domain}']/ipa_hostname ${hostname}.${domain}",
    ],
    notify  => Service["sssd"]
  }
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.