Ask Your Question

file_line cannot write enabled=0 to a .repo file?

asked 2016-02-04 00:33:08 -0600

Good morning everyone!

I'm having a small problem that's been driving me crazy and I simply cannot work out the logic in it! I've been trying to simply disable a repo (specifically epel.repo) by replacing enabled=1 with enabled=0 using file_line...

    file_line { 'replace enabled=1 with enabled=0 in /etc/yum.repos.d/epel.repo':
            ensure => present,
            path => '/etc/yum.repos.d/epel.repo',
            line => "enabled=0",
            match => "enabled=1",

The above code simply doesn't work. If I change the line value to enabled=anythingintheworld it works but for some reason, enabled=0 doesn't.

Any ideas for a puppet novice?



edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-02-04 09:42:06 -0600

That's a great question, because I just tried your code and it works for me. What version of Puppet & Stdlib are you using?

Also, why use file_line here, which is usually a bit of a hack. Why not use the Yumrepo type:

yumrepo { 'epel':
  enabled => '0',
edit flag offensive delete link more


Hi Alex, I didn't use the yumrepo type because to be perfectly honest I didn't know about it and it didn't come up in my standard Google search. I tested it and it worked so thank you very much. For reference I was using Stdlib version v4.11.0 and Puppet 4.3.1. Strange? Thanks for your help! Dan gravatar ( 2016-02-04 10:19:00 -0600 )edit

It is strange, I may see if I can reproduce.

Alex Harvey gravatar imageAlex Harvey ( 2016-02-04 10:44:42 -0600 )edit

I am just now running into this. I wanted to ensure all repos inside the repofile were disabled. But, the file_line seemed to only work if I changed the line parameter to something without an equals sign. Then I could re-run it with a match to the temporary word and have line set to enabled=0.

dgkhd06 gravatar imagedgkhd06 ( 2017-04-06 12:46:45 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2016-02-04 00:33:08 -0600

Seen: 67 times

Last updated: Feb 04 '16