vagrant-openshift 1.0.20 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.asciidoc +30 -17
  4. data/lib/vagrant-openshift/action.rb +66 -41
  5. data/lib/vagrant-openshift/action/bootstrap_openshift.rb +34 -0
  6. data/lib/vagrant-openshift/action/{build_openshift3.rb → build_openshift.rb} +1 -1
  7. data/lib/vagrant-openshift/action/{build_openshift3_base_images.rb → build_openshift_base_images.rb} +1 -1
  8. data/lib/vagrant-openshift/action/clone_upstream_repositories.rb +3 -2
  9. data/lib/vagrant-openshift/action/create_ami.rb +19 -3
  10. data/lib/vagrant-openshift/action/create_sample_project.rb +39 -0
  11. data/lib/vagrant-openshift/action/create_yum_repositories.rb +1 -1
  12. data/lib/vagrant-openshift/action/{download_artifacts_openshift3.rb → download_artifacts_openshift.rb} +1 -1
  13. data/lib/vagrant-openshift/action/generate_template.rb +12 -5
  14. data/lib/vagrant-openshift/action/install_docker_registry.rb +47 -0
  15. data/lib/vagrant-openshift/action/{install_openshift3.rb → install_openshift.rb} +7 -5
  16. data/lib/vagrant-openshift/action/{install_openshift3_asset_dependencies.rb → install_openshift_asset_dependencies.rb} +1 -1
  17. data/lib/vagrant-openshift/action/{install_openshift3_base_dependencies.rb → install_openshift_base_dependencies.rb} +2 -2
  18. data/lib/vagrant-openshift/action/{install_openshift3_images.rb → install_openshift_images.rb} +1 -1
  19. data/lib/vagrant-openshift/action/{install_openshift3_rhel7.rb → install_openshift_rhel7.rb} +1 -1
  20. data/lib/vagrant-openshift/action/{install_openshift3_router.rb → install_openshift_router.rb} +3 -3
  21. data/lib/vagrant-openshift/action/{local_openshift3_checkout.rb → local_openshift_checkout.rb} +2 -2
  22. data/lib/vagrant-openshift/action/{push_openshift3_images.rb → push_openshift_images.rb} +3 -3
  23. data/lib/vagrant-openshift/action/{push_openshift3_release.rb → push_openshift_release.rb} +1 -1
  24. data/lib/vagrant-openshift/action/{run_openshift3_tests.rb → run_openshift_tests.rb} +1 -1
  25. data/lib/vagrant-openshift/action/run_systemctl.rb +2 -2
  26. data/lib/vagrant-openshift/action/setup_sample_policy.rb +42 -0
  27. data/lib/vagrant-openshift/action/sync_local_repository.rb +1 -5
  28. data/lib/vagrant-openshift/action/wait_for_openshift.rb +61 -0
  29. data/lib/vagrant-openshift/command/bootstrap_openshift.rb +50 -0
  30. data/lib/vagrant-openshift/command/{build_openshift3.rb → build_openshift.rb} +3 -4
  31. data/lib/vagrant-openshift/command/{build_openshift3_base.rb → build_openshift_base.rb} +3 -4
  32. data/lib/vagrant-openshift/command/{build_openshift3_base_images.rb → build_openshift_base_images.rb} +4 -5
  33. data/lib/vagrant-openshift/command/build_sti.rb +0 -1
  34. data/lib/vagrant-openshift/command/install_docker_registry.rb +50 -0
  35. data/lib/vagrant-openshift/command/{install_openshift3.rb → install_openshift.rb} +4 -5
  36. data/lib/vagrant-openshift/command/{install_openshift3_assets_base.rb → install_openshift_assets_base.rb} +4 -4
  37. data/lib/vagrant-openshift/command/{install_openshift3_router.rb → install_openshift_router.rb} +4 -5
  38. data/lib/vagrant-openshift/command/{local_openshift3_setup.rb → local_openshift_setup.rb} +3 -3
  39. data/lib/vagrant-openshift/command/openshift_init.rb +10 -5
  40. data/lib/vagrant-openshift/command/{push_openshift3_images.rb → push_openshift_images.rb} +4 -4
  41. data/lib/vagrant-openshift/command/{push_openshift3_release.rb → push_openshift_release.rb} +3 -3
  42. data/lib/vagrant-openshift/command/{repo_sync_openshift3.rb → repo_sync_openshift.rb} +3 -3
  43. data/lib/vagrant-openshift/command/{test_openshift3.rb → test_openshift.rb} +3 -3
  44. data/lib/vagrant-openshift/command/{test_openshift3_image.rb → test_openshift_image.rb} +2 -2
  45. data/lib/vagrant-openshift/command/{try_restart_openshift3.rb → try_restart_openshift.rb} +4 -5
  46. data/lib/vagrant-openshift/constants.rb +6 -5
  47. data/lib/vagrant-openshift/helper/command_helper.rb +3 -0
  48. data/lib/vagrant-openshift/plugin.rb +50 -40
  49. data/lib/vagrant-openshift/templates/command/init-openshift/box_info.yaml +42 -2
  50. data/lib/vagrant-openshift/version.rb +1 -1
  51. metadata +35 -28
@@ -0,0 +1,39 @@
1
+ #--
2
+ # Copyright 2015 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 CreateSampleProject
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ end
26
+
27
+ def call(env)
28
+ puts %q[Creating sample OpenShift project 'Turbo']
29
+
30
+ sudo(env[:machine], %q[
31
+ openshift admin new-project turbo --admin=admin --description='Turbo Sample' --display-name='Turbo Sample'
32
+ ])
33
+
34
+ @app.call(env)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -48,7 +48,7 @@ module Vagrant
48
48
  sudo(env[:machine], "yum -y install augeas")
49
49
  if is_centos
50
50
  sudo(env[:machine], "yum install -y centos-release-SCL.x86_64 http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm")
51
- set_yum_repo(env, "/etc/yum.repos.d/openshift-deps.repo", "openshift", "https://mirror.openshift.com/pub/openshift-v3/dependencies/centos7/x86_64/")
51
+ set_yum_repo(env, "/etc/yum.repos.d/openshift-deps.repo", "openshift-deps", "https://mirror.openshift.com/pub/openshift-v3/dependencies/centos7/x86_64/")
52
52
  end
53
53
 
54
54
  sudo(env[:machine], "yum clean all")
@@ -18,7 +18,7 @@ require 'pathname'
18
18
  module Vagrant
19
19
  module Openshift
20
20
  module Action
21
- class DownloadArtifactsOpenshift3
21
+ class DownloadArtifactsOpenshift
22
22
  include CommandHelper
23
23
 
24
24
  def initialize(app, env)
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2013 Red Hat, Inc.
2
+ # Copyright 2013-2015 Red Hat, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -66,10 +66,17 @@ module Vagrant
66
66
  'num_minions' => 2,
67
67
  'cpus' => 2,
68
68
  'memory' => 1024,
69
- 'rebuild_yum_cache' => false,
70
- 'sync_to' => '/data/src',
71
- 'sync_from' => "#{gopath}/src"
69
+ 'rebuild_yum_cache' => false
72
70
  }
71
+
72
+ vagrant_openshift_config['no_synced_folders'] = @options[:no_synced_folders]
73
+ if @options[:no_synced_folders]
74
+ vagrant_openshift_config[:no_synced_folders] = true
75
+ else
76
+ vagrant_openshift_config['sync_to'] = '/data/src'
77
+ vagrant_openshift_config['sync_from'] = "#{gopath}/src"
78
+ end
79
+
73
80
  vagrant_openshift_config['virtualbox'] = {
74
81
  'box_name' => box_info[:virtualbox][:box_name],
75
82
  'box_url' => box_info[:virtualbox][:box_url]
@@ -103,7 +110,7 @@ module Vagrant
103
110
  private
104
111
 
105
112
  def find_ami_from_tag(box_info)
106
- return if box_info[:aws][:ami_tag_prefix].nil?
113
+ return if box_info[:aws].nil? || box_info[:aws][:ami_tag_prefix].nil?
107
114
  @env[:ui].info("Reading AWS credentials from #{@aws_creds_file.to_s}")
108
115
  if @aws_creds_file.exist?
109
116
  aws_creds = @aws_creds_file.exist? ? Hash[*(File.open(@aws_creds_file.to_s).readlines.map{ |l| l.strip!
@@ -0,0 +1,47 @@
1
+ #--
2
+ # Copyright 2015 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 InstallDockerRegistry
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ @env = env
26
+ end
27
+
28
+ def call(env)
29
+ puts 'Installing docker registry'
30
+ sudo(env[:machine], %q[
31
+ #set -x
32
+ source /etc/profile.d/openshift.sh
33
+
34
+ CMD="openshift admin registry --create --credentials=${OPENSHIFTCONFIG}"
35
+ OS_RUNNING=$(systemctl status openshift | /bin/grep "(running)")
36
+ if [[ $OS_RUNNING ]]; then
37
+ ${CMD}
38
+ else
39
+ echo "The OpenShift process is not running. To install a docker registry please start OpenShift and run ${CMD}"
40
+ fi
41
+ ])
42
+ @app.call(env)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -17,7 +17,7 @@
17
17
  module Vagrant
18
18
  module Openshift
19
19
  module Action
20
- class InstallOpenshift3
20
+ class InstallOpenshift
21
21
  include CommandHelper
22
22
  def initialize(app, env)
23
23
  @app = app
@@ -41,7 +41,6 @@ ORIGIN_PATH=/data/src/github.com/openshift/origin
41
41
  cat > /etc/profile.d/openshift.sh <<DELIM
42
42
  export GOPATH=/data
43
43
  export PATH=$ORIGIN_PATH/_output/etcd/bin:$ORIGIN_PATH/_output/local/go/bin/:$GOPATH/bin:$PATH
44
- #export KUBERNETES_MASTER=http://localhost:8080
45
44
  export OPENSHIFTCONFIG=/openshift.local.config/master/admin.kubeconfig
46
45
  DELIM
47
46
 
@@ -55,6 +54,12 @@ pushd $ORIGIN_PATH
55
54
  hack/install-etcd.sh
56
55
  popd
57
56
 
57
+
58
+ mkdir -p /openshift.local.config/master/
59
+ touch /openshift.local.config/master/admin.kubeconfig
60
+ chmod a+r /openshift.local.config/master/admin.kubeconfig
61
+
62
+
58
63
  cat > /usr/bin/generate_openshift_service <<OUTERDELIM
59
64
 
60
65
  HOST=\\`facter ec2_public_hostname 2>/dev/null | xargs echo -n\\`
@@ -80,9 +85,6 @@ Documentation=https://github.com/openshift/origin
80
85
  Type=simple
81
86
  EnvironmentFile=-/etc/sysconfig/openshift
82
87
  ExecStart=$ORIGIN_PATH/_output/local/go/bin/openshift start --public-master=https://\\${HOST}:8443
83
- ExecStartPost=/usr/bin/timeout 60 bash -c 'while [ ! -f /openshift.local.config/master/admin.kubeconfig ] ; do sleep 1; done'
84
- ExecStartPost=/bin/sleep 1
85
- ExecStartPost=/bin/chmod a+r /openshift.local.config/master/admin*
86
88
 
87
89
  [Install]
88
90
  WantedBy=multi-user.target
@@ -17,7 +17,7 @@
17
17
  module Vagrant
18
18
  module Openshift
19
19
  module Action
20
- class InstallOpenshift3AssetDependencies
20
+ class InstallOpenshiftAssetDependencies
21
21
  include CommandHelper
22
22
 
23
23
  def initialize(app, env)
@@ -17,7 +17,7 @@
17
17
  module Vagrant
18
18
  module Openshift
19
19
  module Action
20
- class InstallOpenshift3BaseDependencies
20
+ class InstallOpenshiftBaseDependencies
21
21
  include CommandHelper
22
22
 
23
23
  def initialize(app, env)
@@ -47,7 +47,7 @@ setenforce 0
47
47
 
48
48
  systemctl enable ntpd
49
49
 
50
- groupadd docker
50
+ groupadd -f docker
51
51
  usermod -a -G docker #{ssh_user}
52
52
 
53
53
  sed -i "s,^OPTIONS='\\(.*\\)',OPTIONS='--insecure-registry=172.30.0.0/16 \\1'," /etc/sysconfig/docker
@@ -17,7 +17,7 @@
17
17
  module Vagrant
18
18
  module Openshift
19
19
  module Action
20
- class InstallOpenshift3Images
20
+ class InstallOpenshiftImages
21
21
  include CommandHelper
22
22
 
23
23
  def initialize(app, env)
@@ -17,7 +17,7 @@
17
17
  module Vagrant
18
18
  module Openshift
19
19
  module Action
20
- class InstallOpenshift3Rhel7
20
+ class InstallOpenshiftRhel7
21
21
  include CommandHelper
22
22
  def initialize(app, env)
23
23
  @app = app
@@ -17,7 +17,7 @@
17
17
  module Vagrant
18
18
  module Openshift
19
19
  module Action
20
- class InstallOpenshift3Router
20
+ class InstallOpenshiftRouter
21
21
  include CommandHelper
22
22
 
23
23
  def initialize(app, env)
@@ -28,12 +28,12 @@ module Vagrant
28
28
  def call(env)
29
29
  puts 'Installing router'
30
30
  sudo(env[:machine], '
31
- ROUTER_EXISTS=$(openshift ex router 2>&1 | grep "does not exist")
32
31
  OS_RUNNING=$(systemctl status openshift | grep "(running)")
33
32
  CMD="openshift ex router --create --credentials=${OPENSHIFTCONFIG}"
34
33
 
35
34
  if [[ $OS_RUNNING ]]; then
36
- if [[ -n $ROUTER_EXISTS ]]; then
35
+ ROUTER_EXISTS=$(openshift ex router --credentials=${OPENSHIFTCONFIG} 2>&1 | grep "service exists")
36
+ if [[ -z $ROUTER_EXISTS ]]; then
37
37
  echo "Installing OpenShift router"
38
38
  ${CMD}
39
39
  else
@@ -17,7 +17,7 @@
17
17
  module Vagrant
18
18
  module Openshift
19
19
  module Action
20
- class LocalOpenshift3Checkout
20
+ class LocalOpenshiftCheckout
21
21
  include CommandHelper
22
22
 
23
23
  def initialize(app, env, options)
@@ -38,7 +38,7 @@ module Vagrant
38
38
  end
39
39
  Dir.chdir(go_path) do
40
40
  commands = "echo 'Waiting for the cloning process to finish'\n"
41
- Constants.openshift3_repos.each do |repo, url|
41
+ Constants.openshift_repos.each do |repo, url|
42
42
  commands += %{
43
43
  ( #{repo_checkout_bash_command(repo, url)} ) &
44
44
  PIDS+=$!\" \";
@@ -17,7 +17,7 @@
17
17
  module Vagrant
18
18
  module Openshift
19
19
  module Action
20
- class PushOpenshift3Images
20
+ class PushOpenshiftImages
21
21
  include CommandHelper
22
22
 
23
23
  def initialize(app, env, options)
@@ -78,7 +78,7 @@ fi
78
78
  cmd = %{
79
79
  rm -rf ~/latest_images ; touch ~/latest_images
80
80
  }
81
- Vagrant::Openshift::Constants.openshift3_images.each do |name, git_url|
81
+ Vagrant::Openshift::Constants.openshift_images.each do |name, git_url|
82
82
  cmd += %{
83
83
  set +e
84
84
  git_ref=$(git ls-remote #{git_url} -h refs/heads/master | cut -c1-7)
@@ -116,7 +116,7 @@ docker pull #{@options[:registry]}openshift/base-rhel7
116
116
 
117
117
  build_images.each do |image|
118
118
  name, git_ref = image.split(':')
119
- repo_url = Vagrant::Openshift::Constants.openshift3_images[name]
119
+ repo_url = Vagrant::Openshift::Constants.openshift_images[name]
120
120
  if repo_url == nil
121
121
  puts "Unregistered image: #{name}, skipping"
122
122
  next
@@ -17,7 +17,7 @@
17
17
  module Vagrant
18
18
  module Openshift
19
19
  module Action
20
- class PushOpenshift3Release
20
+ class PushOpenshiftRelease
21
21
  include CommandHelper
22
22
 
23
23
  def initialize(app, env, options)
@@ -17,7 +17,7 @@
17
17
  module Vagrant
18
18
  module Openshift
19
19
  module Action
20
- class RunOpenshift3Tests
20
+ class RunOpenshiftTests
21
21
  include CommandHelper
22
22
 
23
23
  @@SSH_TIMEOUT = 4800
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2013 Red Hat, Inc.
2
+ # Copyright 2013-2015 Red Hat, Inc.
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ module Vagrant
28
28
 
29
29
  def call(env)
30
30
  unless @options[:action].nil? || @options[:service].nil?
31
- sudo(env[:machine], "systemctl #{@options[:action]} #{@options[:service]}")
31
+ sudo(env[:machine], "systemctl #{@options[:action]} #{@options[:service]} #{@options[:argv]}")
32
32
  @app.call(env)
33
33
  end
34
34
  end
@@ -0,0 +1,42 @@
1
+ #--
2
+ # Copyright 2015 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 SetupSamplePolicy
21
+ include CommandHelper
22
+
23
+ def initialize(app, env)
24
+ @app = app
25
+ end
26
+
27
+ def call(env)
28
+ puts 'Creating cluster-admin policy'
29
+
30
+ sudo(env[:machine], %q[
31
+ #set -x
32
+
33
+ source /etc/profile.d/openshift.sh
34
+ openshift admin policy add-role-to-group cluster-admin system:authenticated --config=${OPENSHIFTCONFIG} --namespace=master
35
+ ])
36
+
37
+ @app.call(env)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -28,7 +28,6 @@ module Vagrant
28
28
  def call(env)
29
29
  env[:machine].env.ui.info("Synchronizing local sources")
30
30
 
31
- pids = []
32
31
  Constants.repos(env).each do |repo_name, url|
33
32
  local_repo = Pathname.new(File.expand_path(File.join(env[:machine].env.root_path, "..", repo_name)))
34
33
  unless local_repo.exist?
@@ -39,11 +38,8 @@ module Vagrant
39
38
  end
40
39
  end
41
40
 
42
- pids << fork {
43
- Dir.chdir(local_repo) { sync_repo(env[:machine], repo_name) }
44
- }
41
+ Dir.chdir(local_repo) { sync_repo(env[:machine], repo_name) }
45
42
  end
46
- Process.waitall
47
43
 
48
44
  @app.call(env)
49
45
  end
@@ -0,0 +1,61 @@
1
+ #--
2
+ # Copyright 2015 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 'open-uri'
17
+ require 'openssl'
18
+ require 'uri'
19
+
20
+ module Vagrant
21
+ module Openshift
22
+ module Action
23
+ class WaitForOpenshift
24
+ include CommandHelper
25
+
26
+ def initialize(app, env)
27
+ @app = app
28
+ @env = env
29
+ end
30
+
31
+ def call(env)
32
+ puts 'Waiting on openshift...'
33
+
34
+ uri = URI.parse('https://localhost:8443/api')
35
+ status = nil
36
+ begin
37
+ until '200' == status
38
+ uri.open(ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE, read_timeout: 10) do |response|
39
+ status = response.status[0]
40
+ if '200' == status
41
+ puts "...#{response.status[1]}"
42
+ else
43
+ puts "...#{response.status[1]}:#{status}"
44
+ sleep 1
45
+ end
46
+ end
47
+ end
48
+ rescue OpenSSL::SSL::SSLError, Errno::ECONNRESET, OpenURI::HTTPError
49
+ sleep 1
50
+ retry
51
+ rescue => e
52
+ puts "#{e.class}: #{e.message}"
53
+ raise
54
+ end
55
+
56
+ @app.call(env)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end