shiplane_bootstrappers_chef 0.2.22 → 0.2.23
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f93e993b739e7c74ac9bbc3853e6f910341a70320c6e397e63b09185cad5762b
|
4
|
+
data.tar.gz: 4f90e102ac086f806acdae54c300a76f2bb4c2b347f18901efae37c2e3d6981f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4963c059bccb3e3ed41878d0ffb502c5baf45956e9d43c470d320bcf25d31ef59966e044a8fdb6272bbd92896cfacc07ea2143e4cfe168c5909e0e058d1f5d70
|
7
|
+
data.tar.gz: 031336bf31e336a54781ddbcdc22b768bad077a29d1b47c4a03c92f65b0d07432e5570a4823d6cf8c6ee5bedc593fb92bdb4073a338c9fb2d07c9589b5a94bda
|
data/cookbooks.tar.gz
CHANGED
Binary file
|
data/lib/capistrano/chef_host.rb
CHANGED
@@ -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
|
-
|
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"
|
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.
|
4
|
+
version: 0.2.23
|
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-
|
11
|
+
date: 2022-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|