shiplane_bootstrappers_chef 0.2.21 → 0.2.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1141b724e5e1035366d40305a2c19ae4bf836971c75195195d2922f5df908d6f
4
- data.tar.gz: 368c6d73b413c9be085b7687bc552c1f746b1eebbff31c8e707ad3b67859cbf9
3
+ metadata.gz: 64a10619231a30106a1fb99e4401ca70c98b0ce5940cd67957bd19e425219def
4
+ data.tar.gz: 28afbda734f8f54ca9f6ff49ea2929d8dd93e25c4ab0b5fb55cc21ce8ba16dc7
5
5
  SHA512:
6
- metadata.gz: 0fa9963a27c1d814fa51b7a04af707fccbd2486e18faacfb6f34207cb549cda2d44d16a71fe28c8aa0e7dadfae8284cb3c47b4eda6dc2d0b16b706d8ef9db429
7
- data.tar.gz: 2a66d29eb3bef5e82268b0b2a07692032e305cdc80f52b99cc0ab5d983a5c2b0ad48213498081c20a6196ccb3af420721720233b9ad650b4352a622659128124
6
+ metadata.gz: 8685478c9175669209488730f7d6576027b679eb751ef3a416ea6b9f74b6de91db8d232f6a6af4b381b8033ccb9f47b656258287b1b06d2dcedd86c91229edba
7
+ data.tar.gz: 574b5fe08ce4997fa33c5d3016fb6017cf0e91be83855db30d78436d06b1bf0517a7c1fd90fd359abda3668e2d09077d8c1c6926e1995977dec027f6c069aa48
data/cookbooks.tar.gz CHANGED
Binary file
@@ -7,7 +7,13 @@ module Shiplane
7
7
 
8
8
  REMOTE_CHEF_FOLDER_PATH = File.join("/var","chef")
9
9
  LOCAL_CHEF_FOLDER_PATH = File.expand_path("../../../lib/chef", __FILE__)
10
+ LOCAL_CUSTOM_CONFIGURATION_FOLDER_PATH = File.join(Dir.pwd, '.shiplane', 'bootstrap_config')
11
+ REMOTE_CUSTOM_CONFIGURATION_FOLDER_PATH = File.join(REMOTE_CHEF_FOLDER_PATH, 'cookbooks', 'barebones-docker', 'files', 'default')
10
12
  COOKBOOKS_FILE_NAME = "cookbooks.tar.gz"
13
+ LOCAL_COOKBOOKS_FOLDER_PATH = File.expand_path("../../../cookbooks", __FILE__)
14
+ LOCAL_SITE_COOKBOOKS_FOLDER_PATH = File.expand_path("../../../site-cookbooks", __FILE__)
15
+ LOCAL_SITE_BERKS_COOKBOOKS_FOLDER_PATH = File.expand_path("../../../berks-cookbooks", __FILE__)
16
+ REMOTE_COOKBOOKS_FOLDER_PATH = File.join(REMOTE_CHEF_FOLDER_PATH, 'cookbooks')
11
17
  LOCAL_COOKBOOKS_FILE_PATH = File.expand_path("../../../#{COOKBOOKS_FILE_NAME}", __FILE__)
12
18
  REMOTE_COOKBOOKS_FILE_PATH = File.join(REMOTE_CHEF_FOLDER_PATH, COOKBOOKS_FILE_NAME)
13
19
  CHEF_PACKAGE_NAME = config.fetch("bootstrap", {}).fetch("chef-bootstrapper", {}).fetch("package_name")
@@ -1,5 +1,7 @@
1
1
  require 'dotenv'
2
2
  require_relative '../chef_host'
3
+ require 'open3'
4
+ require 'pry'
3
5
 
4
6
  namespace :shiplane do
5
7
  namespace :bootstrap do
@@ -12,12 +14,18 @@ namespace :shiplane do
12
14
  end
13
15
  end
14
16
 
15
- task configure: %i(evaluate_erb_files rsync_chef_configuration upload_cookbooks fix_file_permissions) do
17
+ task configure: %i(evaluate_erb_files rsync_chef_configuration upload_cookbooks rsync_custom_configuration fix_file_permissions) do
16
18
  fetch(:shiplane_hosts).each do |host|
17
19
  host.configure
18
20
  end
19
21
  end
20
22
 
23
+ # task :prepare_files do |task, args|
24
+ # rm_r Shiplane::ChefHost::LOCAL_COOKBOOKS_FOLDER_PATH, force: true
25
+ # cp_r File.join(Shiplane::ChefHost::LOCAL_SITE_BERKS_COOKBOOKS_FOLDER_PATH, '.'), Shiplane::ChefHost::LOCAL_COOKBOOKS_FOLDER_PATH
26
+ # cp_r File.join(Shiplane::ChefHost::LOCAL_SITE_COOKBOOKS_FOLDER_PATH, '.'), Shiplane::ChefHost::LOCAL_COOKBOOKS_FOLDER_PATH
27
+ # end
28
+
21
29
  # task :cleanup do
22
30
  # end
23
31
 
@@ -38,6 +46,7 @@ namespace :shiplane do
38
46
  compiled_file_name = filename.match(/.*\/chef\/(.*)\.erb/)[1]
39
47
 
40
48
  sudo :mkdir, '-m', '777', '-p', File.join(Shiplane::ChefHost::REMOTE_CHEF_FOLDER_PATH, File.dirname(compiled_file_name))
49
+ execute :sudo, :rm, '-f', File.join(Shiplane::ChefHost::REMOTE_CHEF_FOLDER_PATH, compiled_file_name), interaction_handler: { "[sudo] password for #{host.netssh_options.fetch(:user)}: " => "#{host.netssh_options.fetch(:password, "")}\n" }
41
50
  upload! StringIO.new(compiled_template), File.join(Shiplane::ChefHost::REMOTE_CHEF_FOLDER_PATH, compiled_file_name)
42
51
  end
43
52
  end
@@ -53,7 +62,55 @@ namespace :shiplane do
53
62
  "#{host.netssh_options.fetch(:user)}@#{host}:#{Shiplane::ChefHost::REMOTE_CHEF_FOLDER_PATH}"
54
63
  ]
55
64
 
56
- execute 'rsync', *rsync_arguments
65
+ $stderr.puts rsync_arguments.join(" ")
66
+ execute :rsync, *rsync_arguments
67
+ # *outputs, status = Open3.capture3('rsync', *rsync_arguments)
68
+ end
69
+ end
70
+ end
71
+
72
+ # task :rsync_chef_cookbooks_configuration do |task, args|
73
+ # on fetch(:shiplane_hosts).map(&:capistrano_role) do |host|
74
+ # execute :sudo, :rm, '-Rf', Shiplane::ChefHost::REMOTE_COOKBOOKS_FOLDER_PATH, interaction_handler: { "[sudo] password for #{host.netssh_options.fetch(:user)}: " => "#{host.netssh_options.fetch(:password, "")}\n" }
75
+ # execute :sudo, :mkdir, '-m', '2777', '-p', Shiplane::ChefHost::REMOTE_COOKBOOKS_FOLDER_PATH, interaction_handler: { "[sudo] password for #{host.netssh_options.fetch(:user)}: " => "#{host.netssh_options.fetch(:password, "")}\n" }
76
+ # end
77
+
78
+ # run_locally do
79
+ # fetch(:shiplane_hosts).map(&:capistrano_role).each do |host|
80
+ # rsync_arguments = [
81
+ # '-r',
82
+ # '-e', "\"ssh -p #{host.port || 22} -i #{host.netssh_options.fetch(:keys)}\"",
83
+ # "#{Shiplane::ChefHost::LOCAL_COOKBOOKS_FOLDER_PATH}/",
84
+ # "#{host.netssh_options.fetch(:user)}@#{host}:#{Shiplane::ChefHost::REMOTE_COOKBOOKS_FOLDER_PATH}"
85
+ # ]
86
+
87
+ # $stderr.puts rsync_arguments.join(" ")
88
+ # # execute :rsync, *rsync_arguments
89
+ # *outputs, status = Open3.capture3('rsync', *rsync_arguments)
90
+ # end
91
+ # end
92
+ # end
93
+
94
+ task :rsync_custom_configuration, :role, :username, :keypath do |task, args|
95
+ on fetch(:shiplane_hosts).map(&:capistrano_role) do |host|
96
+ execute :sudo, :rm, '-Rf', Shiplane::ChefHost::REMOTE_CUSTOM_CONFIGURATION_FOLDER_PATH, interaction_handler: { "[sudo] password for #{host.netssh_options.fetch(:user)}: " => "#{host.netssh_options.fetch(:password, "")}\n" }
97
+ execute :sudo, :mkdir, '-m', '2777', '-p', Shiplane::ChefHost::REMOTE_CUSTOM_CONFIGURATION_FOLDER_PATH, interaction_handler: { "[sudo] password for #{host.netssh_options.fetch(:user)}: " => "#{host.netssh_options.fetch(:password, "")}\n" }
98
+ end
99
+
100
+ run_locally do
101
+ if Dir.exist?(Shiplane::ChefHost::LOCAL_CUSTOM_CONFIGURATION_FOLDER_PATH)
102
+ fetch(:shiplane_hosts).map(&:capistrano_role).each do |host|
103
+ rsync_arguments = [
104
+ '-r',
105
+ '-e', "ssh -p #{host.port || 22} -i #{host.netssh_options.fetch(:keys)}",
106
+ "#{Shiplane::ChefHost::LOCAL_CUSTOM_CONFIGURATION_FOLDER_PATH}/",
107
+ "#{host.netssh_options.fetch(:user)}@#{host}:#{Shiplane::ChefHost::REMOTE_CUSTOM_CONFIGURATION_FOLDER_PATH}"
108
+ ]
109
+
110
+ $stderr.puts rsync_arguments.join(" ")
111
+ # execute :rsync, *rsync_arguments
112
+ *outputs, status = Open3.capture3('rsync', *rsync_arguments)
113
+ end
57
114
  end
58
115
  end
59
116
  end
@@ -1,5 +1,6 @@
1
1
  require 'rake'
2
2
  require 'dotenv'
3
+ require 'open3'
3
4
 
4
5
  desc "Provision host"
5
6
  task :provision, [:role, :username, :keypath] => ['provision:default']
@@ -11,8 +12,9 @@ namespace :provision do
11
12
  :set_host_options,
12
13
  :prepare_host,
13
14
  :evaluate_erb_files,
14
- :rsync_chef,
15
15
  'upload-cookbooks',
16
+ :rsync_chef,
17
+ :rsync_custom_configuration,
16
18
  :fix_file_permissions,
17
19
  ] do |task, args|
18
20
  errors = {}
@@ -84,6 +86,19 @@ namespace :provision do
84
86
  end
85
87
  end
86
88
 
89
+ task :rsync_custom_configuration, :role, :username, :keypath do |task, args|
90
+ on roles(fetch(:host_options).role) do |host|
91
+ rsync_arguments = [
92
+ '-r',
93
+ '-e', "ssh -p #{host.port || 22} -i #{host.netssh_options.fetch(:keys)}",
94
+ "#{boostrap_config_path}/",
95
+ "#{host.netssh_options.fetch(:user)}@#{host}:/var/chef/cookbooks/barebones-docker/files"
96
+ ]
97
+ stdout, stderr, status = Open3.capture3("rsync" *rsync_arguments)
98
+ binding.pry
99
+ end
100
+ end
101
+
87
102
  desc "Uploads the tarballed cookbooks"
88
103
  task :'upload-cookbooks', :role, :username, :keypath do |task, args|
89
104
  on roles(args['role']) do |host|
@@ -144,6 +159,10 @@ def chef_folder_path
144
159
  File.expand_path("../../../chef", __FILE__)
145
160
  end
146
161
 
162
+ def boostrap_config_path
163
+ @boostrap_config_path ||= File.join(Dir.pwd, '.shiplane', 'bootstrap_config')
164
+ end
165
+
147
166
  def sudo(*args)
148
167
  execute :sudo, *args, interaction_handler: {
149
168
  "[sudo] password for #{fetch(:host_options).username}: " => "#{fetch(:host_options).password}\n"
@@ -3,7 +3,7 @@
3
3
  module Shiplane
4
4
  module Bootstrappers
5
5
  module Chef
6
- VERSION = "0.2.21"
6
+ VERSION = "0.2.24"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shiplane_bootstrappers_chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.21
4
+ version: 0.2.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Epperson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-30 00:00:00.000000000 Z
11
+ date: 2022-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano