Toggling yum repos to enabled, disabled


#1

hi.

i’m trying to wield the yumrepo cookbook to control the yum repos i dist
to my systems. by default, the yum_repository resource from the yum
cookbook marks the repo as enabled. so it seems i should be able to
toggle that and make the repo disabled by default. but my attempts are
failing.

this is the yum_repository block from the yumrepo::epel recipe:

yum_repository “epel” do
description "Extra Packages for Enterprise Linux"
key node[‘repo’][‘epel’][‘key’]
url node[‘repo’][‘epel’][‘url’]
mirrorlist true
action :add
end

above the action line i’ve tried adding ‘enabled “0”’ and ‘enabled 0’,
but the /etc/yum.repos.d/epel.repo shows up as “enabled=1”.

how do i toggle repos as enabled or disabled?

thanks,
kallen


#2

I ran into this problem yesterday. In the yum cookbook file
yum/providers/respository.rb, comment out the following line:
unless ::File.exists?("/etc/yum.repos.d/#{new_resource.repo_name}.repo")

I don’t understand the point of this line anyway.

Regards,
John

On Mon, Apr 2, 2012 at 4:05 PM, kallen@groknaut.net wrote:

hi.

i’m trying to wield the yumrepo cookbook to control the yum repos i dist
to my systems. by default, the yum_repository resource from the yum
cookbook marks the repo as enabled. so it seems i should be able to
toggle that and make the repo disabled by default. but my attempts are
failing.

this is the yum_repository block from the yumrepo::epel recipe:

yum_repository “epel” do
description "Extra Packages for Enterprise Linux"
key node[‘repo’][‘epel’][‘key’]
url node[‘repo’][‘epel’][‘url’]
mirrorlist true
action :add
end

above the action line i’ve tried adding ‘enabled “0”’ and ‘enabled 0’,
but the /etc/yum.repos.d/epel.repo shows up as “enabled=1”.

how do i toggle repos as enabled or disabled?

thanks,
kallen


John Alberts


#3

disabling the line you mentioned below helped me in another way, but
doesn’t address the problem i’m trying to solve:

with the unless condition in place in yum/providers/respository.rb, a
repo file that is already present on a system won’t get updated. i
don’t like that. :\ … so for that reason i’d want to disable that
unless (but i don’t like hand “patching” the code). are there other
options to updating a repo file in place without first calling
"action :remove", then “action :add” ?

back to the problem at hand, the result that i want is:

[yum.repos.d]# cat epel.repo

Generated by Chef for test-kallen

Local modifications will be overwritten.

[epel]
name=Extra Packages for Enterprise Linux
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
enabled=0

… i want “enabled=0” so yum doesn’t access that repo by default. but
there are times when i might want to call upon epel by doing
–enablerepo=epel. and in order to do that, epel.repo must be present
on the filesystem. aye?

thots?
kallen

On Mon, 02 Apr 2012, John Alberts wrote:

I ran into this problem yesterday. In the yum cookbook file
yum/providers/respository.rb, comment out the following line:
unless ::File.exists?("/etc/yum.repos.d/#{new_resource.repo_name}.repo")

I don’t understand the point of this line anyway.

Regards,
John

On Mon, Apr 2, 2012 at 4:05 PM, kallen@groknaut.net wrote:

hi.

i’m trying to wield the yumrepo cookbook to control the yum repos i dist
to my systems. by default, the yum_repository resource from the yum
cookbook marks the repo as enabled. so it seems i should be able to
toggle that and make the repo disabled by default. but my attempts are
failing.

this is the yum_repository block from the yumrepo::epel recipe:

yum_repository “epel” do
description "Extra Packages for Enterprise Linux"
key node[‘repo’][‘epel’][‘key’]
url node[‘repo’][‘epel’][‘url’]
mirrorlist true
action :add
end

above the action line i’ve tried adding ‘enabled “0”’ and ‘enabled 0’,
but the /etc/yum.repos.d/epel.repo shows up as “enabled=1”.

how do i toggle repos as enabled or disabled?


#4

ohhh hai. i figured out how to change the default value of the
attribute in yum/providers/respository.rb from my recipe. the answer
is not

enabled = ‘0’

nor is it

enabled => ‘0’

or other somesuch. the answer is:

enabled 0

full context:

yum_repository “epel” do
description "Extra Packages for Enterprise Linux"
key node[‘repo’][‘epel’][‘key’]
url node[‘repo’][‘epel’][‘url’]
mirrorlist true
action :add
enabled 0
end

go me.

thanks!

On Mon, 02 Apr 2012, kallen@groknaut.net wrote:

disabling the line you mentioned below helped me in another way, but
doesn’t address the problem i’m trying to solve:

with the unless condition in place in yum/providers/respository.rb, a
repo file that is already present on a system won’t get updated. i
don’t like that. :\ … so for that reason i’d want to disable that
unless (but i don’t like hand “patching” the code). are there other
options to updating a repo file in place without first calling
"action :remove", then “action :add” ?

back to the problem at hand, the result that i want is:

[yum.repos.d]# cat epel.repo

Generated by Chef for test-kallen

Local modifications will be overwritten.

[epel]
name=Extra Packages for Enterprise Linux
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
enabled=0

… i want “enabled=0” so yum doesn’t access that repo by default. but
there are times when i might want to call upon epel by doing
–enablerepo=epel. and in order to do that, epel.repo must be present
on the filesystem. aye?


#5

Ah, sorry about that. I didn’t mean to mislead you. My problem was I
needed to change the baseurl in the repofile, and that unless
statement made it impossible to update any property in the file. I
assumed the same thing was happening to you.
Glad to hear you found your problem.

John

On Mon, Apr 2, 2012 at 7:35 PM, kallen@groknaut.net wrote:

ohhh hai. i figured out how to change the default value of the
attribute in yum/providers/respository.rb from my recipe. the answer
is not

enabled = ‘0’

nor is it

enabled => ‘0’

or other somesuch. the answer is:

enabled 0

full context:

yum_repository “epel” do
description "Extra Packages for Enterprise Linux"
key node[‘repo’][‘epel’][‘key’]
url node[‘repo’][‘epel’][‘url’]
mirrorlist true
action :add
enabled 0
end

go me.

thanks!

On Mon, 02 Apr 2012, kallen@groknaut.net wrote:

disabling the line you mentioned below helped me in another way, but
doesn’t address the problem i’m trying to solve:

with the unless condition in place in yum/providers/respository.rb, a
repo file that is already present on a system won’t get updated. i
don’t like that. :\ … so for that reason i’d want to disable that
unless (but i don’t like hand “patching” the code). are there other
options to updating a repo file in place without first calling
"action :remove", then “action :add” ?

back to the problem at hand, the result that i want is:

[yum.repos.d]# cat epel.repo

Generated by Chef for test-kallen

Local modifications will be overwritten.

[epel]
name=Extra Packages for Enterprise Linux
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
enabled=0

… i want “enabled=0” so yum doesn’t access that repo by default. but
there are times when i might want to call upon epel by doing
–enablerepo=epel. and in order to do that, epel.repo must be present
on the filesystem. aye?


John Alberts


#6

On 04/02/2012 05:54 PM, John Alberts wrote:

I ran into this problem yesterday. In the yum cookbook file
yum/providers/respository.rb, comment out the following line:
unless ::File.exists?("/etc/yum.repos.d/#{new_resource.repo_name}.repo")

I don’t understand the point of this line anyway.
This check doesn’t seem to make sense. Essentially, “unless” means “not
if” when testing if the file exists. The template resource should be
idempotent without that File.exists check.

It could lead to undesired behavior if you want to update an already
managed repo file. I cannot say I have ever noticed this effect in all
the time I’ve used this resource, however. It could possibly be a bug.
Maybe I am reading this wrong, and it has another purpose.

Regards,
John

On Mon, Apr 2, 2012 at 4:05 PM,kallen@groknaut.net wrote:

hi.

i’m trying to wield the yumrepo cookbook to control the yum repos i dist
to my systems. by default, the yum_repository resource from the yum
cookbook marks the repo as enabled. so it seems i should be able to
toggle that and make the repo disabled by default. but my attempts are
failing.

this is the yum_repository block from the yumrepo::epel recipe:

yum_repository “epel” do
description "Extra Packages for Enterprise Linux"
key node[‘repo’][‘epel’][‘key’]
url node[‘repo’][‘epel’][‘url’]
mirrorlist true
action :add
end

above the action line i’ve tried adding ‘enabled “0”’ and ‘enabled 0’,
but the /etc/yum.repos.d/epel.repo shows up as “enabled=1”.

how do i toggle repos as enabled or disabled?

thanks,
kallen


#7

On 04/02/2012 05:54 PM, John Alberts wrote:

I ran into this problem yesterday. In the yum cookbook file
yum/providers/respository.rb, comment out the following line:
unless ::File.exists?("/etc/yum.repos.d/#{new_resource.repo_name}.repo")

I don’t understand the point of this line anyway.
This check doesn’t seem to make sense. Essentially, “unless” means “not
if” when testing if the file exists. The template resource within that
block should be idempotent without that File.exists check.

It could lead to undesired behavior if you want to update an already
managed repo. I cannot say I have noticed this effect in all the time
I’ve used this resource, however. It could be a bug. Unless I am
reading that wrong, and the line is intended for some other purpose.


#8

Well, I see now why the author of the yum cookbook decided to add that
unless statement. If it’s not there, the file is update every single
time, which of course then notifies the execute statement for running
yum makecache. This obviously ends up wasting a lot of time for every
chef run. I dont really understand why chef thinks the template has
changed therefore it thinks the file should be updated.
Is anyone else experiencing this if you have removed the 'unless
::File.exists?("/etc/yum.repos.d/#{new_resource.repo_name}.repo")'
line from yum/providers/repository.rb?

John

On Mon, Apr 2, 2012 at 9:23 PM, Eric G. Wolfe eric.wolfe@marshall.edu wrote:

On 04/02/2012 05:54 PM, John Alberts wrote:

I ran into this problem yesterday. In the yum cookbook file
yum/providers/respository.rb, comment out the following line:
unless ::File.exists?("/etc/yum.repos.d/#{new_resource.repo_name}.repo")

I don’t understand the point of this line anyway.

This check doesn’t seem to make sense. Essentially, “unless” means "not if"
when testing if the file exists. The template resource within that block
should be idempotent without that File.exists check.

It could lead to undesired behavior if you want to update an already managed
repo. I cannot say I have noticed this effect in all the time I’ve used
this resource, however. It could be a bug. Unless I am reading that wrong,
and the line is intended for some other purpose.


John Alberts


#9

Hello!

On Fri, Apr 6, 2012 at 8:07 AM, John Alberts john.m.alberts@gmail.com wrote:

Well, I see now why the author of the yum cookbook decided to add that
unless statement. If it’s not there, the file is update every single
time, which of course then notifies the execute statement for running
yum makecache. This obviously ends up wasting a lot of time for every
chef run. I dont really understand why chef thinks the template has
changed therefore it thinks the file should be updated.
Is anyone else experiencing this if you have removed the 'unless
::File.exists?("/etc/yum.repos.d/#{new_resource.repo_name}.repo")'
line from yum/providers/repository.rb?

This smells like a bug. Can you open a ticket with debug log output
from multiple runs? The whole log isn’t required, just the relevant
parts of a yum_repo resource getting configured.


Opscode, Inc
Joshua Timberman, Technical Program Manager
IRC, Skype, Twitter, Github: jtimberman


#10

Sure. Working on that now.

John

On Fri, Apr 6, 2012 at 10:29 AM, Joshua Timberman joshua@opscode.com wrote:

Hello!

On Fri, Apr 6, 2012 at 8:07 AM, John Alberts john.m.alberts@gmail.com wrote:

Well, I see now why the author of the yum cookbook decided to add that
unless statement. If it’s not there, the file is update every single
time, which of course then notifies the execute statement for running
yum makecache. This obviously ends up wasting a lot of time for every
chef run. I dont really understand why chef thinks the template has
changed therefore it thinks the file should be updated.
Is anyone else experiencing this if you have removed the 'unless
::File.exists?("/etc/yum.repos.d/#{new_resource.repo_name}.repo")'
line from yum/providers/repository.rb?

This smells like a bug. Can you open a ticket with debug log output
from multiple runs? The whole log isn’t required, just the relevant
parts of a yum_repo resource getting configured.


Opscode, Inc
Joshua Timberman, Technical Program Manager
IRC, Skype, Twitter, Github: jtimberman


John Alberts


#11

So… apparently I was mistaken. Something must have changed in
these repository files when I was looking at them before, because now
I can see everything is working like it’s supposed to. The repo files
are not being regenerated each time like I thought. Sorry for the
extra noise on the mailing list.

John

On Fri, Apr 6, 2012 at 10:53 AM, John Alberts john.m.alberts@gmail.com wrote:

Sure. Working on that now.

John

On Fri, Apr 6, 2012 at 10:29 AM, Joshua Timberman joshua@opscode.com wrote:

Hello!

On Fri, Apr 6, 2012 at 8:07 AM, John Alberts john.m.alberts@gmail.com wrote:

Well, I see now why the author of the yum cookbook decided to add that
unless statement. If it’s not there, the file is update every single
time, which of course then notifies the execute statement for running
yum makecache. This obviously ends up wasting a lot of time for every
chef run. I dont really understand why chef thinks the template has
changed therefore it thinks the file should be updated.
Is anyone else experiencing this if you have removed the 'unless
::File.exists?("/etc/yum.repos.d/#{new_resource.repo_name}.repo")'
line from yum/providers/repository.rb?

This smells like a bug. Can you open a ticket with debug log output
from multiple runs? The whole log isn’t required, just the relevant
parts of a yum_repo resource getting configured.


Opscode, Inc
Joshua Timberman, Technical Program Manager
IRC, Skype, Twitter, Github: jtimberman


John Alberts


John Alberts


#12

No worries, thanks for double checking!

On Fri, Apr 6, 2012 at 12:28 PM, John Alberts john.m.alberts@gmail.com wrote:

So… apparently I was mistaken. Something must have changed in
these repository files when I was looking at them before, because now
I can see everything is working like it’s supposed to. The repo files
are not being regenerated each time like I thought. Sorry for the
extra noise on the mailing list.

John

On Fri, Apr 6, 2012 at 10:53 AM, John Alberts john.m.alberts@gmail.com wrote:

Sure. Working on that now.

John

On Fri, Apr 6, 2012 at 10:29 AM, Joshua Timberman joshua@opscode.com wrote:

Hello!

On Fri, Apr 6, 2012 at 8:07 AM, John Alberts john.m.alberts@gmail.com wrote:

Well, I see now why the author of the yum cookbook decided to add that
unless statement. If it’s not there, the file is update every single
time, which of course then notifies the execute statement for running
yum makecache. This obviously ends up wasting a lot of time for every
chef run. I dont really understand why chef thinks the template has
changed therefore it thinks the file should be updated.
Is anyone else experiencing this if you have removed the 'unless
::File.exists?("/etc/yum.repos.d/#{new_resource.repo_name}.repo")'
line from yum/providers/repository.rb?

This smells like a bug. Can you open a ticket with debug log output
from multiple runs? The whole log isn’t required, just the relevant
parts of a yum_repo resource getting configured.


Opscode, Inc
Joshua Timberman, Technical Program Manager
IRC, Skype, Twitter, Github: jtimberman


John Alberts


John Alberts


Opscode, Inc
Joshua Timberman, Technical Program Manager
IRC, Skype, Twitter, Github: jtimberman