augeas failure - any ideas?

1,206 views
Skip to first unread message

James Green

unread,
Dec 10, 2014, 9:59:27 AM12/10/14
to puppet-users
  augeas { 'postfix-master-smtp-inet' :
    context => "/files/etc/postfix/master.cf",
    changes => [
      "set smtp[type = inet]/private n",
      "set smtp[type = inet]/unprivileged -",
      "set smtp[type = inet]/chroot n",
      "set smtp[type = inet]/wakeup -",
      "set smtp[type = inet]/limit 10",
      'set smtp[type = inet]/command "smtpd -o content_filter=smtptorestgw:dummy"',
    ],
    require => Package['postfix'],
    notify  => Service['postfix'],
  }

On the server:

Debug: Augeas[postfix-master-smtp-inet](provider=augeas): Opening augeas with root /, lens path , flags 32
Debug: Augeas[postfix-master-smtp-inet](provider=augeas): Augeas version 1.2.0 is installed
Debug: Augeas[postfix-master-smtp-inet](provider=augeas): Will attempt to save and only run if files changed
Debug: Augeas[postfix-master-smtp-inet](provider=augeas): sending command 'set' with params ["/files/etc/postfix/master.cf/smtp[type = inet]/private", "n"]
Debug: Augeas[postfix-master-smtp-inet](provider=augeas): sending command 'set' with params ["/files/etc/postfix/master.cf/smtp[type = inet]/unprivileged", "-"]
Debug: Augeas[postfix-master-smtp-inet](provider=augeas): sending command 'set' with params ["/files/etc/postfix/master.cf/smtp[type = inet]/chroot", "n"]
Debug: Augeas[postfix-master-smtp-inet](provider=augeas): sending command 'set' with params ["/files/etc/postfix/master.cf/smtp[type = inet]/wakeup", "-"]
Debug: Augeas[postfix-master-smtp-inet](provider=augeas): sending command 'set' with params ["/files/etc/postfix/master.cf/smtp[type = inet]/limit", "10"]
Debug: Augeas[postfix-master-smtp-inet](provider=augeas): sending command 'set' with params ["/files/etc/postfix/master.cf/smtp[type = inet]/command", "smtpd -o content_filter=smtptorestgw:dummy"]
Debug: Augeas[postfix-master-smtp-inet](provider=augeas): Put failed on one or more files, output from /augeas//error:
Debug: Augeas[postfix-master-smtp-inet](provider=augeas): /augeas/files/etc/postfix/master.cf/error = put_failed
Debug: Augeas[postfix-master-smtp-inet](provider=augeas): /augeas/files/etc/postfix/master.cf/error/path = /files/etc/postfix/master.cf/smtp
Debug: Augeas[postfix-master-smtp-inet](provider=augeas): /augeas/files/etc/postfix/master.cf/error/lens = /usr/share/augeas/lenses/dist/postfix_master.aug:39.18-47.21:
Debug: Augeas[postfix-master-smtp-inet](provider=augeas): /augeas/files/etc/postfix/master.cf/error/message = Failed to match
    { /type/ = /inet|unix|fifo|pass/ }{ /private/ = /y|n|-/ }{ /unprivileged/ = /y|n|-/ }{ /chroot/ = /y|n|-/ }{ /wakeup/ = /([0-9]+|-)\\??/ }{ /limit/ = /([0-9]+|-)\\??/ }{ /command/ = /[!$,-.0-:=@-Z_a-{}]([!$,-.0-:=@-Z_a-{}]|[]"\/[]| )*([!$,-.0-:=@-Z_a-{}]|[]"\/[])([\t ]*\n[\t ]+[!$,-.0-:=@-Z_a-{}]([!$,-.0-:=@-Z_a-{}]|[]"\/[]| )*([!$,-.0-:=@-Z_a-{}]|[]"\/[]))*/ }
  with tree
    { "private" = "n" }
Debug: Augeas[postfix-master-smtp-inet](provider=augeas): Closed the augeas connection
Error: /Stage[main]/custom_postfix::Sasl/Augeas[postfix-master-smtp-inet]: Could not evaluate: Saving failed, see debug

Any ideas?

Thanks,

James

James Green

unread,
Dec 10, 2014, 10:30:18 AM12/10/14
to puppet-users
It's because the file doesn't yet have an uncommented smtp line. It seems augeas cannot uncomment the line or put a new one in. I am therefore unsure how augeas can be used to ensure the line exists.

Do people have to work around this by supplying template fragments or something?

David Lutterkort

unread,
Dec 19, 2014, 1:42:31 PM12/19/14
to puppet...@googlegroups.com


On Wednesday, December 10, 2014 7:30:18 AM UTC-8, James Green wrote:
It's because the file doesn't yet have an uncommented smtp line. It seems augeas cannot uncomment the line or put a new one in. I am therefore unsure how augeas can be used to ensure the line exists.

Do people have to work around this by supplying template fragments or something?

There's two problems with that code:
  1. It has to deal with both the situation where an inet smtp entry already exists and where one needs to be created
  2. The expression 'smtp[type = inet]' has a type: as written it says "find the smtp node in the tree that has a type and an inet child whose value is equal. What you want is 'smtp[type = "inet"]'
Assuming you only want one entry smtp[type = 'inet'] in your config, the following should work:

 augeas { 'postfix-master-smtp-inet' :
  context => "/files/etc/postfix/master.cf",
  changes => [
    # Remove, then recreate the smtp entry for type inet; this will not lead
    # to any changes in the file if the correct entry was there already since
    # Augeas will notice that no real change was made and skip writing the file
    "rm smtp[type = 'inet']",
    "set smtp[last()+1]/type inet",

    "set smtp[type = inet]/private n",
    "set smtp[type = inet]/unprivileged -",
    "set smtp[type = inet]/chroot n",
    "set smtp[type = inet]/wakeup -",
    "set smtp[type = inet]/limit 10",
    'set smtp[type = inet]/command "smtpd -o content_filter=smtptorestgw:dummy"',
    ],
  require => Package['postfix'],
  notify  => Service['postfix'],
}

I haven't tried the above in Puppet, but the equivalent in augtool works. You might also want to open an issue against augeasproviders since this might be worthwhile as a separate provider there (Writing augeas resources is a bit like writing your own provider, augeasproviders builds types/providers that remove that headache)

David

Reply all
Reply to author
Forward
0 new messages