vagrant-openshift 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitattributes +1 -0
- data/.gitignore +24 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +13 -0
- data/README.asciidoc +379 -0
- data/Rakefile +53 -0
- data/lib/vagrant-openshift/action/build_geard.rb +41 -0
- data/lib/vagrant-openshift/action/build_geard_broker.rb +59 -0
- data/lib/vagrant-openshift/action/build_geard_console.rb +55 -0
- data/lib/vagrant-openshift/action/build_geard_images.rb +54 -0
- data/lib/vagrant-openshift/action/build_sources.rb +39 -0
- data/lib/vagrant-openshift/action/checkout_repositories.rb +72 -0
- data/lib/vagrant-openshift/action/checkout_tests.rb +57 -0
- data/lib/vagrant-openshift/action/clean.rb +51 -0
- data/lib/vagrant-openshift/action/clean_network_setup.rb +52 -0
- data/lib/vagrant-openshift/action/clone_upstream_repositories.rb +65 -0
- data/lib/vagrant-openshift/action/create_ami.rb +54 -0
- data/lib/vagrant-openshift/action/create_bare_repo_placeholders.rb +53 -0
- data/lib/vagrant-openshift/action/create_puppet_file.rb +84 -0
- data/lib/vagrant-openshift/action/create_test_users.rb +36 -0
- data/lib/vagrant-openshift/action/create_yum_repositories.rb +121 -0
- data/lib/vagrant-openshift/action/download_artifacts.rb +70 -0
- data/lib/vagrant-openshift/action/generate_template.rb +89 -0
- data/lib/vagrant-openshift/action/idle_all_gears.rb +36 -0
- data/lib/vagrant-openshift/action/install_build_dependencies.rb +48 -0
- data/lib/vagrant-openshift/action/install_geard.rb +76 -0
- data/lib/vagrant-openshift/action/install_geard_base_dependencies.rb +72 -0
- data/lib/vagrant-openshift/action/install_geard_broker.rb +39 -0
- data/lib/vagrant-openshift/action/install_geard_images.rb +51 -0
- data/lib/vagrant-openshift/action/install_open_shift_dependencies.rb +50 -0
- data/lib/vagrant-openshift/action/install_rhc.rb +42 -0
- data/lib/vagrant-openshift/action/local_geard_checkout.rb +58 -0
- data/lib/vagrant-openshift/action/local_repo_checkout.rb +47 -0
- data/lib/vagrant-openshift/action/modify_ami.rb +54 -0
- data/lib/vagrant-openshift/action/modify_instance.rb +71 -0
- data/lib/vagrant-openshift/action/prepare_ssh_config.rb +89 -0
- data/lib/vagrant-openshift/action/preserve_mcollective_logs.rb +48 -0
- data/lib/vagrant-openshift/action/restart_geard.rb +39 -0
- data/lib/vagrant-openshift/action/restart_geard_broker.rb +43 -0
- data/lib/vagrant-openshift/action/restart_geard_console.rb +43 -0
- data/lib/vagrant-openshift/action/run_geard_tests.rb +57 -0
- data/lib/vagrant-openshift/action/run_tests.rb +47 -0
- data/lib/vagrant-openshift/action/set_host_name.rb +43 -0
- data/lib/vagrant-openshift/action/setup_bind_dns_key.rb +38 -0
- data/lib/vagrant-openshift/action/setup_bind_host.rb +141 -0
- data/lib/vagrant-openshift/action/setup_builder_files.rb +57 -0
- data/lib/vagrant-openshift/action/setup_geard_broker.rb +71 -0
- data/lib/vagrant-openshift/action/sync_local_repository.rb +115 -0
- data/lib/vagrant-openshift/action/sync_upstream_repository.rb +71 -0
- data/lib/vagrant-openshift/action/test_exit_code.rb +36 -0
- data/lib/vagrant-openshift/action/uninstall_openshift_rpms.rb +37 -0
- data/lib/vagrant-openshift/action/yum_update.rb +67 -0
- data/lib/vagrant-openshift/action.rb +308 -0
- data/lib/vagrant-openshift/command/build_geard.rb +51 -0
- data/lib/vagrant-openshift/command/build_geard_base.rb +51 -0
- data/lib/vagrant-openshift/command/build_geard_broker.rb +59 -0
- data/lib/vagrant-openshift/command/build_geard_console.rb +59 -0
- data/lib/vagrant-openshift/command/build_geard_images.rb +68 -0
- data/lib/vagrant-openshift/command/build_origin_base.rb +51 -0
- data/lib/vagrant-openshift/command/checkout_repositories.rb +55 -0
- data/lib/vagrant-openshift/command/clone_upstream_repositories.rb +54 -0
- data/lib/vagrant-openshift/command/create_ami.rb +49 -0
- data/lib/vagrant-openshift/command/install_geard.rb +51 -0
- data/lib/vagrant-openshift/command/install_geard_broker.rb +51 -0
- data/lib/vagrant-openshift/command/install_rhc.rb +49 -0
- data/lib/vagrant-openshift/command/local_geard_setup.rb +62 -0
- data/lib/vagrant-openshift/command/local_repo_setup.rb +62 -0
- data/lib/vagrant-openshift/command/modify_ami.rb +54 -0
- data/lib/vagrant-openshift/command/modify_instance.rb +63 -0
- data/lib/vagrant-openshift/command/openshift_init.rb +83 -0
- data/lib/vagrant-openshift/command/repo_sync.rb +73 -0
- data/lib/vagrant-openshift/command/repo_sync_geard.rb +78 -0
- data/lib/vagrant-openshift/command/restart_geard.rb +51 -0
- data/lib/vagrant-openshift/command/restart_geard_broker.rb +51 -0
- data/lib/vagrant-openshift/command/restart_geard_console.rb +51 -0
- data/lib/vagrant-openshift/command/setup_geard_broker.rb +49 -0
- data/lib/vagrant-openshift/command/test.rb +108 -0
- data/lib/vagrant-openshift/command/test_geard.rb +59 -0
- data/lib/vagrant-openshift/command/test_geard_image.rb +147 -0
- data/lib/vagrant-openshift/config.rb +56 -0
- data/lib/vagrant-openshift/constants.rb +111 -0
- data/lib/vagrant-openshift/helper/command_helper.rb +213 -0
- data/lib/vagrant-openshift/plugin.rb +171 -0
- data/lib/vagrant-openshift/provisioner.rb +82 -0
- data/lib/vagrant-openshift/templates/builder/Rakefile +231 -0
- data/lib/vagrant-openshift/templates/builder/lib/.gitkeep +0 -0
- data/lib/vagrant-openshift/templates/builder/lib/rpm.rb +248 -0
- data/lib/vagrant-openshift/templates/builder/lib/test.rb +432 -0
- data/lib/vagrant-openshift/templates/builder/yum-listbuilddep +124 -0
- data/lib/vagrant-openshift/templates/command/init-openshift/Vagrantfile.erb +175 -0
- data/lib/vagrant-openshift/templates/command/init-openshift/box_info.yaml +152 -0
- data/lib/vagrant-openshift/version.rb +21 -0
- data/lib/vagrant-openshift.rb +34 -0
- data/vagrant-openshift.gemspec +43 -0
- metadata +234 -0
@@ -0,0 +1,56 @@
|
|
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
|
+
class Config < Vagrant.plugin(2, :config)
|
20
|
+
attr_accessor :cloud_domain, :ignore_packages, :additional_services, :container,
|
21
|
+
:advanced_puppet_values, :repos_base, :os_repo, :os_updates_repo,
|
22
|
+
:jenkins_repo_base, :optional_repo, :os_extras_repo, :os_scl_repo
|
23
|
+
|
24
|
+
def initialize
|
25
|
+
super
|
26
|
+
|
27
|
+
@ignore_packages = UNSET_VALUE
|
28
|
+
@cloud_domain = UNSET_VALUE
|
29
|
+
@additional_services = UNSET_VALUE
|
30
|
+
@container = UNSET_VALUE
|
31
|
+
@repos_base = UNSET_VALUE
|
32
|
+
@os_repo = nil
|
33
|
+
@os_updates_repo = nil
|
34
|
+
@os_extras_repo = nil
|
35
|
+
@jenkins_repo_base = UNSET_VALUE
|
36
|
+
@optional_repo = nil
|
37
|
+
@os_scl_repo = nil
|
38
|
+
|
39
|
+
@advanced_puppet_values = UNSET_VALUE
|
40
|
+
end
|
41
|
+
|
42
|
+
def finalize!
|
43
|
+
super
|
44
|
+
|
45
|
+
@ignore_packages = [] if @ignore_packages == UNSET_VALUE
|
46
|
+
@cloud_domain = "example.com" if @cloud_domain == UNSET_VALUE
|
47
|
+
@additional_services = [] if @additional_services == UNSET_VALUE
|
48
|
+
@container = "selinux" if @container == UNSET_VALUE
|
49
|
+
@advanced_puppet_values = {} if @advanced_puppet_values == UNSET_VALUE
|
50
|
+
@repos_base = nil if @repos_base == UNSET_VALUE
|
51
|
+
@jenkins_repo_base = "http://pkg.jenkins-ci.org/redhat/" if @jenkins_repo_base == UNSET_VALUE
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
@@ -0,0 +1,111 @@
|
|
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
|
+
require 'pathname'
|
17
|
+
|
18
|
+
module Vagrant
|
19
|
+
module Openshift
|
20
|
+
class Constants
|
21
|
+
|
22
|
+
FILTER_BROKER="broker"
|
23
|
+
FILTER_CONSOLE="console"
|
24
|
+
FILTER_IMAGES="images"
|
25
|
+
FILTER_RHC="rhc"
|
26
|
+
FILTER_GEARD="geard"
|
27
|
+
|
28
|
+
def self.repos
|
29
|
+
{
|
30
|
+
'origin-server' => 'https://github.com/openshift/origin-server.git',
|
31
|
+
'rhc' => 'https://github.com/openshift/rhc.git',
|
32
|
+
'puppet-openshift_origin' => 'https://github.com/openshift/puppet-openshift_origin.git',
|
33
|
+
'geard' => 'https://github.com/openshift/geard.git',
|
34
|
+
|
35
|
+
}.merge(geard_images)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.geard_images
|
39
|
+
{
|
40
|
+
'wildfly-8-centos' => 'https://github.com/openshift/wildfly-8-centos.git',
|
41
|
+
'ruby-19-centos' => 'https://github.com/openshift/ruby-19-centos.git'
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.images
|
46
|
+
[
|
47
|
+
'centos'
|
48
|
+
] + geard_images.map { |c, _| "openshift/#{c}" }
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.git_branch_current
|
52
|
+
"$(git rev-parse --abbrev-ref HEAD)"
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.plugins_conf_dir
|
56
|
+
Pathname.new "/plugins"
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.sync_dir
|
60
|
+
Pathname.new "~/sync"
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.build_dir
|
64
|
+
Pathname.new "/data/src/github.com/openshift/"
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.deps_marker
|
68
|
+
Pathname.new "/.origin_deps_installed"
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.git_ssh
|
72
|
+
""
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.restart_services_cmd(is_fedora)
|
76
|
+
services = [ 'mongod', 'activemq', 'cgconfig', 'cgred', 'named',
|
77
|
+
'openshift-broker', 'openshift-console',
|
78
|
+
'openshift-node-web-proxy', 'openshift-watchman',
|
79
|
+
'sshd', 'httpd' ]
|
80
|
+
|
81
|
+
if(is_fedora)
|
82
|
+
services << 'mcollective'
|
83
|
+
else
|
84
|
+
services << 'ruby193-mcollective'
|
85
|
+
end
|
86
|
+
|
87
|
+
cmd = []
|
88
|
+
cmd += services.map do |service|
|
89
|
+
"/sbin/service #{service} stop;"
|
90
|
+
end
|
91
|
+
cmd << "rm -f /var/www/openshift/broker/httpd/run/httpd.pid;"
|
92
|
+
cmd << "rm -f /var/www/openshift/console/httpd/run/httpd.pid;"
|
93
|
+
cmd += services.map do |service|
|
94
|
+
"/sbin/service #{service} start;"
|
95
|
+
end
|
96
|
+
cmd << "rm -rf /var/www/openshift/broker/tmp/cache/*;"
|
97
|
+
cmd << "/etc/cron.minutely/openshift-facts;"
|
98
|
+
cmd << "/sbin/service openshift-tc start || /sbin/service openshift-tc reload;"
|
99
|
+
if(is_fedora)
|
100
|
+
cmd << "/sbin/service network reload;"
|
101
|
+
else
|
102
|
+
cmd << "/sbin/service network restart;"
|
103
|
+
end
|
104
|
+
cmd << "/sbin/service messagebus restart;"
|
105
|
+
cmd << "/sbin/service oddjobd restart;"
|
106
|
+
|
107
|
+
cmd
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,213 @@
|
|
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
|
+
require "tempfile"
|
17
|
+
require "timeout"
|
18
|
+
|
19
|
+
module Vagrant
|
20
|
+
module Openshift
|
21
|
+
module CommandHelper
|
22
|
+
def scl_wrapper(is_fedora, command)
|
23
|
+
is_fedora ? command : %{scl enable ruby193 "#{command}"}
|
24
|
+
end
|
25
|
+
|
26
|
+
def sudo(machine, command, options={})
|
27
|
+
stdout = []
|
28
|
+
stderr = []
|
29
|
+
rc = -1
|
30
|
+
options[:timeout] = 60*10 unless options.has_key? :timeout
|
31
|
+
options[:retries] = 1 unless options.has_key? :retries
|
32
|
+
options[:fail_on_error] = true unless options.has_key? :fail_on_error
|
33
|
+
|
34
|
+
(1..options[:retries]).each do |retry_count|
|
35
|
+
begin
|
36
|
+
machine.env.ui.info "Running ssh/sudo command '#{command}' with timeout #{options[:timeout]}. Attempt ##{retry_count}"
|
37
|
+
Timeout::timeout(options[:timeout]) do
|
38
|
+
rc = machine.communicate.sudo(command) do |type, data|
|
39
|
+
if [:stderr, :stdout].include?(type)
|
40
|
+
if type == :stdout
|
41
|
+
color = :green
|
42
|
+
stdout << data
|
43
|
+
else
|
44
|
+
color = :red
|
45
|
+
stderr << data
|
46
|
+
end
|
47
|
+
machine.env.ui.info(data, :color => color, :new_line => false, :prefix => false) unless options[:buffered_output] == true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
rescue Timeout::Error
|
52
|
+
machine.env.ui.warn "Timeout occurred while running ssh/sudo command: #{command}"
|
53
|
+
rc = -1
|
54
|
+
rescue Exception => e
|
55
|
+
machine.env.ui.warn "Error while running ssh/sudo command: #{command}"
|
56
|
+
rc ||= -1
|
57
|
+
end
|
58
|
+
|
59
|
+
break if rc == 0
|
60
|
+
end
|
61
|
+
exit rc if options[:fail_on_error] && rc != 0
|
62
|
+
|
63
|
+
[stdout, stderr, rc]
|
64
|
+
end
|
65
|
+
|
66
|
+
def do_execute(machine, command)
|
67
|
+
stdout = []
|
68
|
+
stderr = []
|
69
|
+
rc = -1
|
70
|
+
|
71
|
+
machine.env.ui.info "Running command '#{command}'"
|
72
|
+
rc = machine.communicate.execute(command) do |type, data|
|
73
|
+
if [:stderr, :stdout].include?(type)
|
74
|
+
if type == :stdout
|
75
|
+
color = :green
|
76
|
+
stdout << data
|
77
|
+
else
|
78
|
+
color = :red
|
79
|
+
stderr << data
|
80
|
+
end
|
81
|
+
machine.env.ui.info(data, :color => color, :new_line => false, :prefix => false)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
[stdout, stderr, rc]
|
86
|
+
end
|
87
|
+
|
88
|
+
def remote_write(machine, dest, owner="root", perms="0644", &block)
|
89
|
+
file = Tempfile.new('file')
|
90
|
+
begin
|
91
|
+
file.write(block.yield)
|
92
|
+
file.flush
|
93
|
+
file.close
|
94
|
+
machine.communicate.upload(file.path, "/tmp/#{File.basename(file)}")
|
95
|
+
dest_dir = File.dirname(dest)
|
96
|
+
sudo(machine,
|
97
|
+
%{mkdir -p #{dest_dir};
|
98
|
+
mv /tmp/#{File.basename(file)} #{dest} &&
|
99
|
+
chown #{owner} #{dest} &&
|
100
|
+
chmod #{perms} #{dest}})
|
101
|
+
ensure
|
102
|
+
file.unlink
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def sync_bash_command(repo_name, build_cmd, file_path="", branch_name=Vagrant::Openshift::Constants.git_branch_current, sync_path=Vagrant::Openshift::Constants.sync_dir, commit_id_path="#{sync_path}/#{repo_name}")
|
107
|
+
refname = branch_name
|
108
|
+
refname = "#{refname}:#{file_path}" if !file_path.empty?
|
109
|
+
git_status_cmd = "git status --porcelain"
|
110
|
+
git_status_cmd = "#{git_status_cmd} | grep #{file_path}" if !file_path.empty?
|
111
|
+
cmd = %{
|
112
|
+
pushd /data/src/github.com/openshift/#{repo_name}
|
113
|
+
commit_id=`git rev-parse #{refname}`
|
114
|
+
git_status=$(#{git_status_cmd})
|
115
|
+
if [ -f #{commit_id_path} ]
|
116
|
+
then
|
117
|
+
previous_commit_id=$(cat #{commit_id_path})
|
118
|
+
fi
|
119
|
+
if [ "$previous_commit_id" != "$commit_id" ] || [ -n "$git_status" ]
|
120
|
+
then
|
121
|
+
#{build_cmd}
|
122
|
+
else
|
123
|
+
echo "No update for #{repo_name}, #{refname}"
|
124
|
+
fi
|
125
|
+
mkdir -p #{sync_path}
|
126
|
+
echo -n $commit_id > #{commit_id_path}
|
127
|
+
popd
|
128
|
+
}
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
def sync_bash_command_on_dockerfile(repo_name, dockerfile_build_path, build_cmd)
|
133
|
+
file_path = "#{dockerfile_build_path}/Dockerfile"
|
134
|
+
branch_name=Vagrant::Openshift::Constants.git_branch_current
|
135
|
+
sync_path = "#{Vagrant::Openshift::Constants.sync_dir}/dockerfile/#{repo_name}/#{dockerfile_build_path}"
|
136
|
+
commit_id_path = "#{sync_path}/Dockerfile"
|
137
|
+
sync_bash_command(repo_name, build_cmd, file_path, branch_name, sync_path, commit_id_path)
|
138
|
+
end
|
139
|
+
|
140
|
+
def repo_checkout_bash_command(repo, url)
|
141
|
+
repo_path = File.expand_path(repo)
|
142
|
+
command = ""
|
143
|
+
if Pathname.new(repo_path).exist?
|
144
|
+
if @options[:replace]
|
145
|
+
command += %{
|
146
|
+
echo 'Replacing: #{repo_path}'
|
147
|
+
rm -rf #{repo_path}
|
148
|
+
}
|
149
|
+
else
|
150
|
+
command += "echo 'Already cloned: #{repo}'\n"
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
command += %{
|
155
|
+
cloned=false
|
156
|
+
echo 'Cloning #{repo} ...'
|
157
|
+
}
|
158
|
+
|
159
|
+
if @options[:user]
|
160
|
+
user_repo_url="git@github.com:#{@options[:user]}/#{repo}"
|
161
|
+
command += %{
|
162
|
+
echo 'Cloning #{user_repo_url}'
|
163
|
+
git clone --quiet #{user_repo_url}
|
164
|
+
if [ $? -eq 0 ]; then
|
165
|
+
cloned=true
|
166
|
+
(cd #{repo} && git remote add upstream #{url} && git fetch upstream)
|
167
|
+
else
|
168
|
+
echo 'Fork of repo #{repo} not found. Cloning read-only copy from upstream'
|
169
|
+
fi
|
170
|
+
}
|
171
|
+
|
172
|
+
end
|
173
|
+
command += %{
|
174
|
+
[ $cloned != true ] && git clone --quiet #{url}
|
175
|
+
( cd #{repo} && git checkout #{@options[:branch]} &>/dev/null)
|
176
|
+
}
|
177
|
+
|
178
|
+
command
|
179
|
+
end
|
180
|
+
|
181
|
+
def bash_systemd_polling_functions
|
182
|
+
command = %{
|
183
|
+
function wait_for_success {
|
184
|
+
local retries=1
|
185
|
+
local cmd=$1
|
186
|
+
until [ $retries -ge 21 ]; do
|
187
|
+
/bin/sh -c $cmd
|
188
|
+
[ $? == 0 ] && return 0
|
189
|
+
echo "Command '$cmd' failed ($?). Retry \#${retries}" && sleep 1
|
190
|
+
retries=$[$retries+1]
|
191
|
+
done
|
192
|
+
}
|
193
|
+
|
194
|
+
function wait_for_activate {
|
195
|
+
local retries=0
|
196
|
+
local unit="$1"
|
197
|
+
until [ $retries -ge 20 ]; do
|
198
|
+
state=$(systemctl is-active ctr-${unit}-1.service)
|
199
|
+
[ "$state" == "active" ] && return 0
|
200
|
+
[ "$state" == "failed" ] && break
|
201
|
+
echo "Waiting for ${unit} to become active (${state})" && sleep 1
|
202
|
+
retries=$[$retries+1]
|
203
|
+
done
|
204
|
+
echo "The unit ctr-${unit}-1.service failed to activate."
|
205
|
+
return 1
|
206
|
+
}
|
207
|
+
}
|
208
|
+
return command
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
@@ -0,0 +1,171 @@
|
|
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
|
+
class Plugin < Vagrant.plugin("2")
|
20
|
+
name "OpenShift"
|
21
|
+
description %{
|
22
|
+
Plugin to build and manage OpenShift Origin environments
|
23
|
+
}
|
24
|
+
|
25
|
+
config "openshift" do
|
26
|
+
require_relative "config"
|
27
|
+
Config
|
28
|
+
end
|
29
|
+
|
30
|
+
config(:openshift, :provisioner) do
|
31
|
+
require_relative "config"
|
32
|
+
Config
|
33
|
+
end
|
34
|
+
|
35
|
+
command "sync" do
|
36
|
+
require_relative "command/repo_sync"
|
37
|
+
Commands::RepoSync
|
38
|
+
end
|
39
|
+
|
40
|
+
command "sync-geard" do
|
41
|
+
require_relative "command/repo_sync_geard"
|
42
|
+
Commands::RepoSyncGeard
|
43
|
+
end
|
44
|
+
|
45
|
+
command "origin-build-base" do
|
46
|
+
require_relative "command/build_origin_base"
|
47
|
+
Commands::BuildOriginBase
|
48
|
+
end
|
49
|
+
|
50
|
+
command "build-geard-base" do
|
51
|
+
require_relative "command/build_geard_base"
|
52
|
+
Commands::BuildGeardBase
|
53
|
+
end
|
54
|
+
|
55
|
+
command "build-geard" do
|
56
|
+
require_relative "command/build_geard"
|
57
|
+
Commands::BuildGeard
|
58
|
+
end
|
59
|
+
|
60
|
+
command "install-geard" do
|
61
|
+
require_relative "command/install_geard"
|
62
|
+
Commands::InstallGeard
|
63
|
+
end
|
64
|
+
|
65
|
+
command "install-geard-broker" do
|
66
|
+
require_relative "command/install_geard_broker"
|
67
|
+
Commands::InstallGeardBroker
|
68
|
+
end
|
69
|
+
|
70
|
+
command "restart-geard" do
|
71
|
+
require_relative "command/restart_geard"
|
72
|
+
Commands::RestartGeard
|
73
|
+
end
|
74
|
+
|
75
|
+
command "restart-geard-broker" do
|
76
|
+
require_relative "command/restart_geard_broker"
|
77
|
+
Commands::RestartGeardBroker
|
78
|
+
end
|
79
|
+
|
80
|
+
command "build-geard-broker" do
|
81
|
+
require_relative "command/build_geard_broker"
|
82
|
+
Commands::BuildGeardBroker
|
83
|
+
end
|
84
|
+
|
85
|
+
command "restart-geard-console" do
|
86
|
+
require_relative "command/restart_geard_console"
|
87
|
+
Commands::RestartGeardConsole
|
88
|
+
end
|
89
|
+
|
90
|
+
command "build-geard-console" do
|
91
|
+
require_relative "command/build_geard_console"
|
92
|
+
Commands::BuildGeardConsole
|
93
|
+
end
|
94
|
+
|
95
|
+
command "build-geard-images" do
|
96
|
+
require_relative "command/build_geard_images"
|
97
|
+
Commands::BuildGeardImages
|
98
|
+
end
|
99
|
+
|
100
|
+
command "origin-init" do
|
101
|
+
require_relative "command/openshift_init"
|
102
|
+
Commands::OpenshiftInit
|
103
|
+
end
|
104
|
+
|
105
|
+
command "origin-local-checkout" do
|
106
|
+
require_relative "command/local_repo_setup"
|
107
|
+
Commands::LocalRepoSetup
|
108
|
+
end
|
109
|
+
|
110
|
+
command "geard-local-checkout" do
|
111
|
+
require_relative "command/local_geard_setup"
|
112
|
+
Commands::LocalGeardSetup
|
113
|
+
end
|
114
|
+
|
115
|
+
command "test" do
|
116
|
+
require_relative "command/test"
|
117
|
+
Commands::Test
|
118
|
+
end
|
119
|
+
|
120
|
+
command "test-geard" do
|
121
|
+
require_relative "command/test_geard"
|
122
|
+
Commands::TestGeard
|
123
|
+
end
|
124
|
+
|
125
|
+
command "create-ami" do
|
126
|
+
require_relative "command/create_ami"
|
127
|
+
Commands::CreateAMI
|
128
|
+
end
|
129
|
+
|
130
|
+
command "modify-ami" do
|
131
|
+
require_relative "command/modify_ami"
|
132
|
+
Commands::ModifyAMI
|
133
|
+
end
|
134
|
+
|
135
|
+
command "modify-instance" do
|
136
|
+
require_relative "command/modify_instance"
|
137
|
+
Commands::ModifyInstance
|
138
|
+
end
|
139
|
+
|
140
|
+
command "clone-upstream-repos" do
|
141
|
+
require_relative "command/clone_upstream_repositories"
|
142
|
+
Commands::CloneUpstreamRepositories
|
143
|
+
end
|
144
|
+
|
145
|
+
command "checkout-repos" do
|
146
|
+
require_relative "command/checkout_repositories"
|
147
|
+
Commands::CheckoutRepositories
|
148
|
+
end
|
149
|
+
|
150
|
+
command "install-rhc" do
|
151
|
+
require_relative "command/install_rhc"
|
152
|
+
Commands::InstallRhc
|
153
|
+
end
|
154
|
+
|
155
|
+
command "setup-geard-broker" do
|
156
|
+
require_relative "command/setup_geard_broker"
|
157
|
+
Commands::SetupGeardBroker
|
158
|
+
end
|
159
|
+
|
160
|
+
command "test-geard-image" do
|
161
|
+
require_relative "command/test_geard_image"
|
162
|
+
Commands::TestGeardImage
|
163
|
+
end
|
164
|
+
|
165
|
+
provisioner(:openshift) do
|
166
|
+
require_relative "provisioner"
|
167
|
+
Provisioner
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
@@ -0,0 +1,82 @@
|
|
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
|
+
class Provisioner < Vagrant.plugin(2, :provisioner)
|
20
|
+
include CommandHelper
|
21
|
+
|
22
|
+
# Called with the root configuration of the machine so the provisioner
|
23
|
+
# can add some configuration on top of the machine.
|
24
|
+
#
|
25
|
+
# During this step, and this step only, the provisioner should modify
|
26
|
+
# the root machine configuration to add any additional features it
|
27
|
+
# may need. Examples include sharing folders, networking, and so on.
|
28
|
+
# This step is guaranteed to be called before any of those steps are
|
29
|
+
# done so the provisioner may do that.
|
30
|
+
#
|
31
|
+
# No return value is expected.
|
32
|
+
def configure(root_config)
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
# This is the method called when the actual provisioning should be
|
37
|
+
# done. The communicator is guaranteed to be ready at this point,
|
38
|
+
# and any shared folders or networks are already setup.
|
39
|
+
#
|
40
|
+
# No return value is expected.
|
41
|
+
def provision
|
42
|
+
#check if OpenShift has been installed
|
43
|
+
#reapply puppet configuration so that IPs and ifcfg-* file is correct
|
44
|
+
if @machine.communicate.test("test -d /etc/openshift")
|
45
|
+
@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")
|
48
|
+
sudo(machine,"puppet apply --verbose #{Vagrant::Openshift::Constants.build_dir + 'configure_origin.pp'}", {timeout: 60*20})
|
49
|
+
is_fedora = @machine.communicate.test("test -e /etc/fedora-release")
|
50
|
+
|
51
|
+
sudo(machine,Constants.restart_services_cmd(is_fedora).join("\n"))
|
52
|
+
if @machine.config.openshift.additional_services.size > 0
|
53
|
+
cmd = ""
|
54
|
+
@machine.config.openshift.additional_services.each do |service|
|
55
|
+
cmd += "service #{service} restart;"
|
56
|
+
end
|
57
|
+
sudo(machine,cmd)
|
58
|
+
end
|
59
|
+
|
60
|
+
# TODO: Replace this temporary fix with a complete post-install routine
|
61
|
+
sudo(machine,"oo-admin-ctl-cartridge -c import-node --activate --obsolete && RAILS_ENV=test oo-admin-ctl-cartridge -c import-node --activate --obsolete")
|
62
|
+
else
|
63
|
+
#TODO is_fedora is a temporary fix for the new environment
|
64
|
+
is_fedora = @machine.communicate.test("test -e /etc/fedora-release")
|
65
|
+
if is_fedora
|
66
|
+
ssh_user = machine.ssh_info[:username]
|
67
|
+
sync_dir = Vagrant::Openshift::Constants.sync_dir
|
68
|
+
## pause to stabilize environment to try to correct odd sudo error on aws
|
69
|
+
sleep 2
|
70
|
+
sudo(machine, "mkdir -p #{sync_dir} && chown -R #{ssh_user}:#{ssh_user} #{sync_dir}")
|
71
|
+
end
|
72
|
+
unless is_fedora || @machine.communicate.test("test -f #{Vagrant::Openshift::Constants.deps_marker}")
|
73
|
+
@machine.ui.info("Preparing base environment")
|
74
|
+
require_relative "command/build_origin_base"
|
75
|
+
Vagrant::Openshift::Commands::BuildOriginBase.new([], @machine.env).execute
|
76
|
+
@machine.communicate.sudo("touch #{Vagrant::Openshift::Constants.deps_marker}")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|