Ask Your Question
0

Repository Deployment OEL6,OEL5,RHEL5,RHEL6,

asked 2014-10-03 21:25:17 -0500

Anil gravatar image

Hello All,

I am in the process of deploying *.repo files to oracle linux and a few red hat servers (we have solaris as well but that is another story). The problem i am facing is that the servers do not have access to the internet, and these servers have *.repo files from the existing operating system installation so when a package update runs it check all repos on the servers and timeout before it finally reaches the local repo (fails in some cases and make puppet out of sync with foreman). Is there a solution where subsequent puppet classes that are created can specify which repo file it can use. Please assist and bear in mind i suck at programming thank you in advance.

THE MANIFEST FOR THE REPOS

[root@foreman manifests]# cat init.pp
class repository{
                                case $operatingsystem {
                OracleLinux, OEL:            {
                                                case $operatingsystemmajrelease {
                                                "5": {
                                                $repo_file = 'systeam.oel5.repo'
                                                file { 'systeam.repo':
                        path => '/etc/yum.repos.d/systeam.repo',
                        ensure => file,
                        source => "puppet:///modules/repository/${repo_file}"
                                                        }
                                                                }
                                                "6": {
                                                        $repo_file = 'systeam.oel6.repo'
                                                file { 'systeam.repo':
                        path => '/etc/yum.repos.d/systeam.repo',
                        ensure => file,
                        source => "puppet:///modules/repository/${repo_file}"
                                                        }
                                                        }
                                                                                                                }

                                        }

                Redhat:                 {
                                                case $operatingsystemmajrelease {
                                                "5": {
                                                $repo_file = 'systeam.oel5.repo'
                                                file { 'systeam.repo':
                        path => '/etc/yum.repos.d/systeam.repo',
                        ensure => file,
                        source => "puppet:///modules/repository/${repo_file}"
                                                        }
                                                        }
                                                "6": {
                                                $repo_file = 'systeam.oel6.repo'
                                                file { 'systeam.repo':
                        path => '/etc/yum.repos.d/systeam.repo',
                        ensure => file,
                        source => "puppet:///modules/repository/${repo_file}"
                                                        }

                                                                }
                                                                                                                }
                                        }

                                CentOS:                 {
                                                case $operatingsystemmajrelease {
                                                "5": {
                                                $repo_file = 'systeam.oel5.repo'
                                                file { 'systeam.repo':
                        path => '/etc/yum.repos.d/systeam.repo',
                        ensure => file,
                        source => "puppet:///modules/repository/${repo_file}"
                                                        }
                                                        }
                                                "6": {
                                                $repo_file = 'systeam.oel6.repo'
                                                file { 'systeam.repo':
                        path => '/etc/yum.repos.d/systeam.repo',
                        ensure => file,
                        source => "puppet:///modules/repository/${repo_file}"
                                                        }

                                                                }
                                                                                                                }
                                        }

                default:                {
                                fail("Unrecognized operating system")
                                         }
                }
}

==================================================================================

PACKAGE UPDATE CLASS

class bashupdate{
package { "bash":
    provider => "yum",
    ensure => "latest"
}
}
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2014-10-08 13:50:37 -0500

cbarbour gravatar image

updated 2014-10-08 14:31:44 -0500

I would be inclined to purge the existing repositories. On current releases of Puppet, you can accomplish this using a file resource to remove the repo files themselves, and file resources to ensure the repositories you want aren't removed.

file { '/etc/yum.repos.d/':
  ensure  => 'directory',
  purge   => 'true',
  recurse => 'true',
}

file { '/etc/yum.repos.d/rhel5updates.repo':
  ensure => 'file',
}

file { '/etc/yum.repos.d/rhel6updates.repo':
  ensure => 'file',
}

This approach is compatible with the use of Yumrepo resources as well. You still need the file resources with this approach, otherwise the directory purge will try to remove any files the Yumrepo resource creates.

Also, consider using Virtual resources instead of conditional logic. Declare your resources virtually using the yumrepo type, tag the resource based on what platform they apply to, and realize them based on facts. This approach is much cleaner and more flexible than using conditional logic.

E.g.:

@yumrepo { 'rhel5updates':
  tags => 'Redhat-5'
}

@yumrepo { 'rhel6updates':
  tags => 'Redhat-6'
}

Yumrepo <| tags == "$::osfamily-$::operatingsystemrelease" |>
edit flag offensive delete link more
1

answered 2014-10-04 12:23:12 -0500

jonn gravatar image

You might want to take a look at the yumrepo type instead of using file resources. This will allow you to manage individual attributes of each repository, so it's way more flexible.

To disable your annoying OS-provided repos, you could do something like this:

yumrepo { 'annoying-repo':
   enabled => false
}

or, if you wanted to remove it completely, you could do this:

yumrepo { 'annoying-repo':
   ensure => absent
}

If you want to get a list of the yum repos on your system that Puppet knows about and is able to manage, then try running this command:

$ sudo puppet resource yumrepo
edit flag offensive delete link more
0

answered 2014-10-06 11:13:21 -0500

Anil gravatar image

Hello Jonn,

thank you for the response on this however the questions i now have is that

  1. I would basically have to go on a few of the servers to get the list of repos to add to that class is there a faster way)?
  2. How would puppet react if it runs on a server that does not have that repo that is listed in the class. would it intelligently move on or would it throw an error?
  3. Is there a way to write the class to say "disable/remove all repo not equal to awesome.repo"?
edit flag offensive delete link more

Comments

Support for purging yumrepo resources has recently been added from the looks of things (see https://tickets.puppetlabs.com/browse/PUP-1066) but it may not be in the version of Puppet that you're running right now. http://projects.puppetlabs.com/issues/9293 has a workaround that may work for you?

jonn gravatar imagejonn ( 2014-10-06 11:25:43 -0500 )edit

thank you for the assistance i will look into this

Anil gravatar imageAnil ( 2014-10-07 14:13:18 -0500 )edit

For older releases of Puppet, you can purge unmanaged repositories using a combination of the tidy meta-type to remove unmanaged files in /etc/yum.repos.d, file resources to mark the repos you actually want to keep, and yumrepo to configure those marked repos.

cbarbour gravatar imagecbarbour ( 2014-10-08 13:27:51 -0500 )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

1 follower

Stats

Asked: 2014-10-03 20:52:47 -0500

Seen: 496 times

Last updated: Oct 08 '14