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,54 @@
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 BuildGeardImages
21
+ include CommandHelper
22
+
23
+ def initialize(app, env, options)
24
+ @app = app
25
+ @env = env
26
+ @options = options
27
+ end
28
+
29
+ def call(env)
30
+ # FIXME: Measure what would be the appropriate timeout here as the
31
+ # docker build command can take quite a long time...
32
+ #
33
+ @options[:geard_images].each do |geard_image, _|
34
+ docker_image_name = "openshift/#{geard_image}"
35
+ docker_file_path = "#{Constants.build_dir}#{geard_image}"
36
+ build_cmd = %{
37
+ echo "Building #{docker_image_name} image"
38
+ pushd #{docker_file_path}
39
+ docker build --rm #{@options[:force] ? "--no-cache" : ""} -t #{docker_image_name} .
40
+ popd
41
+ }
42
+ if @options[:force]
43
+ sudo(env[:machine], build_cmd, { :timeout => 60*20 })
44
+ else
45
+ sudo(env[:machine], sync_bash_command(geard_image, build_cmd), { :timeout => 60*20 })
46
+ end
47
+ end
48
+ @app.call(env)
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+ 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 BuildSources
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
+ hostname = env[:machine].config.vm.hostname
31
+ sudo(env[:machine],"echo #{hostname} > /proc/sys/kernel/hostname")
32
+ sudo(env[:machine], "cd #{Constants.build_dir + "builder"}; #{scl_wrapper(is_fedora,'rake update_packages')}", {timeout: 60*30})
33
+
34
+ @app.call(env)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ 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 CheckoutRepositories
21
+ include CommandHelper
22
+
23
+ def initialize(app, env, options={})
24
+ @app = app
25
+ @env = env
26
+ @options = options
27
+ end
28
+
29
+ def call(env)
30
+ git_clone_commands = ""
31
+ Constants.repos.each do |repo_name, url|
32
+ bare_repo_name = repo_name + "-bare"
33
+ bare_repo_path = Constants.build_dir + bare_repo_name
34
+ repo_path = Constants.build_dir + repo_name
35
+
36
+ git_clone_commands += %{
37
+ (
38
+ if [ -d #{bare_repo_path} ]; then
39
+ rm -rf #{repo_path}
40
+ echo 'Cloning #{repo_name} ...'
41
+ git clone --quiet #{bare_repo_path} #{repo_path}
42
+ }
43
+
44
+ if @options[:branch] && @options[:branch][repo_name]
45
+ git_clone_commands += "cd #{repo_path}; git checkout --quiet #{@options[:branch][repo_name]}; cd #{Constants.build_dir};\n"
46
+ end
47
+ git_clone_commands += %{
48
+ else
49
+ MISSING_REPO+='#{bare_repo_name}'
50
+ fi
51
+ ) &
52
+ PIDS+=$!\" \";
53
+ }
54
+ end
55
+
56
+ git_clone_commands += %{
57
+ [ -n \"$PIDS\" ] && wait $PIDS
58
+ if [ -n \"$MISSING_REPO\" ]; then
59
+ echo 'Missing required upstream repositories:'
60
+ echo $MISSING_REPO
61
+ echo 'To fix, execute command: vagrant clone-upstream-repos'
62
+ fi
63
+ }
64
+
65
+ do_execute env[:machine], git_clone_commands
66
+
67
+ @app.call(env)
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,57 @@
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 CheckoutTests
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 checkout_tests')}"
31
+
32
+ sudo env[:machine], "mkdir -p /var/www/html/binaryartifacts"
33
+ sudo env[:machine], "restorecon /var/www/html/binaryartifacts"
34
+
35
+ remote_write(env[:machine], "/etc/httpd/conf.d/binaryartifacts.conf", "root:root", "0644") {
36
+ %{#
37
+ # This configuration is to host the binary artifacts for use during testing.
38
+ # Currently the apache only hosts on https and with a cert that is not signed
39
+ # so curl requires -k. To get around this in testing just host it over non-ssl
40
+ # and test test copies the tgz file to the /var/www/html/binaryartifacts folder.
41
+ #
42
+
43
+ Listen 81
44
+
45
+ <VirtualHost *:81>
46
+ ServerName localhost
47
+ ServerAdmin root@localhost
48
+ DocumentRoot /var/www/html/binaryartifacts
49
+ </VirtualHost>}}
50
+ sudo env[:machine], "restorecon -v /etc/httpd/conf.d/binaryartifacts.conf"
51
+ sudo env[:machine], "service httpd restart"
52
+ @app.call(env)
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,51 @@
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 Clean
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
+ git_clone_commands = ""
32
+ Constants.repos.each do |repo_name, url|
33
+ bare_repo_name = repo_name + "-bare"
34
+ wc_repo_name = repo_name + "-bare-working_copy"
35
+ 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
+
39
+ git_clone_commands += "rm -rf #{bare_repo_path}; \n"
40
+ end
41
+ do_execute env[:machine], git_clone_commands
42
+
43
+ sudo env[:machine], "rm -rf /etc/yum.repos.d/openshift-origin.repo"
44
+ sudo env[:machine], "rm -rf /var/cache/yum/x86_64/19/openshift-origin" #clear OpenShift package cache
45
+ sudo env[:machine], "rm -f /etc/openshift/.mongo-setup-complete"
46
+ @app.call(env)
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,52 @@
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 CleanNetworkSetup
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
+ if env[:machine].communicate.test("test -e /etc/udev/rules.d/70-persistent-net.rules")
33
+ remote_write(env[:machine], "/etc/udev/rules.d/70-persistent-net.rules") do
34
+ %{# This file was automatically generated by the /lib/udev/write_net_rules
35
+ # program, run by the persistent-net-generator.rules rules file.
36
+ #
37
+ # You can modify it, as long as you keep each rule on a single
38
+ # line, and change only the value of the NAME= key.
39
+
40
+ }
41
+ end
42
+ end
43
+ end
44
+
45
+ sudo env[:machine], "yum clean all"
46
+ sudo env[:machine], "rm -f /var/lib/mlocate/mlocate.db"
47
+ @app.call(env)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,65 @@
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 CloneUpstreamRepositories
21
+ include CommandHelper
22
+
23
+ def initialize(app, env, options={})
24
+ @app = app
25
+ @env = env
26
+ @options = options
27
+ end
28
+
29
+ def call(env)
30
+ remote_write(env[:machine], "/root/.ssh/config", "root:root", "0600") {
31
+ %{Host github.com
32
+ StrictHostKeyChecking no
33
+ UserKnownHostsFile=/dev/null
34
+ }}
35
+
36
+ git_clone_commands = ""
37
+ Constants.repos.each do |repo_name, url|
38
+ bare_repo_name = repo_name + "-bare"
39
+ bare_repo_path = Constants.build_dir + bare_repo_name
40
+
41
+ if @options[:clean]
42
+ git_clone_commands += "rm -fr #{bare_repo_path};\n"
43
+ end
44
+
45
+ git_clone_commands += %{
46
+ if [ ! -d #{bare_repo_path} ]; then
47
+ git clone --quiet --bare #{url} #{bare_repo_path} >/dev/null &
48
+ PIDS+=$!\" \"
49
+ fi
50
+ }
51
+ end
52
+
53
+ git_clone_commands += "[ -n \"$PIDS\" ] && wait $PIDS\n"
54
+
55
+ ssh_user = env[:machine].ssh_info[:username]
56
+ sudo(env[:machine], "mkdir -p #{Constants.build_dir}")
57
+ sudo(env[:machine], "mkdir -p #{Constants.build_dir + "builder"} && chown -R #{ssh_user}:#{ssh_user} #{Constants.build_dir}")
58
+ do_execute env[:machine], git_clone_commands
59
+
60
+ @app.call(env)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,54 @@
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 'xmlsimple'
17
+
18
+ module Vagrant
19
+ module Openshift
20
+ module Action
21
+ class CreateAMI
22
+ include CommandHelper
23
+
24
+ def initialize(app, env, options)
25
+ @app = app
26
+ @env = env
27
+ @options = options
28
+ end
29
+
30
+ def call(env)
31
+ raise VagrantPlugins::AWS::Errors::FogError, :message => "Error: EC2 Machine is not available" unless env[:machine].state.id == :running
32
+
33
+ begin
34
+ machine = env[:aws_compute].servers.get(env[:machine].id)
35
+ image_req = env[:aws_compute].create_image(machine.identity, machine.tags["Name"], machine.tags["Name"], false)
36
+ image = env[:aws_compute].images.get(image_req.body["imageId"])
37
+ env[:machine].ui.info "Creating AMI #{image.id}"
38
+ while not image.ready?
39
+ sleep 10
40
+ image = env[:aws_compute].images.get(image_req.body["imageId"])
41
+ end
42
+ env[:machine].ui.info("Done")
43
+ rescue Excon::Errors::BadRequest => e
44
+ doc = XMLSimple.xml_in(e.response.body)
45
+ code = doc['Response']['Errors']['Error']['Code'][0]
46
+ message = doc['Response']['Errors']['Error']['Message'][0]
47
+ raise VagrantPlugins::AWS::Errors::FogError, :message => "#{message}. Code: #{code}"
48
+ end
49
+ @app.call(env)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,53 @@
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 CreateBareRepoPlaceholders
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ @env = env
26
+ end
27
+
28
+ def call(env)
29
+ remote_write(env[:machine], "/root/.ssh/config", "root:root", "0600") {
30
+ %{Host github.com
31
+ StrictHostKeyChecking no
32
+ UserKnownHostsFile=/dev/null
33
+ }}
34
+
35
+ git_clone_commands = ""
36
+ Constants.repos.each do |repo_name, url|
37
+ bare_repo_name = repo_name + "-bare"
38
+ bare_repo_path = Constants.build_dir + bare_repo_name
39
+
40
+ git_clone_commands += "[ ! -d #{bare_repo_path} ] && git init --bare #{bare_repo_path};\n"
41
+ end
42
+
43
+ ssh_user = env[:machine].ssh_info[:username]
44
+ sudo(env[:machine], "mkdir -p #{Constants.build_dir}")
45
+ sudo(env[:machine], "mkdir -p #{Constants.build_dir + "builder"} && chown -R #{ssh_user}:#{ssh_user} #{Constants.build_dir}")
46
+ do_execute env[:machine], git_clone_commands
47
+
48
+ @app.call(env)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,84 @@
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 CreatePuppetFile
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ @env = env
26
+ end
27
+
28
+ def call(env)
29
+ hostname = env[:machine].config.vm.hostname
30
+ domain = env[:machine].config.openshift.cloud_domain
31
+ key,_ = sudo(env[:machine], "cat /var/named/K#{domain}.*.key")
32
+ key = key.first.strip.split(' ')
33
+ key = "#{key[6]}#{key[7]}"
34
+
35
+ links,_ = sudo(env[:machine], "ip link")
36
+ links = links.map!{ |l| l.split("\n") }.flatten
37
+
38
+ links.map! do |link|
39
+ m = link.match(/[0-9]+: ([a-z0-9]+):/)
40
+ m.nil?? "lo" : m[1]
41
+ end
42
+ links.delete "lo"
43
+
44
+ remote_write(env[:machine], "#{Constants.build_dir}/configure_origin.pp") {
45
+ config = "
46
+ class { 'openshift_origin' :
47
+ domain => '#{domain}',
48
+ broker_hostname => '#{hostname}',
49
+ node_hostname => '#{hostname}',
50
+ nameserver_hostname => '#{hostname}',
51
+ datastore_hostname => '#{hostname}',
52
+ msgserver_hostname => '#{hostname}',
53
+ openshift_user1 => 'admin',
54
+ openshift_password1 => 'admin',
55
+ bind_key => '#{key}',
56
+ override_install_repo => 'file://#{Constants.build_dir}/origin-rpms',
57
+ development_mode => true,
58
+ conf_node_external_eth_dev => '#{links.first}',
59
+ register_host_with_nameserver => true,
60
+ broker_auth_plugin => 'htpasswd',
61
+ conf_broker_auth_salt => 'salt salt salt',
62
+ conf_broker_multi_haproxy_per_node => true,
63
+ conf_valid_gear_sizes => ['small','medium'],
64
+ node_frontend_plugins => ['apache-mod-rewrite','nodejs-websocket','haproxy-sni-proxy'],
65
+ node_unmanaged_users => ['#{env[:machine].ssh_info[:username]}'],
66
+ node_container_plugin => '#{env[:machine].config.openshift.container}',"
67
+ env[:machine].config.openshift.advanced_puppet_values.each do |k,v|
68
+ config += %{ #{k} => '#{v}',\n}
69
+ end
70
+ config += "\n repos_base => '#{env[:machine].config.openshift.repos_base}'," unless env[:machine].config.openshift.repos_base.nil?
71
+ config += "\n os_repo => '#{env[:machine].config.openshift.os_repo}'," unless env[:machine].config.openshift.os_repo.nil?
72
+ config += "\n os_updates_repo => '#{env[:machine].config.openshift.os_updates_repo}'," unless env[:machine].config.openshift.os_updates_repo.nil?
73
+ config += "\n jenkins_repo_base => '#{env[:machine].config.openshift.jenkins_repo_base }'," unless env[:machine].config.openshift.jenkins_repo_base.nil?
74
+ config += "\n optional_repo => '#{env[:machine].config.openshift.optional_repo}'," unless env[:machine].config.openshift.optional_repo.nil?
75
+ config += "\n}\n"
76
+ config
77
+ }
78
+
79
+ @app.call(env)
80
+ end
81
+ end
82
+ end
83
+ end
84
+ 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 CreateTestUsers
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 create_test_users')}"
31
+ @app.call(env)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end