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

Commit

Permalink
Use ruby193-mcollective on RHEL.
Browse files Browse the repository at this point in the history
Ensure that hostname is set before running puppet script.
Added ability to sync from upstream/master
  • Loading branch information
kraman committed Sep 23, 2013
1 parent e9a4ffb commit d7996e9
Show file tree
Hide file tree
Showing 14 changed files with 161 additions and 18 deletions.
9 changes: 8 additions & 1 deletion lib/vagrant-openshift/action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@ def self.repo_sync(options)
end
end

b.use SyncLocalRepository if options[:local_source]
if options[:local_source]
b.use SyncLocalRepository
else
b.use SyncUpstreamRepository
end
b.use CheckoutRepositories
b.use InstallOpenShiftDependencies if options[:deps]
b.use UninstallOpenShiftRpms if options[:clean]
b.use BuildSources unless options[:no_build]
end
end
Expand All @@ -76,6 +81,7 @@ def self.run_tests(options)

action_root = Pathname.new(File.expand_path("../action", __FILE__))
autoload :Clean, action_root.join("clean")
autoload :UninstallOpenShiftRpms, action_root.join("uninstall_openshift_rpms")
autoload :CloneUpstreamRepositories, action_root.join("clone_upstream_repositories")
autoload :CreateYumRepositories, action_root.join("create_yum_repositories")
autoload :CreatePuppetFile, action_root.join("create_puppet_file")
Expand All @@ -88,6 +94,7 @@ def self.run_tests(options)
autoload :InstallBuildDependencies, action_root.join("install_build_dependencies")
autoload :PrepareSshConfig, action_root.join("prepare_ssh_config")
autoload :SyncLocalRepository, action_root.join("sync_local_repository")
autoload :SyncUpstreamRepository, action_root.join("sync_upstream_repository")
autoload :BuildSources, action_root.join("build_sources")
autoload :LocalRepoCheckout, action_root.join("local_repo_checkout")
autoload :CreateBareRepoPlaceholders, action_root.join("create_bare_repo_placeholders")
Expand Down
2 changes: 2 additions & 0 deletions lib/vagrant-openshift/action/build_sources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def initialize(app, env)

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

@app.call(env)
Expand Down
6 changes: 4 additions & 2 deletions lib/vagrant-openshift/action/clean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ def call(env)
git_clone_commands = ""
Constants.repos.each do |repo_name, url|
bare_repo_name = repo_name + "-bare"
wc_repo_name = repo_name + "-bare-working_copy"
bare_repo_path = Constants.build_dir + bare_repo_name
repo_path = Constants.build_dir + repo_name
wc_repo_path = Constants.build_dir + wc_repo_name

git_clone_commands += "rm -rf #{bare_repo_path}; \n"
end
do_execute env[:machine], git_clone_commands

sudo env[:machine], "rm -rf /etc/yum.repos.d/openshift-origin.repo"
sudo env[:machine], "rm -rf /var/cache/yum/x86_64/19/openshift-origin" #clear openshift package cache
sudo env[:machine], "cd #{Constants.build_dir + "builder; #{scl_wrapper(is_fedora,'rake clean_rpms')}"}"
sudo env[:machine], "rm -rf #{Constants.build_dir + "origin-rpms"} #{Constants.build_dir + ".built_packages"} #{Constants.build_dir + ".spec_cache"}"
@app.call(env)
end
end
Expand Down
14 changes: 8 additions & 6 deletions lib/vagrant-openshift/action/create_yum_repositories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ def call(env)
is_fedora = env[:machine].communicate.test("test -e /etc/fedora-release")

unless is_fedora
sudo env[:machine], "yum install -y http://mirror.pnl.gov/epel/6/i386/epel-release-6-8.noarch.rpm"
remote_write(env[:machine], "/etc/yum.repos.d/epel.repo") {
%{
unless env[:machine].communicate.test("rpm -q epel-release")
sudo env[:machine], "yum install -y http://mirror.pnl.gov/epel/6/i386/epel-release-6-8.noarch.rpm"
remote_write(env[:machine], "/etc/yum.repos.d/epel.repo") {
%{
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
mirrorlist=http://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
exclude=*passenger* nodejs*
failovermethod=priority
enabled=1
Expand All @@ -61,8 +62,9 @@ def call(env)
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1
}
}
}
}
end

remote_write(env[:machine], "/etc/yum.repos.d/puppet.repo") {
%{[puppet]
Expand Down
7 changes: 6 additions & 1 deletion lib/vagrant-openshift/action/preserve_mcollective_logs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ def call(env)
unless env[:machine].communicate.test("grep 'keeplogs=9999' /etc/mcollective/server.cfg")
env[:machine].ui.info "Keep all mcollective logs on remote instance"
sudo(env[:machine], "echo keeplogs=9999 >> /etc/mcollective/server.cfg")
sudo(env[:machine], "/sbin/service mcollective restart")
is_fedora = env[:machine].communicate.test("test -e /etc/fedora-release")
if is_fedora
sudo(env[:machine], "/sbin/service mcollective restart")
else
sudo(env[:machine], "/sbin/service ruby193-mcollective restart")
end
end

@app.call(env)
Expand Down
67 changes: 67 additions & 0 deletions lib/vagrant-openshift/action/sync_upstream_repository.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#--
# Copyright 2013 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#++

module Vagrant
module Openshift
module Action
class SyncUpstreamRepository
include CommandHelper

def initialize(app, env)
@app = app
@env = env
end

def call(env)
env[:machine].env.ui.info("Sync'ing upstream sources\n")

Constants.repos.each do |repo_name, url|
sync_repo(env[:machine], repo_name, url)
end
env[:machine].env.ui.info("Done")

@app.call(env)
end

private

def sync_repo(machine, repo_name, url, branch="master")
bare_repo_name = repo_name + "-bare"
bare_repo_wc_name = repo_name + "-bare-working_copy"
bare_repo_path = Constants.build_dir + bare_repo_name
bare_repo_wc_path = Constants.build_dir + bare_repo_wc_name

command = ""
command += "export GIT_SSH=#{Constants.git_ssh};\n" unless Constants.git_ssh.nil? or Constants.git_ssh.empty?
command += %{
if [ ! -d #{bare_repo_wc_path} ]; then
git clone -l #{bare_repo_path} #{bare_repo_wc_path};
fi;
cd #{bare_repo_wc_path};
git remote add upstream #{url};
git fetch upstream;
git checkout master;
git reset --hard upstream/#{branch};
git push origin master -f;
}
do_execute(machine, command)
end
end
end
end
end
37 changes: 37 additions & 0 deletions lib/vagrant-openshift/action/uninstall_openshift_rpms.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#--
# Copyright 2013 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#++

module Vagrant
module Openshift
module Action
class UninstallOpenShiftRpms
include CommandHelper

def initialize(app, env)
@app = app
@env = env
end

def call(env)
is_fedora = env[:machine].communicate.test("test -e /etc/fedora-release")
sudo env[:machine], "cd #{Constants.build_dir + "builder; #{scl_wrapper(is_fedora,'rake clean_rpms')}"}"
sudo env[:machine], "rm -rf #{Constants.build_dir + "origin-rpms"} #{Constants.build_dir + ".built_packages"} #{Constants.build_dir + ".spec_cache"}"
@app.call(env)
end
end
end
end
end
13 changes: 10 additions & 3 deletions lib/vagrant-openshift/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,17 @@ def self.git_ssh
""
end

def self.restart_services_cmd
services = [ 'mongod', 'mcollective', 'activemq', 'cgconfig', 'cgred', 'named',
def self.restart_services_cmd(is_fedora)
services = [ 'mongod', 'activemq', 'cgconfig', 'cgred', 'named',
'openshift-broker', 'openshift-console', 'openshift-node-web-proxy',
'sshd', 'httpd' ]

if(is_fedora)
services << 'mcollective'
else
services << 'ruby193-mcollective'
end

cmd = []
cmd += services.map do |service|
"/sbin/service #{service} stop;"
Expand All @@ -51,7 +58,7 @@ def self.restart_services_cmd
end
cmd << "rm -rf /var/www/openshift/broker/tmp/cache/*;"
cmd << "/etc/cron.minutely/openshift-facts;"
cmd << "/sbin/service openshift-tc reload;"
cmd << "/sbin/service openshift-tc start || /sbin/service openshift-tc reload;"
cmd << "/sbin/service network restart || /sbin/service network reload;"
cmd << "/sbin/service messagebus restart;"
cmd << "/sbin/service oddjobd restart;"
Expand Down
1 change: 1 addition & 0 deletions lib/vagrant-openshift/helper/command_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def do_execute(machine, command)
stderr = []
rc = -1

machine.env.ui.info "Running command '#{command}'"
rc = machine.communicate.execute(command) do |type, data|
if [:stderr, :stdout].include?(type)
if type == :stdout
Expand Down
8 changes: 6 additions & 2 deletions lib/vagrant-openshift/provisioner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ def provision
#reapply puppet configuration so that IPs and ifcfg-* file is correct
if @machine.communicate.test("test -d /etc/openshift")
@machine.ui.info("Reapplying puppet script to update changed IP values")
hostname = @machine.config.vm.hostname
sudo(machine,"echo #{hostname} > /proc/sys/kernel/hostname")
sudo(machine,"puppet apply --verbose #{Vagrant::Openshift::Constants.build_dir + 'configure_origin.pp'}")
sudo(machine,Constants.restart_services_cmd.join("\n"))
is_fedora = @machine.communicate.test("test -e /etc/fedora-release")

sudo(machine,Constants.restart_services_cmd(is_fedora).join("\n"))
if @machine.config.openshift.additional_services.size > 0
cmd = ""
@machine.config.openshift.additional_services.each do |service|
Expand All @@ -63,4 +67,4 @@ def provision
end
end
end
end
end
3 changes: 2 additions & 1 deletion lib/vagrant-openshift/templates/builder/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ task :update_packages do
end

task :restart_services do
system(Vagrant::Openshift::Constants.restart_services_cmd.join("\n"))
is_fedora=File.exists?("/etc/fedora-release")
system(Vagrant::Openshift::Constants.restart_services_cmd(is_fedora).join("\n"))
cmd = ""
OPTIONS[:additional_services].each do |service|
cmd += "service #{service} restart;"
Expand Down
9 changes: 8 additions & 1 deletion lib/vagrant-openshift/templates/builder/lib/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,19 @@ def idle_all_gears
is_fedora = system("test -e /etc/fedora-release")

print "Idling all gears on remote instance\n"
system('/sbin/service mcollective stop; /sbin/service mcollective start; /sbin/service openshift-port-proxy restart;')

if is_fedora
system('/sbin/service mcollective stop; /sbin/service mcollective start; /sbin/service openshift-port-proxy restart;')
else
system('/sbin/service ruby193-mcollective stop; /sbin/service ruby193-mcollective start; /sbin/service openshift-port-proxy restart;')
end

system(%{
for gear in `oo-admin-ctl-gears list`; do
oo-admin-ctl-gears idlegear $gear;
done;
})

if is_fedora
system('/sbin/service httpd reload')
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ runcmd:
'rubygem-openshift-origin-container-libvirt',
'openshift-origin-cartridge-jbosseap',
'openshift-origin-cartridge-jbossews',
'openshift-origin-cartridge-jbossas',
'avahi-cname-manager',
'rubygem-openshift-origin-dns-avahi',
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-openshift/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

module Vagrant
module Openshift
VERSION = "0.0.2"
VERSION = "0.0.3"
end
end

0 comments on commit d7996e9

Please sign in to comment.