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
<https://github.com/hercules-team/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
> On 10 December 2014 at 14:59, James Green <[email protected]
> <javascript:>> wrote:
>
>> 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
>> <http://master.cf/smtp%5Btype> = inet]/private", "n"]
>> Debug: Augeas[postfix-master-smtp-inet](provider=augeas): sending command
>> 'set' with params ["/files/etc/postfix/master.cf/smtp[type
>> <http://master.cf/smtp%5Btype> = inet]/unprivileged", "-"]
>> Debug: Augeas[postfix-master-smtp-inet](provider=augeas): sending command
>> 'set' with params ["/files/etc/postfix/master.cf/smtp[type
>> <http://master.cf/smtp%5Btype> = inet]/chroot", "n"]
>> Debug: Augeas[postfix-master-smtp-inet](provider=augeas): sending command
>> 'set' with params ["/files/etc/postfix/master.cf/smtp[type
>> <http://master.cf/smtp%5Btype> = inet]/wakeup", "-"]
>> Debug: Augeas[postfix-master-smtp-inet](provider=augeas): sending command
>> 'set' with params ["/files/etc/postfix/master.cf/smtp[type
>> <http://master.cf/smtp%5Btype> = inet]/limit", "10"]
>> Debug: Augeas[postfix-master-smtp-inet](provider=augeas): sending command
>> 'set' with params ["/files/etc/postfix/master.cf/smtp[type
>> <http://master.cf/smtp%5Btype> = 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
>>
>>
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/397f87d4-8afb-49a3-9ab2-f7e5538f4bfe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.