-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
War Conversion #4
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
Description | ||
=========== | ||
|
||
Installs and configures Jenkins CI server & node slaves. Resource providers to support automation via jenkins-cli, including job create/update. | ||
|
||
Changelog | ||
========= | ||
|
||
- 0.7 - Jenkins was binding to the ip address of the primary interface instead of listening to all addresses which caused nginx to be unable to connect over localhost to Jenkins. | ||
- 0.8 - Convert the recipe to use only the WAR file and not the Debian package. | ||
|
||
Requirements | ||
============ | ||
|
||
|
@@ -40,9 +47,10 @@ Where the jenkins_login recipe is simply: | |
jenkins_cli "login --username #{node[:jenkins][:username]} --password #{node[:jenkins][:password]}" | ||
|
||
Attributes | ||
========== | ||
---------- | ||
|
||
* jenkins[:mirror] - Base URL for downloading Jenkins (server) | ||
* jenkins[:version] - Specify the version of jenkins used. By default it is latest | ||
* jenkins[:mirror_url] - Specify the URL to download the WAR from | ||
* jenkins[:java_home] - Java install path, used for for cli commands | ||
* jenkins[:server][:home] - JENKINS_HOME directory | ||
* jenkins[:server][:user] - User the Jenkins server runs as | ||
|
@@ -69,20 +77,20 @@ Attributes | |
* jenkins[:node][:ssh_private_key] - jenkins master defaults to: `~/.ssh/id_rsa` (created by the default recipe) | ||
* jenkins[:node][:jvm_options] - SSH slave JVM options | ||
* jenkins[:iptables_allow] - if iptables is enabled, add a rule passing 'jenkins[:server][:port]' | ||
* jenkins[:nginx][:http_proxy][:variant] - use `nginx` or `apache2` to proxy traffic to jenkins backend (`nil` by default) | ||
* jenkins[:http_proxy][:variant] - use `nginx` or `apache2` to proxy traffic to jenkins backend (`nil` by default) | ||
* jenkins[:http_proxy][:www_redirect] - add a redirect rule for 'www.*' URL requests ("disable" by default) | ||
* jenkins[:http_proxy][:listen_ports] - list of HTTP ports for the HTTP proxy to listen on ([80] by default) | ||
* jenkins[:http_proxy][:host_name] - primary vhost name for the HTTP proxy to respond to (`node[:fqdn]` by default) | ||
* jenkins[:http_proxy][:host_aliases] - optional list of other host aliases to respond to (empty by default) | ||
* jenkins[:http_proxy][:client_max_body_size] - max client upload size ("1024m" by default, nginx only) | ||
|
||
Usage | ||
===== | ||
----- | ||
|
||
'default' recipe | ||
---------------- | ||
|
||
Installs a Jenkins CI server using the http://jenkins-ci.org/redhat RPM. The recipe also generates an ssh private key and stores the ssh public key in the node 'jenkins[:pubkey]' attribute for use by the node recipes. | ||
Installs a Jenkins CI server using the http://jenkins-ci.org/war-stable WAR. The recipe also generates an ssh private key and stores the ssh public key in the node 'jenkins[:pubkey]' attribute for use by the node recipes. | ||
|
||
'node_ssh' recipe | ||
----------------- | ||
|
@@ -117,8 +125,8 @@ Uses the nginx::source recipe from the nginx cookbook to install an HTTP fronten | |
|
||
Uses the apache2 recipe from the apache2 cookbook to install an HTTP frontend proxy. To automatically activate this recipe set the `node[:jenkins][:http_proxy][:variant]` to `apache2`. | ||
|
||
'jenkins_cli' resource provider | ||
------------------------------- | ||
'jenkins_cli' resource provider | ||
|
||
This resource can be used to execute the Jenkins cli from your recipes. For example, install plugins via update center and restart Jenkins: | ||
|
||
|
@@ -175,14 +183,14 @@ The script to generate groovy that manages a node can be used standalone. For e | |
% ruby manage_node.rb name slave-hostname remote_fs /home/jenkins ... | java -jar jenkins-cli.jar -s http://jenkins:8080/ groovy = | ||
|
||
Issues | ||
====== | ||
------ | ||
|
||
* CLI authentication - http://issues.jenkins-ci.org/browse/JENKINS-3796 | ||
|
||
* CLI *-node commands fail with "No argument is allowed: nameofslave" - http://issues.jenkins-ci.org/browse/JENKINS-5973 | ||
|
||
License & Author | ||
================ | ||
License & Author(s): | ||
------------------- | ||
|
||
This is a downstream fork of Doug MacEachern's Hudson cookbook (https://github.com/dougm/site-cookbooks) and therefore deserves all the glory. | ||
|
||
|
@@ -192,6 +200,7 @@ Contributor:: AJ Christensen <[email protected]> | |
Contributor:: Fletcher Nichol <[email protected]> | ||
Contributor:: Roman Kamyk <[email protected]> | ||
Contributor:: Darko Fabijan <[email protected]> | ||
Contributor:: Scott Likens <[email protected]> | ||
|
||
Copyright:: 2010, VMware, Inc | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
maintainer "AJ Christensen" | ||
maintainer "AJ Christensen" | ||
maintainer_email "[email protected]" | ||
license "Apache 2.0" | ||
description "Installs and configures Jenkins CI server & slaves" | ||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) | ||
version "0.6.3" | ||
version "0.8" | ||
|
||
%w(runit java).each { |cb| depends cb } | ||
%w(iptables yum apt).each { |cb| recommends cb } | ||
%w(runit java nginx).each { |cb| depends cb } | ||
%w(iptables apt).each { |cb| recommends cb } |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
# Based on hudson | ||
# Recipe:: default | ||
# | ||
# Author:: Scott Likens <[email protected]> | ||
# Author:: AJ Christensen <[email protected]> | ||
# Author:: Doug MacEachern <[email protected]> | ||
# Author:: Fletcher Nichol <[email protected]> | ||
|
@@ -21,7 +22,7 @@ | |
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
pid_file = "/var/run/jenkins/jenkins.pid" | ||
pkey = "#{node[:jenkins][:server][:home]}/.ssh/id_rsa" | ||
tmp = "/tmp" | ||
|
||
|
@@ -65,43 +66,25 @@ | |
backup false | ||
owner node[:jenkins][:server][:user] | ||
group node[:jenkins][:server][:group] | ||
action :create_if_missing | ||
end | ||
end | ||
|
||
case node.platform | ||
when "ubuntu", "debian" | ||
include_recipe "apt" | ||
include_recipe "java" | ||
|
||
pid_file = "/var/run/jenkins/jenkins.pid" | ||
install_starts_service = true | ||
|
||
apt_repository "jenkins" do | ||
uri "#{node.jenkins.package_url}/debian" | ||
components %w[binary/] | ||
key "http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key" | ||
action :add | ||
end | ||
when "centos", "redhat" | ||
include_recipe "yum" | ||
|
||
pid_file = "/var/run/jenkins.pid" | ||
install_starts_service = false | ||
|
||
yum_key "jenkins" do | ||
url "#{node.jenkins.package_url}/redhat/jenkins-ci.org.key" | ||
action :add | ||
end | ||
directory "/usr/share/jenkins" do | ||
action :create | ||
owner "nobody" | ||
group "nogroup" | ||
recursive true | ||
end | ||
|
||
yum_repository "jenkins" do | ||
description "repository for jenkins" | ||
url "#{node.jenkins.package_url}/redhat/" | ||
key "jenkins" | ||
action :add | ||
end | ||
remote_file "/usr/share/jenkins/jenkins.war" do | ||
source "#{node[:jenkins][:mirror_url]}/#{node[:jenkins][:version]}/jenkins.war" | ||
owner "root" | ||
group "root" | ||
mode 0644 | ||
end | ||
|
||
package "daemon" | ||
include_recipe "java" | ||
#"jenkins stop" may (likely) exit before the process is actually dead | ||
#so we sleep until nothing is listening on jenkins.server.port (according to netstat) | ||
ruby_block "netstat" do | ||
|
@@ -119,12 +102,6 @@ | |
action :nothing | ||
end | ||
|
||
service "jenkins" do | ||
supports [ :stop, :start, :restart, :status ] | ||
status_command "test -f #{pid_file} && kill -0 `cat #{pid_file}`" | ||
action :nothing | ||
end | ||
|
||
ruby_block "block_until_operational" do | ||
block do | ||
until IO.popen("netstat -lnt").entries.select { |entry| | ||
|
@@ -145,20 +122,17 @@ | |
action :nothing | ||
end | ||
|
||
log "jenkins: install and start" do | ||
notifies :install, "package[jenkins]", :immediately | ||
notifies :start, "service[jenkins]", :immediately unless install_starts_service | ||
notifies :create, "ruby_block[block_until_operational]", :immediately | ||
not_if do | ||
File.exists? "/usr/share/jenkins/jenkins.war" | ||
end | ||
end | ||
|
||
template "/etc/default/jenkins" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this needs a |
||
|
||
package "jenkins" do | ||
template "/etc/init.d/jenkins" do | ||
source "jenkins" | ||
mode 0755 | ||
end | ||
|
||
service "jenkins" do | ||
supports [ :stop, :start, :restart, :status ] | ||
status_command "test -f #{pid_file} && kill -0 `cat #{pid_file}`" | ||
action :nothing | ||
notifies :create, "template[/etc/default/jenkins]", :immediately | ||
end | ||
|
||
# restart if this run only added new plugins | ||
|
@@ -198,3 +172,12 @@ | |
end | ||
end | ||
end | ||
service "jenkins" do | ||
supports [ :stop, :start, :restart, :status ] | ||
status_command "test -f #{pid_file} && kill -0 `cat #{pid_file}`" | ||
action [:start,:enable] | ||
end | ||
execute "start jenkins" do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little confused by this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These'll be purged when I add the s6 supervisor support. Cheers! |
||
command "/etc/init.d/jenkins start" | ||
not_if 'ps auxwww | grep [j]enkins' | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,3 +54,6 @@ | |
enable false | ||
end | ||
end | ||
service "nginx" do | ||
action [:start, :enable] | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double-plus-good!