Friday, April 17, 2015

Jenkins(winstone way) Puppet install

This content shows puppet setup of jenkins winstone way. This script follows http://pkg.jenkins-ci.org/debian/ and  http://pkg.jenkins-ci.org/redhat/

root@puppet:/etc/puppet/modules/jenkins/manifests# cat init.pp
class jenkins {
    
case $::operatingsystem {
   'RedHat', 'CentOS', 'Scientific', 'OracleLinux', 'OEL': {
     $service_name = "jenkins"
     #java install
     #class { 'java': }


     if ! defined(Service['jenkins']){
     include jenkins::get_jenkins_centos
     }
     # do something RHEL specific

     #running service
      # running tomcat8
     service { 'jenkins':
      provider => "systemd",
      name => $service_name,
      ensure => running,
      enable => true,
     }

   }

   'ubuntu': {
     $service_name = "jenkins"
     #java install
     #class { 'java': }
     #$java_home = "/usr/lib/jvm/java-7-oracle"

     if ! defined(Service['jenkins']){
     include jenkins::get_jenkins_ubuntu
     }

     #package { 'jenkins':
     #   ensure => 'installed',
     #   install_options => [ '--force-yes' ],
     #}

      # running tomcat8
     service { 'jenkins':
      name => $service_name,
      ensure => running,
      enable => true,
     }
    
   }
   default: {
     # ...
   }
 }
}





root@puppet:/etc/puppet/modules/jenkins/manifests# cat get_jenkins_ubuntu.pp
class jenkins::get_jenkins_ubuntu {
     exec { 'wget-repo-key':
        path => ['/bin','/usr/bin','/usr/sbin','/sbin'],
        command => 'wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -',
      }

      include jenkins::ubuntu_config

     exec { 'update':
        command => '/usr/bin/apt-get update',
     }

     exec { 'install-jenkins':
        command => '/usr/bin/apt-get install -y --force-yes jenkins',
        timeout => 0,
        require => Exec['update'],
     }


 }





root@puppet:/etc/puppet/modules/jenkins/manifests# cat get_jenkins_centos.pp
class jenkins::get_jenkins_centos {
     exec { 'wget-repo-key':
        path => ['/bin','/usr/bin','/usr/sbin','/sbin'],
        command => 'sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo && sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key',
      }

      exec { 'yum-update-jenkins':
        command => '/bin/yum -y update',
        require => Exec['wget-repo-key'],
      }

      exec { 'install-jenkins':
        path => ['/bin','/usr/bin','/usr/sbin','/sbin'],
        command => 'sudo yum -y install jenkins',
        timeout => 0,
        require => Exec['yum-update-jenkins'],
      }



 }



root@puppet:/etc/puppet/modules/jenkins/manifests# cat ubuntu_config.pp
class jenkins::ubuntu_config {
   file { "/etc/apt/sources.list.d/jenkins.list":
     ensure => present,
     owner => 'root',
     group => 'root',
     mode => 0644,
     source => "puppet:///modules/jenkins/jenkins_ubuntu.repo",
   }
    
}



root@puppet:/etc/puppet/modules/jenkins/manifests# cat ../files/jenkins_ubuntu.repo
deb http://pkg.jenkins-ci.org/debian binary/
root@puppet:/etc/puppet/modules/jenkins/manifests#



No comments:

Post a Comment