-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Jenkins Infrastructure Demo (#55)
* Adding Jenkins, which uses Docker * adding missing spec tests * update jenkins module * adding rbenv, windows_env * bump acl module to latest * adding puppetlabs-service * adding resource module * test * Adding reboot for ruby pre-reqs on Windows * Rename Rubydev to PuppetDev; Use PDK for Windows * cleanup data * Fixing Lint issues * Updating lint errors * Fix pathing * Updating Profile::App::Docker Spec to fail Windows
- Loading branch information
Showing
23 changed files
with
415 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!-- This file is managed by Puppet. --> | ||
<configuration> | ||
<runtime> | ||
<generatePublisherEvidence enabled="false"/> | ||
</runtime> | ||
<startup> | ||
<supportedRuntime version="v2.0.50727"/> | ||
<supportedRuntime version="v4.0"/> | ||
</startup> | ||
</configuration> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class profile::app::docker { | ||
|
||
if $::kernel == 'windows' { | ||
fail('Unsupported OS') | ||
} | ||
|
||
include ::docker | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class profile::app::jenkins::master { | ||
|
||
if $::kernel == 'windows' { | ||
fail('Unsupported OS') | ||
} | ||
|
||
docker::image { 'ipcrm/jenkins_demo': | ||
ensure => present, | ||
image_tag => 'latest', | ||
} | ||
|
||
docker::run { 'jenkins_demo': | ||
image => 'ipcrm/jenkins_demo:latest', | ||
ports => ['8080:8080','50000:50000'], | ||
extra_parameters => [ '--restart=always' ], | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
class profile::app::jenkins::slave ( | ||
$master_url = 'http://localhost:8080', | ||
){ | ||
|
||
include ::profile::platform::baseline | ||
|
||
case $::kernel { | ||
|
||
'Linux': { | ||
class { '::jenkins::slave': | ||
masterurl => $master_url, | ||
ui_user => 'admin', | ||
ui_pass => 'password', | ||
labels => ['tse-slave-linux','tse-control-repo'], | ||
slave_groups => 'wheel', | ||
} | ||
|
||
include ::profile::app::puppetdev | ||
} | ||
|
||
'windows': { | ||
class { '::profile::app::jenkins::win_slave': | ||
masterurl => $master_url, | ||
ui_user => 'admin', | ||
ui_pass => 'password', | ||
labels => 'tse-slave-windows', | ||
} | ||
|
||
include ::profile::app::puppetdev | ||
} | ||
|
||
default:{ | ||
fail('Unsupported OS') | ||
} | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
class profile::app::jenkins::win_slave ( | ||
$masterurl, | ||
$ui_user, | ||
$ui_pass, | ||
$labels = undef, | ||
$slave_home = 'C:/jenkins', | ||
$slave_version = '2.0', | ||
$client_jar = 'swarm-client-2.0-jar-with-dependencies.jar', | ||
$jenkins_owner = 'jenkins', | ||
$executors = 1, | ||
){ | ||
|
||
include ::profile::platform::baseline | ||
|
||
$client_url = "https://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/swarm-client/${slave_version}/" | ||
|
||
$client_jar_flag = "-jar ${slave_home}/${client_jar}" | ||
$mode_flag = '-mode normal' | ||
$fs_root_flag = "-fsroot ${slave_home}" | ||
$executors_flag = "-executors ${executors}" | ||
$ui_user_flag = "-username ${ui_user}" | ||
$ui_pass_flag = "-password ${ui_pass}" | ||
$slave_alias_flag = "-name ${::fqdn}" | ||
$master_url_flag = "-master ${masterurl}" | ||
$labels_flag = "-labels ${labels}" | ||
|
||
package { ['javaruntime','wget']: | ||
ensure => installed, | ||
provider => chocolatey, | ||
} | ||
|
||
user { $jenkins_owner: | ||
ensure => present, | ||
home => $slave_home, | ||
password => 'S3cr3tP@$$w0rd', | ||
managehome => true, | ||
groups => ['Administrators'], | ||
comment => 'Jenkins User', | ||
} | ||
|
||
file { $slave_home: | ||
ensure => directory, | ||
owner => 'S-1-5-32-544', # BUILTIN\Administrators | ||
group => 'S-1-0-0', # NULL, managed by acl resource below | ||
require => User[$jenkins_owner], | ||
} | ||
|
||
acl { $slave_home: | ||
permissions => [ | ||
{ identity => 'S-1-5-32-544', rights => [ 'full' ] }, # BUILTIN\Administrators | ||
{ identity => 'S-1-5-18', rights => [ 'full' ] }, # NT AUTHORITY\SYSTEM | ||
{ identity => 'Administrator', rights => [ 'full' ] }, | ||
{ identity => $jenkins_owner, rights => [ 'full' ] }, | ||
], | ||
inherit_parent_permissions => false, | ||
require => File[$slave_home], | ||
} | ||
|
||
exec { 'download-swarm-client': | ||
command => "wget.exe -O ${slave_home}/${client_jar} ${client_url}/${client_jar}", | ||
path => "c:/programdata/chocolatey/bin;${::path}", | ||
creates => "${slave_home}/${client_jar}", | ||
notify => Exec['uninstall-jenkins-service'], | ||
} | ||
|
||
file { "${slave_home}/${client_jar}": | ||
ensure => file, | ||
owner => $jenkins_owner, | ||
group => 'S-1-5-32-544', # Administrators | ||
mode => '0775', | ||
require => Exec['download-swarm-client'], | ||
} | ||
|
||
# Let's install the service. | ||
file { "${slave_home}/swarm-client.xml": | ||
content => template('profile/app/jenkins/swarm-client-win.xml.erb'), | ||
notify => Exec['uninstall-jenkins-service'], | ||
require => User[$jenkins_owner], | ||
} | ||
|
||
file { "${slave_home}/swarm-client.exe.config": | ||
source => 'puppet:///modules/profile/app/jenkins/swarm-client-win.config', | ||
owner => $jenkins_owner, | ||
group => 'S-1-5-32-544', # Administrators | ||
mode => '0775', | ||
notify => Exec['uninstall-jenkins-service'], | ||
require => User[$jenkins_owner], | ||
} | ||
|
||
# Its binary, but only 37k. Used to setup a service. | ||
# see: https://github.com/kohsuke/winsw | ||
file { "${slave_home}/swarm-client.exe": | ||
source => 'puppet:///modules/profile/app/jenkins/swarm-client-win.exe', | ||
owner => $jenkins_owner, | ||
group => 'S-1-5-32-544', # Administrators | ||
mode => '0775', | ||
notify => Exec['uninstall-jenkins-service'], | ||
require => [ | ||
File["${slave_home}/swarm-client.xml"], | ||
File["${slave_home}/swarm-client.exe.config"], | ||
], | ||
} | ||
|
||
exec { 'install-jenkins-service': | ||
path => "c:/windows/system32;${slave_home}", | ||
command => "${slave_home}/swarm-client.exe install", | ||
unless => '$t = (Get-Service jenkins-slave -ErrorAction SilentlyContinue); if (-Not $t){ exit 1 } else { exit 0 }', | ||
provider => powershell, | ||
require => [ | ||
Exec['download-swarm-client'], | ||
File["${slave_home}/swarm-client.exe"], | ||
], | ||
} | ||
|
||
exec { 'uninstall-jenkins-service': | ||
path => "c:/windows/system32;${slave_home}", | ||
command => 'net stop jenkins-slave & sc.exe delete jenkins-slave', | ||
onlyif => '$t = (Get-Service jenkins-slave -ErrorAction SilentlyContinue); if (-Not $t){ exit 1 } else { exit 0 }', | ||
provider => powershell, | ||
refreshonly => true, | ||
returns => [0, 1], | ||
notify => Exec['install-jenkins-service'], | ||
logoutput => true, | ||
} | ||
|
||
windows_env { 'git-on-path': | ||
ensure => present, | ||
variable => 'PATH', | ||
value => [ | ||
'C:\Program Files\Git\cmd', | ||
'C:\Program Files (x86)\Git\cmd', | ||
], | ||
mergemode => 'prepend', | ||
require => Package['git'], | ||
} | ||
|
||
|
||
service { 'jenkins-slave': | ||
ensure => running, | ||
enable => true, | ||
require => Exec['install-jenkins-service'], | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class profile::app::puppetdev { | ||
|
||
case $::kernel { | ||
|
||
'windows': { | ||
contain ::profile::app::puppetdev::windows | ||
} | ||
|
||
'Linux': { | ||
contain ::profile::app::puppetdev::linux | ||
} | ||
|
||
default: { | ||
fail('Unsupported OS') | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class profile::app::puppetdev::linux { | ||
|
||
$dev_packages = $::osfamily ? { | ||
'RedHat' => ['gcc','gcc-c++','openssl-devel','readline-devel','zlib-devel','cmake'], | ||
'Debian' => ['build-essential','cmake','libssl-dev','zlib1g-dev','libreadline6-dev'], | ||
} | ||
|
||
ensure_packages($dev_packages,{ensure => present}) | ||
|
||
include ::rbenv | ||
rbenv::plugin { 'rbenv/ruby-build': } | ||
rbenv::build { '2.3.1': global => true } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class profile::app::puppetdev::windows { | ||
|
||
package { 'Puppet Development Kit': | ||
ensure => present, | ||
source => 'https://puppet-pdk.s3.amazonaws.com/pdk/1.2.1.0/repos/windows/pdk-1.2.1.0-x64.msi', | ||
provider => 'windows', | ||
} | ||
|
||
ensure_packages('git', { ensure => present, provider => 'chocolatey' }) | ||
|
||
windows_env { 'PATH=C:\Program Files\Puppet Labs\DevelopmentKit\private\ruby\2.1.9\bin': require => Package['Puppet Development Kit'] } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.