Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.

Commit d7996e9

Browse files
committed
Use ruby193-mcollective on RHEL.
Ensure that hostname is set before running puppet script. Added ability to sync from upstream/master
1 parent e9a4ffb commit d7996e9

File tree

14 files changed

+161
-18
lines changed

14 files changed

+161
-18
lines changed

lib/vagrant-openshift/action.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,14 @@ def self.repo_sync(options)
5151
end
5252
end
5353

54-
b.use SyncLocalRepository if options[:local_source]
54+
if options[:local_source]
55+
b.use SyncLocalRepository
56+
else
57+
b.use SyncUpstreamRepository
58+
end
5559
b.use CheckoutRepositories
5660
b.use InstallOpenShiftDependencies if options[:deps]
61+
b.use UninstallOpenShiftRpms if options[:clean]
5762
b.use BuildSources unless options[:no_build]
5863
end
5964
end
@@ -76,6 +81,7 @@ def self.run_tests(options)
7681

7782
action_root = Pathname.new(File.expand_path("../action", __FILE__))
7883
autoload :Clean, action_root.join("clean")
84+
autoload :UninstallOpenShiftRpms, action_root.join("uninstall_openshift_rpms")
7985
autoload :CloneUpstreamRepositories, action_root.join("clone_upstream_repositories")
8086
autoload :CreateYumRepositories, action_root.join("create_yum_repositories")
8187
autoload :CreatePuppetFile, action_root.join("create_puppet_file")
@@ -88,6 +94,7 @@ def self.run_tests(options)
8894
autoload :InstallBuildDependencies, action_root.join("install_build_dependencies")
8995
autoload :PrepareSshConfig, action_root.join("prepare_ssh_config")
9096
autoload :SyncLocalRepository, action_root.join("sync_local_repository")
97+
autoload :SyncUpstreamRepository, action_root.join("sync_upstream_repository")
9198
autoload :BuildSources, action_root.join("build_sources")
9299
autoload :LocalRepoCheckout, action_root.join("local_repo_checkout")
93100
autoload :CreateBareRepoPlaceholders, action_root.join("create_bare_repo_placeholders")

lib/vagrant-openshift/action/build_sources.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ def initialize(app, env)
2727

2828
def call(env)
2929
is_fedora = env[:machine].communicate.test("test -e /etc/fedora-release")
30+
hostname = env[:machine].config.vm.hostname
31+
sudo(env[:machine],"echo #{hostname} > /proc/sys/kernel/hostname")
3032
sudo(env[:machine], "cd #{Constants.build_dir + "builder"}; #{scl_wrapper(is_fedora,'rake update_packages')}", {timeout: 60*30})
3133

3234
@app.call(env)

lib/vagrant-openshift/action/clean.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,17 @@ def call(env)
3131
git_clone_commands = ""
3232
Constants.repos.each do |repo_name, url|
3333
bare_repo_name = repo_name + "-bare"
34+
wc_repo_name = repo_name + "-bare-working_copy"
3435
bare_repo_path = Constants.build_dir + bare_repo_name
36+
repo_path = Constants.build_dir + repo_name
37+
wc_repo_path = Constants.build_dir + wc_repo_name
38+
3539
git_clone_commands += "rm -rf #{bare_repo_path}; \n"
3640
end
3741
do_execute env[:machine], git_clone_commands
3842

3943
sudo env[:machine], "rm -rf /etc/yum.repos.d/openshift-origin.repo"
4044
sudo env[:machine], "rm -rf /var/cache/yum/x86_64/19/openshift-origin" #clear openshift package cache
41-
sudo env[:machine], "cd #{Constants.build_dir + "builder; #{scl_wrapper(is_fedora,'rake clean_rpms')}"}"
42-
sudo env[:machine], "rm -rf #{Constants.build_dir + "origin-rpms"} #{Constants.build_dir + ".built_packages"} #{Constants.build_dir + ".spec_cache"}"
4345
@app.call(env)
4446
end
4547
end

lib/vagrant-openshift/action/create_yum_repositories.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ def call(env)
2929
is_fedora = env[:machine].communicate.test("test -e /etc/fedora-release")
3030

3131
unless is_fedora
32-
sudo env[:machine], "yum install -y http://mirror.pnl.gov/epel/6/i386/epel-release-6-8.noarch.rpm"
33-
remote_write(env[:machine], "/etc/yum.repos.d/epel.repo") {
34-
%{
32+
unless env[:machine].communicate.test("rpm -q epel-release")
33+
sudo env[:machine], "yum install -y http://mirror.pnl.gov/epel/6/i386/epel-release-6-8.noarch.rpm"
34+
remote_write(env[:machine], "/etc/yum.repos.d/epel.repo") {
35+
%{
3536
[epel]
3637
name=Extra Packages for Enterprise Linux 6 - $basearch
3738
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
38-
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
39+
mirrorlist=http://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
3940
exclude=*passenger* nodejs*
4041
failovermethod=priority
4142
enabled=1
@@ -61,8 +62,9 @@ def call(env)
6162
enabled=0
6263
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
6364
gpgcheck=1
64-
}
65-
}
65+
}
66+
}
67+
end
6668

6769
remote_write(env[:machine], "/etc/yum.repos.d/puppet.repo") {
6870
%{[puppet]

lib/vagrant-openshift/action/preserve_mcollective_logs.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ def call(env)
2929
unless env[:machine].communicate.test("grep 'keeplogs=9999' /etc/mcollective/server.cfg")
3030
env[:machine].ui.info "Keep all mcollective logs on remote instance"
3131
sudo(env[:machine], "echo keeplogs=9999 >> /etc/mcollective/server.cfg")
32-
sudo(env[:machine], "/sbin/service mcollective restart")
32+
is_fedora = env[:machine].communicate.test("test -e /etc/fedora-release")
33+
if is_fedora
34+
sudo(env[:machine], "/sbin/service mcollective restart")
35+
else
36+
sudo(env[:machine], "/sbin/service ruby193-mcollective restart")
37+
end
3338
end
3439

3540
@app.call(env)
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#--
2+
# Copyright 2013 Red Hat, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#++
16+
17+
module Vagrant
18+
module Openshift
19+
module Action
20+
class SyncUpstreamRepository
21+
include CommandHelper
22+
23+
def initialize(app, env)
24+
@app = app
25+
@env = env
26+
end
27+
28+
def call(env)
29+
env[:machine].env.ui.info("Sync'ing upstream sources\n")
30+
31+
Constants.repos.each do |repo_name, url|
32+
sync_repo(env[:machine], repo_name, url)
33+
end
34+
env[:machine].env.ui.info("Done")
35+
36+
@app.call(env)
37+
end
38+
39+
private
40+
41+
def sync_repo(machine, repo_name, url, branch="master")
42+
bare_repo_name = repo_name + "-bare"
43+
bare_repo_wc_name = repo_name + "-bare-working_copy"
44+
bare_repo_path = Constants.build_dir + bare_repo_name
45+
bare_repo_wc_path = Constants.build_dir + bare_repo_wc_name
46+
47+
command = ""
48+
command += "export GIT_SSH=#{Constants.git_ssh};\n" unless Constants.git_ssh.nil? or Constants.git_ssh.empty?
49+
command += %{
50+
51+
if [ ! -d #{bare_repo_wc_path} ]; then
52+
git clone -l #{bare_repo_path} #{bare_repo_wc_path};
53+
fi;
54+
55+
cd #{bare_repo_wc_path};
56+
git remote add upstream #{url};
57+
git fetch upstream;
58+
git checkout master;
59+
git reset --hard upstream/#{branch};
60+
git push origin master -f;
61+
}
62+
do_execute(machine, command)
63+
end
64+
end
65+
end
66+
end
67+
end
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#--
2+
# Copyright 2013 Red Hat, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#++
16+
17+
module Vagrant
18+
module Openshift
19+
module Action
20+
class UninstallOpenShiftRpms
21+
include CommandHelper
22+
23+
def initialize(app, env)
24+
@app = app
25+
@env = env
26+
end
27+
28+
def call(env)
29+
is_fedora = env[:machine].communicate.test("test -e /etc/fedora-release")
30+
sudo env[:machine], "cd #{Constants.build_dir + "builder; #{scl_wrapper(is_fedora,'rake clean_rpms')}"}"
31+
sudo env[:machine], "rm -rf #{Constants.build_dir + "origin-rpms"} #{Constants.build_dir + ".built_packages"} #{Constants.build_dir + ".spec_cache"}"
32+
@app.call(env)
33+
end
34+
end
35+
end
36+
end
37+
end

lib/vagrant-openshift/constants.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,17 @@ def self.git_ssh
3838
""
3939
end
4040

41-
def self.restart_services_cmd
42-
services = [ 'mongod', 'mcollective', 'activemq', 'cgconfig', 'cgred', 'named',
41+
def self.restart_services_cmd(is_fedora)
42+
services = [ 'mongod', 'activemq', 'cgconfig', 'cgred', 'named',
4343
'openshift-broker', 'openshift-console', 'openshift-node-web-proxy',
4444
'sshd', 'httpd' ]
45+
46+
if(is_fedora)
47+
services << 'mcollective'
48+
else
49+
services << 'ruby193-mcollective'
50+
end
51+
4552
cmd = []
4653
cmd += services.map do |service|
4754
"/sbin/service #{service} stop;"
@@ -51,7 +58,7 @@ def self.restart_services_cmd
5158
end
5259
cmd << "rm -rf /var/www/openshift/broker/tmp/cache/*;"
5360
cmd << "/etc/cron.minutely/openshift-facts;"
54-
cmd << "/sbin/service openshift-tc reload;"
61+
cmd << "/sbin/service openshift-tc start || /sbin/service openshift-tc reload;"
5562
cmd << "/sbin/service network restart || /sbin/service network reload;"
5663
cmd << "/sbin/service messagebus restart;"
5764
cmd << "/sbin/service oddjobd restart;"

lib/vagrant-openshift/helper/command_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def do_execute(machine, command)
6363
stderr = []
6464
rc = -1
6565

66+
machine.env.ui.info "Running command '#{command}'"
6667
rc = machine.communicate.execute(command) do |type, data|
6768
if [:stderr, :stdout].include?(type)
6869
if type == :stdout

lib/vagrant-openshift/provisioner.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ def provision
4343
#reapply puppet configuration so that IPs and ifcfg-* file is correct
4444
if @machine.communicate.test("test -d /etc/openshift")
4545
@machine.ui.info("Reapplying puppet script to update changed IP values")
46+
hostname = @machine.config.vm.hostname
47+
sudo(machine,"echo #{hostname} > /proc/sys/kernel/hostname")
4648
sudo(machine,"puppet apply --verbose #{Vagrant::Openshift::Constants.build_dir + 'configure_origin.pp'}")
47-
sudo(machine,Constants.restart_services_cmd.join("\n"))
49+
is_fedora = @machine.communicate.test("test -e /etc/fedora-release")
50+
51+
sudo(machine,Constants.restart_services_cmd(is_fedora).join("\n"))
4852
if @machine.config.openshift.additional_services.size > 0
4953
cmd = ""
5054
@machine.config.openshift.additional_services.each do |service|
@@ -63,4 +67,4 @@ def provision
6367
end
6468
end
6569
end
66-
end
70+
end

0 commit comments

Comments
 (0)