Ask Your Question
0

Should I have used yumrepo here?

asked 2014-02-14 15:57:07 -0500

Red Cricket gravatar image

I have this module to install jenkins for me ...

class red::profile::jenkins {
        package { yum:
                ensure => present,
        }

        file { "jenkins.repo" :
                        path    =>      "/etc/yum.repos.d/jenkins.repo"
                ,       owner   =>      "root"
                ,       group   =>      "root"
                ,       mode    =>      0440
                ,       require =>      [ Package["yum"], Exec['import_key']]
                ,       ensure  =>      file
                ,       backup  =>      false
        }

        exec { "download_repo": 
                command => '/usr/bin/wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo'
        }

        exec { "import_key": 
                        command => '/bin/rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key'
                ,       require =>      Exec["download_repo"]
        }

        package { jenkins:
                        ensure  => present
                ,       require => File["jenkins.repo"]
        }

        service { jenkins:
                        ensure  => running
                ,       require => package ["jenkins"]
        }
}

... it seems to work fine, but ... (more)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2014-02-15 16:06:31 -0500

Stefan gravatar image

If you are looking for comments on your code there are a few observations

  1. The first package resource doesn't make a lot of sense because if yum is not present, puppet will not be able to install it on a yum system (or do you run this on a system that does not originally use yum as a package manager?)
  2. the way you format your code is valid, but it does not follow the style guide which makes it harder for others to read
  3. The exec resource to download the repo file runs every time you run puppet which ...
(more)
edit flag offensive delete link more

Comments

Excellent points Stefan. Thank you.

Red Cricket gravatar imageRed Cricket ( 2014-02-17 10:42:16 -0500 )edit
2

answered 2014-02-14 22:12:24 -0500

spuder gravatar image

The code you have written is fine.

While using yumrepo may be more 'proper', it won't make the code much cleaner, shorter, robust, or easier to read.

For comparison, here is a good example of yumrepo

edit flag offensive delete link more

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-02-14 15:57:07 -0500

Seen: 231 times

Last updated: Feb 15 '14