Augeas file line edit please help

401 views
Skip to first unread message

kdo

unread,
Jan 23, 2013, 11:28:34 PM1/23/13
to puppet...@googlegroups.com
what i thought would be a simple edit using augeas is turning out to not be so straight forward, can anyone please help ?

the plan is to edit sendmail.cf and change the default DS to DShostname.domain

class mail {
      $key = DS

      service {
           'sendmail':;
      }
      augeas { "sendmail.cf/$key":
context => "/files/etc/mail/sendmail.cf",
changes => "set $key mail.hostname.domain",
notify => Service['sendmail'];
}
}


debug: Augeas[sendmail.cf/DS](provider=augeas): Opening augeas with root /, lens path , flags 0
debug: Augeas[sendmail.cf/DS](provider=augeas): Augeas version 0.9.0 is installed
debug: Augeas[sendmail.cf/DS](provider=augeas): Will attempt to save and only run if files changed
debug: Augeas[sendmail.cf/DS](provider=augeas): sending command 'set' with params ["/files/etc/mail/sendmail.cf/DS", "mail.hostname.domain"]
debug: Augeas[sendmail.cf/DS](provider=augeas): Skipping because no files were changed
debug: Augeas[sendmail.cf/DS](provider=augeas): Closed the augeas connection




kdo

unread,
Jan 24, 2013, 1:04:12 AM1/24/13
to puppet...@googlegroups.com
might be easier to just use sed in a exec statement to replace all occurances of DS with DShostname.domain 

Ex:
sed 's/DS/c DShostname.domain' /etc/mail/sendmail.cf

Dominic Cleal

unread,
Jan 24, 2013, 5:32:03 AM1/24/13
to puppet...@googlegroups.com
On 24/01/13 04:28, kdo wrote:
> what i thought would be a simple edit using augeas is turning out to not
> be so straight forward, can anyone please help ?
>
> the plan is to edit sendmail.cf and change the default DS to
> DShostname.domain
>
> class mail {
> $key = DS
>
> service {
> 'sendmail':;
> }
> augeas { "sendmail.cf/$key":
> context => "/files/etc/mail/sendmail.cf",
> changes => "set $key mail.hostname.domain",
> notify => Service['sendmail'];
> }
> }

There's no Augeas lens for sendmail.cf files. From Puppet 3, it'll now
warn you if using context and a file wasn't loaded. Otherwise check in
augtool with "print" to see if the file can be loaded.

Maybe use stdlib's file_line type?

--
Dominic Cleal
Red Hat Engineering
Reply all
Reply to author
Forward
0 new messages