vagrant-openshift 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +1 -0
  3. data/.gitignore +24 -0
  4. data/Gemfile +11 -0
  5. data/LICENSE.txt +13 -0
  6. data/README.asciidoc +379 -0
  7. data/Rakefile +53 -0
  8. data/lib/vagrant-openshift/action/build_geard.rb +41 -0
  9. data/lib/vagrant-openshift/action/build_geard_broker.rb +59 -0
  10. data/lib/vagrant-openshift/action/build_geard_console.rb +55 -0
  11. data/lib/vagrant-openshift/action/build_geard_images.rb +54 -0
  12. data/lib/vagrant-openshift/action/build_sources.rb +39 -0
  13. data/lib/vagrant-openshift/action/checkout_repositories.rb +72 -0
  14. data/lib/vagrant-openshift/action/checkout_tests.rb +57 -0
  15. data/lib/vagrant-openshift/action/clean.rb +51 -0
  16. data/lib/vagrant-openshift/action/clean_network_setup.rb +52 -0
  17. data/lib/vagrant-openshift/action/clone_upstream_repositories.rb +65 -0
  18. data/lib/vagrant-openshift/action/create_ami.rb +54 -0
  19. data/lib/vagrant-openshift/action/create_bare_repo_placeholders.rb +53 -0
  20. data/lib/vagrant-openshift/action/create_puppet_file.rb +84 -0
  21. data/lib/vagrant-openshift/action/create_test_users.rb +36 -0
  22. data/lib/vagrant-openshift/action/create_yum_repositories.rb +121 -0
  23. data/lib/vagrant-openshift/action/download_artifacts.rb +70 -0
  24. data/lib/vagrant-openshift/action/generate_template.rb +89 -0
  25. data/lib/vagrant-openshift/action/idle_all_gears.rb +36 -0
  26. data/lib/vagrant-openshift/action/install_build_dependencies.rb +48 -0
  27. data/lib/vagrant-openshift/action/install_geard.rb +76 -0
  28. data/lib/vagrant-openshift/action/install_geard_base_dependencies.rb +72 -0
  29. data/lib/vagrant-openshift/action/install_geard_broker.rb +39 -0
  30. data/lib/vagrant-openshift/action/install_geard_images.rb +51 -0
  31. data/lib/vagrant-openshift/action/install_open_shift_dependencies.rb +50 -0
  32. data/lib/vagrant-openshift/action/install_rhc.rb +42 -0
  33. data/lib/vagrant-openshift/action/local_geard_checkout.rb +58 -0
  34. data/lib/vagrant-openshift/action/local_repo_checkout.rb +47 -0
  35. data/lib/vagrant-openshift/action/modify_ami.rb +54 -0
  36. data/lib/vagrant-openshift/action/modify_instance.rb +71 -0
  37. data/lib/vagrant-openshift/action/prepare_ssh_config.rb +89 -0
  38. data/lib/vagrant-openshift/action/preserve_mcollective_logs.rb +48 -0
  39. data/lib/vagrant-openshift/action/restart_geard.rb +39 -0
  40. data/lib/vagrant-openshift/action/restart_geard_broker.rb +43 -0
  41. data/lib/vagrant-openshift/action/restart_geard_console.rb +43 -0
  42. data/lib/vagrant-openshift/action/run_geard_tests.rb +57 -0
  43. data/lib/vagrant-openshift/action/run_tests.rb +47 -0
  44. data/lib/vagrant-openshift/action/set_host_name.rb +43 -0
  45. data/lib/vagrant-openshift/action/setup_bind_dns_key.rb +38 -0
  46. data/lib/vagrant-openshift/action/setup_bind_host.rb +141 -0
  47. data/lib/vagrant-openshift/action/setup_builder_files.rb +57 -0
  48. data/lib/vagrant-openshift/action/setup_geard_broker.rb +71 -0
  49. data/lib/vagrant-openshift/action/sync_local_repository.rb +115 -0
  50. data/lib/vagrant-openshift/action/sync_upstream_repository.rb +71 -0
  51. data/lib/vagrant-openshift/action/test_exit_code.rb +36 -0
  52. data/lib/vagrant-openshift/action/uninstall_openshift_rpms.rb +37 -0
  53. data/lib/vagrant-openshift/action/yum_update.rb +67 -0
  54. data/lib/vagrant-openshift/action.rb +308 -0
  55. data/lib/vagrant-openshift/command/build_geard.rb +51 -0
  56. data/lib/vagrant-openshift/command/build_geard_base.rb +51 -0
  57. data/lib/vagrant-openshift/command/build_geard_broker.rb +59 -0
  58. data/lib/vagrant-openshift/command/build_geard_console.rb +59 -0
  59. data/lib/vagrant-openshift/command/build_geard_images.rb +68 -0
  60. data/lib/vagrant-openshift/command/build_origin_base.rb +51 -0
  61. data/lib/vagrant-openshift/command/checkout_repositories.rb +55 -0
  62. data/lib/vagrant-openshift/command/clone_upstream_repositories.rb +54 -0
  63. data/lib/vagrant-openshift/command/create_ami.rb +49 -0
  64. data/lib/vagrant-openshift/command/install_geard.rb +51 -0
  65. data/lib/vagrant-openshift/command/install_geard_broker.rb +51 -0
  66. data/lib/vagrant-openshift/command/install_rhc.rb +49 -0
  67. data/lib/vagrant-openshift/command/local_geard_setup.rb +62 -0
  68. data/lib/vagrant-openshift/command/local_repo_setup.rb +62 -0
  69. data/lib/vagrant-openshift/command/modify_ami.rb +54 -0
  70. data/lib/vagrant-openshift/command/modify_instance.rb +63 -0
  71. data/lib/vagrant-openshift/command/openshift_init.rb +83 -0
  72. data/lib/vagrant-openshift/command/repo_sync.rb +73 -0
  73. data/lib/vagrant-openshift/command/repo_sync_geard.rb +78 -0
  74. data/lib/vagrant-openshift/command/restart_geard.rb +51 -0
  75. data/lib/vagrant-openshift/command/restart_geard_broker.rb +51 -0
  76. data/lib/vagrant-openshift/command/restart_geard_console.rb +51 -0
  77. data/lib/vagrant-openshift/command/setup_geard_broker.rb +49 -0
  78. data/lib/vagrant-openshift/command/test.rb +108 -0
  79. data/lib/vagrant-openshift/command/test_geard.rb +59 -0
  80. data/lib/vagrant-openshift/command/test_geard_image.rb +147 -0
  81. data/lib/vagrant-openshift/config.rb +56 -0
  82. data/lib/vagrant-openshift/constants.rb +111 -0
  83. data/lib/vagrant-openshift/helper/command_helper.rb +213 -0
  84. data/lib/vagrant-openshift/plugin.rb +171 -0
  85. data/lib/vagrant-openshift/provisioner.rb +82 -0
  86. data/lib/vagrant-openshift/templates/builder/Rakefile +231 -0
  87. data/lib/vagrant-openshift/templates/builder/lib/.gitkeep +0 -0
  88. data/lib/vagrant-openshift/templates/builder/lib/rpm.rb +248 -0
  89. data/lib/vagrant-openshift/templates/builder/lib/test.rb +432 -0
  90. data/lib/vagrant-openshift/templates/builder/yum-listbuilddep +124 -0
  91. data/lib/vagrant-openshift/templates/command/init-openshift/Vagrantfile.erb +175 -0
  92. data/lib/vagrant-openshift/templates/command/init-openshift/box_info.yaml +152 -0
  93. data/lib/vagrant-openshift/version.rb +21 -0
  94. data/lib/vagrant-openshift.rb +34 -0
  95. data/vagrant-openshift.gemspec +43 -0
  96. metadata +234 -0
@@ -0,0 +1,121 @@
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 CreateYumRepositories
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ end
26
+
27
+ def set_yum_repo(env, file, repo_name, baseurl)
28
+ unless baseurl.nil?
29
+ sudo(env[:machine], %{
30
+ (
31
+ echo "set /files#{file}/#{repo_name}/baseurl #{baseurl}"
32
+ echo "set /files#{file}/#{repo_name}/gpgcheck 0"
33
+ echo "set /files#{file}/#{repo_name}/name #{repo_name}"
34
+ echo "rm /files#{file}/#{repo_name}/mirrorlist"
35
+ echo save
36
+ ) | augtool
37
+ })
38
+ end
39
+ end
40
+
41
+ def call(env)
42
+ options = env[:machine].config.openshift
43
+ is_fedora = env[:machine].communicate.test("test -e /etc/fedora-release")
44
+ is_centos = env[:machine].communicate.test("test -e /etc/centos-release")
45
+ is_rhel = env[:machine].communicate.test("test -e /etc/redhat-release") && !is_centos && !is_fedora
46
+
47
+ sudo(env[:machine], "yum install -y augeas")
48
+ if is_centos
49
+ sudo(env[:machine], "yum install -y centos-release-SCL.x86_64 http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm")
50
+ set_yum_repo(env, "/etc/yum.repos.d/CentOS-Base.repo", "base", options.os_repo)
51
+ set_yum_repo(env, "/etc/yum.repos.d/CentOS-Base.repo", "updates", options.os_updates_repo)
52
+ set_yum_repo(env, "/etc/yum.repos.d/CentOS-Base.repo", "extras", options.os_extras_repo)
53
+ set_yum_repo(env, "/etc/yum.repos.d/epel.repo", "epel", options.optional_repo)
54
+ set_yum_repo(env, "/etc/yum.repos.d/CentOS-SCL.repo", "scl", options.os_scl_repo)
55
+ end
56
+
57
+ if is_rhel
58
+ set_yum_repo(env, "/etc/yum.repos.d/RHEL-Base.repo", "base", options.os_repo)
59
+ set_yum_repo(env, "/etc/yum.repos.d/RHEL-Base.repo", "updates", options.os_updates_repo)
60
+ set_yum_repo(env, "/etc/yum.repos.d/epel.repo", "epel", options.optional_repo)
61
+ set_yum_repo(env, "/etc/yum.repos.d/RHEL-SCL.repo", "scl", options.os_scl_repo)
62
+
63
+ end
64
+
65
+ if is_fedora
66
+ set_yum_repo(env, "/etc/yum.repos.d/fedora.repo", "fedora", options.os_repo)
67
+ set_yum_repo(env, "/etc/yum.repos.d/fedora.repo", "updates", options.os_updates_repo)
68
+ end
69
+
70
+ if options.repos_base == nil
71
+ if is_fedora
72
+ options.repos_base = "http://mirror.openshift.com/pub/openshift-origin/nightly/fedora-19/"
73
+ elsif is_centos or is_rhel
74
+ options.repos_base = "http://mirror.openshift.com/pub/openshift-origin/nightly/rhel-6/"
75
+ end
76
+
77
+ packages = "#{options.repos_base}/packages/latest/x86_64"
78
+ dependencies = "#{options.repos_base}/dependencies/x86_64"
79
+ else
80
+ packages = "#{options.repos_base}/packages/x86_64"
81
+ dependencies = "#{options.repos_base}/dependencies/x86_64"
82
+ end
83
+
84
+ set_yum_repo(env, "/etc/yum.repos.d/openshift-deps.repo", "openshift-deps", dependencies)
85
+
86
+ sudo(env[:machine], "yum clean all")
87
+
88
+ unless is_fedora
89
+ unless env[:machine].communicate.test("rpm -q epel-release")
90
+ #Workaround broken RHEL image which does not recover after restart.
91
+ if "VagrantPlugins::AWS::Provider" == env[:machine].provider.class.to_s
92
+ remote_write(env[:machine], "/etc/rc.local") {
93
+ %{#!/bin/sh
94
+ #
95
+ # This script will be executed *after* all the other init scripts.
96
+ # You can put your own initialization stuff in here if you don't
97
+ # want to do the full Sys V style init stuff.
98
+
99
+ touch /var/lock/subsys/local
100
+ if [ ! -d /root/.ssh ] ; then
101
+ mkdir -p /root/.ssh
102
+ chmod 0700 /root/.ssh
103
+ restorecon /root/.ssh
104
+ fi
105
+
106
+ # bz 707364
107
+ if [ ! -f /etc/blkid/blkid.tab ] ; then
108
+ blkid /dev/xvda &>/dev/null
109
+ fi
110
+ }}
111
+ sudo env[:machine], "chmod og+x /etc/rc.local"
112
+ end
113
+ end
114
+ end
115
+
116
+ @app.call(env)
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,70 @@
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
+ module Action
21
+ class DownloadArtifacts
22
+ include CommandHelper
23
+
24
+ def initialize(app, env)
25
+ @app = app
26
+ @env = env
27
+ end
28
+
29
+ def call(env)
30
+ machine = @env[:machine]
31
+ machine.ui.info "Downloading logs and rpms"
32
+ ssh_info = machine.ssh_info
33
+ private_key_path = ssh_info[:private_key_path].kind_of?(Array) ? ssh_info[:private_key_path][0] : ssh_info[:private_key_path]
34
+
35
+ artifacts_dir = Pathname.new(File.expand_path(machine.env.root_path + "artifacts"))
36
+ download_map = {
37
+ "/tmp/rhc/" => artifacts_dir + "test_runs/",
38
+ "/var/log/openshift/" => artifacts_dir + "openshift_logs/",
39
+ "/var/log/httpd/" => artifacts_dir + "node_httpd_logs/",
40
+ "/var/log/yum.log" => artifacts_dir + "yum.log",
41
+ "/var/log/messages" => artifacts_dir + "messages",
42
+ "/var/log/secure" => artifacts_dir + "secure",
43
+ "/var/log/audit/audit.log" => artifacts_dir + "audit.log",
44
+ #"/tmp/rhc/*_coverage" => artifacts_dir + "coverage/",
45
+ "/var/log/mcollective.*" => artifacts_dir + "mcollective/",
46
+ "#{Constants.build_dir}/origin-rpms/" => artifacts_dir + "rpms/",
47
+ "#{Constants.build_dir}/origin-srpms/" => artifacts_dir + "srpms/"
48
+ }
49
+
50
+ download_map.each do |source,target|
51
+ machine.ui.info "Downloading artifacts from '#{source}' to '#{target}'"
52
+ if target.to_s.end_with? '/'
53
+ FileUtils.mkdir_p target.to_s
54
+ else
55
+ FileUtils.mkdir_p File.dirname(target.to_s)
56
+ end
57
+
58
+ command = "/usr/bin/rsync -avz -e 'ssh -i #{private_key_path}' --rsync-path='sudo rsync' #{ssh_info[:username]}@#{ssh_info[:host]}:#{source} #{target}"
59
+
60
+ if not system(command)
61
+ machine.ui.warn "Unable to download artifact"
62
+ machine.ui.warn r.stderr
63
+ end
64
+ end
65
+ @app.call(env)
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,89 @@
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 'yaml'
17
+ require 'fog'
18
+
19
+ module Vagrant
20
+ module Openshift
21
+ module Action
22
+ class GenerateTemplate
23
+ include CommandHelper
24
+
25
+ def initialize(app, env, options)
26
+ @app = app
27
+ @env = env
28
+ @options = options
29
+ end
30
+
31
+ def call(env)
32
+ os = @options[:os].to_sym
33
+ stage = @options[:stage].to_sym
34
+ inst_ts = Time.now.getutc.strftime('%Y%m%d_%H%M')
35
+
36
+ template_path = Pathname.new(File.expand_path("#{__FILE__}/../../templates/command/init-openshift/Vagrantfile.erb"))
37
+ box_info_path = Pathname.new(File.expand_path("#{__FILE__}/../../templates/command/init-openshift/box_info.yaml"))
38
+
39
+ box_info_data = YAML.load(File.new(box_info_path))
40
+ box_info = box_info_data[os][stage]
41
+ box_info[:instance_name] = @options[:name].nil? ? 'openshift_origin_' + inst_ts : @options[:name]
42
+ box_info[:os] = os
43
+ box_info[:vagrant_guest] = [:centos6, :rhel6].include?(os) ? :redhat : os
44
+ box_info[:port_mappings] = @options[:port_mappings]
45
+
46
+ @openstack_creds_file = ENV['OPENSTACK_CREDS'].nil? || ENV['OPENSTACK_CREDS'] == '' ? "~/.openstackcred" : ENV['OPENSTACK_CREDS']
47
+ @openstack_creds_file = Pathname.new(File.expand_path(@openstack_creds_file))
48
+ box_info[:openstack_creds_file] = @openstack_creds_file
49
+
50
+ @aws_creds_file = ENV['AWS_CREDS'].nil? || ENV['AWS_CREDS'] == '' ? "~/.awscred" : ENV['AWS_CREDS']
51
+ @aws_creds_file = Pathname.new(File.expand_path(@aws_creds_file))
52
+ box_info[:aws_creds_file] = @aws_creds_file
53
+ find_ami_from_tag(box_info)
54
+
55
+ contents = Vagrant::Util::TemplateRenderer.render(template_path.to_s[0..-5], box_info: box_info)
56
+ File.open("Vagrantfile", "w+") do |f|
57
+ f.write(contents)
58
+ end
59
+
60
+ @app.call(env)
61
+ end
62
+
63
+ private
64
+
65
+ def find_ami_from_tag(box_info)
66
+ return if box_info[:aws][:ami_tag_prefix].nil?
67
+ @env[:ui].info("Reading AWS credentials from #{@aws_creds_file.to_s}")
68
+ if @aws_creds_file.exist?
69
+ aws_creds = @aws_creds_file.exist? ? Hash[*(File.open(@aws_creds_file.to_s).readlines.map{ |l| l.split('=') }.flatten.map{ |i| i.strip })] : {}
70
+
71
+ fog_config = {
72
+ :provider => :aws,
73
+ :region => box_info[:aws][:ami_region],
74
+ :aws_access_key_id => aws_creds['AWSAccessKeyId'],
75
+ :aws_secret_access_key => aws_creds['AWSSecretKey'],
76
+ }
77
+
78
+ aws_compute = Fog::Compute.new(fog_config)
79
+ @env[:ui].info("Searching for latest base AMI")
80
+ images = aws_compute.images.all({'Owner' => 'self', 'name' => "#{box_info[:aws][:ami_tag_prefix]}*" })
81
+ latest_image = images.sort_by{ |i| i.name.split("_")[-1].to_i }.last
82
+ box_info[:aws][:ami] = latest_image.id
83
+ @env[:ui].info("Found: #{latest_image.id} (#{latest_image.name})")
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,36 @@
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 IdleAllGears
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 idle_all_gears')}"
31
+ @app.call(env)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,48 @@
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 InstallBuildDependencies
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ @env = env
26
+ end
27
+
28
+ def call(env)
29
+ sudo(env[:machine], "yum install -y puppet git tito yum-utils wget make tig mlocate bind augeas vim")
30
+ is_fedora = env[:machine].communicate.test("test -e /etc/fedora-release")
31
+
32
+ if is_fedora
33
+ sudo(env[:machine], "yum install -y rubygem-rake rubygem-fakefs")
34
+ else
35
+ sudo(env[:machine], "yum install -y ruby193-rubygem-rake ruby193-build scl-utils-build libuv libuv-devel http-parser http-parser-devel createrepo")
36
+ #test dependencies
37
+ sudo(env[:machine], "yum install -y ruby193-rubygem-net-ssh ruby193-rubygem-archive-tar-minitar ruby193-rubygem-fakefs ruby193-rubygem-httpclient ruby193-rubygem-test-unit")
38
+ sudo(env[:machine], "yum install -y ruby193-rubygem-cucumber ruby193-rubygem-simplecov ruby193-rubygem-webmock ruby193-rubygem-poltergeist")
39
+
40
+ #rhc client dependencies for SCL Ruby 1.9.3 environment
41
+ sudo(env[:machine], "yum install -y rubygem-parseconfig ruby193-rubygem-net-ssh-multi ruby193-rubygem-commander ruby193-rubygem-open4")
42
+ end
43
+ @app.call(env)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,76 @@
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 InstallGeard
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ @env = env
26
+ end
27
+
28
+ def call(env)
29
+ ssh_user = env[:machine].ssh_info[:username]
30
+ sudo(env[:machine], %{
31
+ set -x
32
+ # TODO Remove me ASAP
33
+ setenforce 0
34
+ usermod -a -G docker #{ssh_user}
35
+
36
+ GEARD_PATH=/data/src/github.com/openshift/geard
37
+ chown -R #{ssh_user}:#{ssh_user} /data
38
+
39
+ # Modify SSHD config to use gear-auth-keys-command to support git clone from repo
40
+ echo -e '\\nAuthorizedKeysCommand /usr/sbin/gear-auth-keys-command' >> /etc/ssh/sshd_config
41
+ echo -e '\\nAuthorizedKeysCommandUser nobody' >> /etc/ssh/sshd_config
42
+
43
+ cat > /etc/profile.d/geard.sh <<DELIM
44
+ export GOPATH=/data
45
+ export PATH=$GOPATH/bin:$PATH
46
+ export GEARD_URI=http://172.17.42.1:43273
47
+ DELIM
48
+
49
+ # Must listen on docker gateway address for container to access host, see: https://github.com/dotcloud/docker/issues/1143
50
+ GEARD_OPTS=http://172.17.42.1:43273
51
+ cat > /usr/lib/systemd/system/geard.service <<DELIM
52
+ [Unit]
53
+ Description=Gear Provisioning Daemon (geard)
54
+ After=docker.service
55
+ Requires=docker.service
56
+ Documentation=https://github.com/openshift/geard
57
+
58
+ [Service]
59
+ Type=simple
60
+ EnvironmentFile=-/etc/default/gear
61
+ ExecStart=/usr/bin/gear daemon $GEARD_OPTS
62
+
63
+ [Install]
64
+ WantedBy=multi-user.target
65
+ DELIM
66
+
67
+ systemctl restart sshd
68
+ systemctl enable geard.service
69
+ })
70
+
71
+ @app.call(env)
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,72 @@
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 InstallGeardBaseDependencies
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ @env = env
26
+ end
27
+
28
+ def call(env)
29
+ # FIXME: Move 'openshift/centos-mongodb' into openshift org and then
30
+ # add the image into 'repositories' constants
31
+ #
32
+ sudo(env[:machine], "yum install -y puppet git tito yum-utils wget make mlocate bind augeas vim docker-io hg bzr libselinux-devel vim tig glibc-static btrfs-progs-devel device-mapper-devel sqlite-devel libnetfilter_queue-devel gcc gcc-c++")
33
+ #
34
+ # FIXME: Need to install golang packages 'after' the 'gcc' is
35
+ # installed. See BZ#1101508
36
+ #
37
+ sudo(env[:machine], "yum install -y golang golang-pkg* golang-src")
38
+ #
39
+ sudo(env[:machine], %{
40
+ cat > /usr/lib/systemd/system/docker.service <<DELIM
41
+ [Unit]
42
+ Description=Docker Application Container Engine
43
+ Documentation=http://docs.docker.io
44
+ After=network.target
45
+ Requires=docker.socket
46
+
47
+ [Service]
48
+ Type=notify
49
+ EnvironmentFile=-/etc/sysconfig/docker
50
+ ExecStart=/usr/bin/docker -d --selinux-enabled -H fd:// --bip=172.17.42.1/16
51
+ Restart=on-failure
52
+ LimitNOFILE=1048576
53
+ LimitNPROC=1048576
54
+
55
+ [Install]
56
+ WantedBy=multi-user.target
57
+ DELIM
58
+ systemctl daemon-reload
59
+ systemctl enable docker
60
+ systemctl start docker
61
+ docker pull openshift/centos-mongodb
62
+ if ! docker images | grep 'openshift/centos-mongodb' 2>&1 > /dev/null ; then
63
+ docker pull openshift/centos-mongodb
64
+ fi
65
+ touch #{Vagrant::Openshift::Constants.deps_marker}
66
+ }, {:timeout=>60*20})
67
+ @app.call(env)
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,39 @@
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 InstallGeardBroker
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ @env = env
26
+ end
27
+
28
+ def call(env)
29
+ sudo(env[:machine], %{
30
+ set -e
31
+ pushd /data/src/github.com/openshift/origin-server/broker/docker
32
+ gear deploy origin_deploy.json
33
+ popd
34
+ })
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,51 @@
1
+ #--
2
+ # Copyright 2014 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 InstallGeardImages
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ @env = env
26
+ end
27
+
28
+ def call(env)
29
+ Vagrant::Openshift::Constants.images.each do |image_name, _|
30
+ puts "Importing #{image_name} from Docker index"
31
+ sudo(env[:machine], pull_docker_image_cmd(image_name), {
32
+ :timeout=>60*20
33
+ })
34
+ end
35
+ @app.call(env)
36
+ end
37
+
38
+ def pull_docker_image_cmd(image_name)
39
+ %{
40
+ docker pull '#{image_name}'
41
+ if ! docker inspect '#{image_name}' 2>&1 > /dev/null
42
+ then
43
+ docker pull '#{image_name}'
44
+ fi
45
+ }
46
+ end
47
+
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,50 @@
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 InstallOpenShiftDependencies
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
+
31
+ if is_fedora
32
+ unless env[:machine].communicate.test("rpm -q activemq-5.6.0-6.fc19.x86_64")
33
+ sudo(env[:machine], "yum erase -y activemq")
34
+ sudo(env[:machine], "yum install -y https://mirror.openshift.com/pub/origin-server/nightly/fedora-19/dependencies/x86_64/activemq-5.6.0-6.fc19.x86_64.rpm")
35
+ end
36
+ sudo(env[:machine], "yum install -y rubygem-rake")
37
+ sudo(env[:machine], "yum install -y rubygem-net-ssh-multi rubygem-net-ssh-gateway")
38
+ else
39
+ sudo(env[:machine], "yum install -y activemq")
40
+ sudo(env[:machine], "yum install -y ruby193-rubygem-rake ruby193-build scl-utils-build")
41
+ sudo(env[:machine], "yum install -y ruby193-rubygem-net-ssh-multi ruby193-rubygem-net-ssh-gateway")
42
+ end
43
+
44
+ sudo(env[:machine], "cd #{Constants.build_dir + "builder"}; #{scl_wrapper(is_fedora, 'rake install_deps')}", {timeout: 0})
45
+ @app.call(env)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end