augeas to setm enabled=0 in yum repos?

165 views
Skip to first unread message

Guy Matz

unread,
Apr 16, 2015, 9:22:14 AM4/16/15
to puppet...@googlegroups.com
Hi!  I'm trying to disable yum repos using augeas and can't quite figure out how to set enabled=0 for all repos in a yum file.  I've got this:

  augeas { 'disable all repos in CentOS Base':
    context => '/files/etc/yum.repos.d/CentOS-Base.repo',
    changes => [
      'setm */enabled . 0'
    ]
  }

Which works if a repo has an enabled line.  The problem is that it doesn't *add* an enabled line to a repo that does not.  For example, the enabled line here will get set to enabled=0:
[centosplus]
name=CentOS-$releasever - Plus
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

but an enabled=0 will not get added to this:
[base]
name=CentOS-$releasever - Base
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6


Anyone know how/if I can hit these two birds with one stone?

Thanks!!

Guy Matz

unread,
Apr 16, 2015, 12:00:47 PM4/16/15
to puppet...@googlegroups.com
This works with augtool but not in puppet:

  augeas { 'disable all other repos in CentOS Base':
    context => '/files/etc/yum.repos.d/CentOS-Base.repo',
    changes => [
      'setm /files/etc/yum.repos.d/CentOS-Base.repo/* enabled 0'
    ]
  }

Any thoughts would be appreciated!

Guy Matz

unread,
Apr 16, 2015, 12:15:32 PM4/16/15
to puppet...@googlegroups.com
No, I was wrong . .  that doesn't work with augtool.  It seems to, but won't save . . . 

Guy Matz

unread,
Apr 16, 2015, 12:55:31 PM4/16/15
to puppet...@googlegroups.com
OK!  This seems to work:
setm /files/etc/yum.repos.d/CentOS-Base.repo/*[label() != '#comment'] enabled 0"

But for a set of stanzas like this:
[base]
name=CentOS-$releasever - Base
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#released updates 
[updates]
blah, blah blah

the 'enabled=0' line gets added after the comment, e.g.
[base]
name=CentOS-$releasever - Base
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#released updates 
enabled=0
[updates]
blah, blah blah

When it would be sooooo much better if the line got added above the comment under the gpgkey line . . .

I'm nitpicking here, I know!!  Any suggestions?

Thanks so much for all of the help up to this point!  ;-)
Reply all
Reply to author
Forward
0 new messages