Skip to content

Commit 1794719

Browse files
committed
third bootstrap phase: jenkins
Only after master-init, master-config and a restart of the jenkins service, can the master-jenkins recipe actually configure the jenkins install (which by then has the chef user + plugins)
1 parent fbde7da commit 1794719

File tree

7 files changed

+63
-45
lines changed

7 files changed

+63
-45
lines changed

.chef/Vagrantfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Vagrant.configure("2") do |config|
1515
# TODO: chef.encrypted_data_bag_secret_key_path
1616
chef.add_recipe("scala-jenkins-infra::master-init")
1717
chef.add_recipe("scala-jenkins-infra::master-config")
18+
chef.add_recipe("scala-jenkins-infra::master-jenkins") # do not run on first provision -- must run up to master-config and allow jenkins to restart
1819
end
1920
config.vm.network "public_network"
2021
config.vm.provider "virtualbox" do |v|

recipes/_master-config-jenkins.rb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#
2+
# Cookbook Name:: scala-jenkins-infra
3+
# Recipe:: _master-config-jenkins
4+
#
5+
# Copyright 2014, Typesafe, Inc.
6+
#
7+
# All rights reserved - Do Not Redistribute
8+
#
9+
10+
# Config base Jenkins setup and restart
11+
ruby_block 'set private key' do
12+
block do
13+
node.run_state[:jenkins_private_key] = chef_vault_item("master", "scala-jenkins-keypair")['private_key']
14+
end
15+
end
16+
17+
## set up chef user with public key from our master/scala-jenkins-keypair vault
18+
template "#{node['jenkins']['master']['home']}/users/chef/config.xml" do
19+
source 'chef-user-config.erb'
20+
user node['jenkins']['master']['user']
21+
group node['jenkins']['master']['group']
22+
23+
variables({
24+
:pubkey => chef_vault_item("master", "scala-jenkins-keypair")['public_key']
25+
})
26+
end
27+
28+
%w(notification ssh-credentials groovy cygpath job-dsl build-flow-plugin rebuild greenballs build-timeout copyartifact email-ext slack throttle-concurrents dashboard-view parameterized-trigger).each do |plugin|
29+
plugin, version = plugin.split('=') # in case we decide to pin versions later
30+
jenkins_plugin plugin
31+
end
32+
33+
jenkins_plugin "ec2-start-stop" do
34+
source node['master']['ec2-start-stop']['url']
35+
# doesn't support checksum
36+
end
37+
38+
jenkins_plugin "github-oauth" do
39+
notifies :restart, 'runit_service[jenkins]', :immediately
40+
end
File renamed without changes.

recipes/master-config.rb

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,54 +7,14 @@
77
# All rights reserved - Do Not Redistribute
88
#
99

10+
# This recipe needs access to the vault, so can't be run on EC2 bootstrap (would be nice to fix)
1011

11-
ruby_block 'set private key' do
12-
block do
13-
node.run_state[:jenkins_private_key] = chef_vault_item("master", "scala-jenkins-keypair")['private_key']
14-
end
15-
end
16-
17-
18-
# nginx reverse proxy setup, in concert with JenkinsLocationConfiguration created in master-init
12+
# NGINX REVERSE PROXY setup, in concert with JenkinsLocationConfiguration created in master-init
1913
include_recipe 'scala-jenkins-infra::_master-config-proxy'
2014

21-
# set up chef user with public key from our master/scala-jenkins-keypair vault
22-
template "#{node['jenkins']['master']['home']}/users/chef/config.xml" do
23-
source 'chef-user-config.erb'
24-
user node['jenkins']['master']['user']
25-
group node['jenkins']['master']['group']
26-
27-
variables({
28-
:pubkey => chef_vault_item("master", "scala-jenkins-keypair")['public_key']
29-
})
30-
end
31-
32-
%w(notification ssh-credentials groovy cygpath job-dsl build-flow-plugin rebuild greenballs build-timeout copyartifact email-ext slack throttle-concurrents dashboard-view parameterized-trigger).each do |plugin|
33-
plugin, version = plugin.split('=') # in case we decide to pin versions later
34-
jenkins_plugin plugin
35-
end
36-
37-
jenkins_plugin "ec2-start-stop" do
38-
source node['master']['ec2-start-stop']['url']
39-
# doesn't support checksum
40-
end
41-
42-
jenkins_plugin "github-oauth" do
43-
end
44-
45-
# this doesn't work
46-
# jenkins_command 'safe-restart' do
47-
# action :nothing
48-
# subscribes :execute, 'jenkins_plugin[github-oauth]', :delayed
49-
# end
50-
51-
# NEED TO RESTART JENKINS BEFORE YOU CAN CONTINUE BRINGING UP JENKINS THE FIRST TIME
52-
include_recipe 'scala-jenkins-infra::_master-config-auth-github'
53-
54-
include_recipe 'scala-jenkins-infra::_master-config-jobs'
55-
56-
include_recipe 'scala-jenkins-infra::_master-config-workers'
15+
# Jenkins base config
16+
include_recipe 'scala-jenkins-infra::_master-config-jenkins'
5717

58-
# NEEDS /usr/local/sbt
18+
# SCABOT
5919
include_recipe 'scala-jenkins-infra::_master-config-scabot'
6020

recipes/master-jenkins.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Cookbook Name:: scala-jenkins-infra
3+
# Recipe:: master-jenkins
4+
#
5+
# Copyright 2014, Typesafe, Inc.
6+
#
7+
# All rights reserved - Do Not Redistribute
8+
#
9+
10+
# run after master-config + jenkins restart
11+
12+
# ON FIRST PROVISION, MAKE SURE JENKINS HAS BEEN RESTARTED
13+
# Plugins don't take effect until that, so `_master-config-auth-github` would fail
14+
include_recipe 'scala-jenkins-infra::_master-jenkins-auth-github'
15+
include_recipe 'scala-jenkins-infra::_master-jenkins-jobs'
16+
include_recipe 'scala-jenkins-infra::_master-jenkins-workers'
17+

0 commit comments

Comments
 (0)