selfbootstrap 0.1.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.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/LICENSE +3 -0
- data/README.md +12 -0
- data/bin/selfbootstrap +10 -0
- data/certs/public/jimbodragon.pem +26 -0
- data/lib/selfbootstrap/nochef/berks.rb +108 -0
- data/lib/selfbootstrap/nochef/chef.rb +63 -0
- data/lib/selfbootstrap/nochef/chefrepo.rb +237 -0
- data/lib/selfbootstrap/nochef/commandline.rb +114 -0
- data/lib/selfbootstrap/nochef/defaultvalues.rb +258 -0
- data/lib/selfbootstrap/nochef/defaultworkstationresource.rb +95 -0
- data/lib/selfbootstrap/nochef/git.rb +128 -0
- data/lib/selfbootstrap/nochef/kitchen.rb +84 -0
- data/lib/selfbootstrap/nochef/knife.rb +95 -0
- data/lib/selfbootstrap/nochef/platforms.rb +54 -0
- data/lib/selfbootstrap/nochef/provisioners.rb +68 -0
- data/lib/selfbootstrap/nochef/selfbootstrap.rb +467 -0
- data/lib/selfbootstrap/nochef/ssh.rb +72 -0
- data/lib/selfbootstrap/nochef/suites.rb +46 -0
- data/lib/selfbootstrap/nochef/update.rb +62 -0
- data/lib/selfbootstrap/nochef/users.rb +106 -0
- data/lib/selfbootstrap/nochef/verifiers.rb +59 -0
- data/lib/selfbootstrap/nochef/workstation.rb +250 -0
- data/lib/selfbootstrap/nochef/workstationresource.rb +140 -0
- data/lib/selfbootstrap/nochef.rb +52 -0
- data/lib/selfbootstrap/withchef/chef.rb +120 -0
- data/lib/selfbootstrap/withchef/chefrepo.rb +84 -0
- data/lib/selfbootstrap/withchef/commandline.rb +40 -0
- data/lib/selfbootstrap/withchef/defaultvalues.rb +39 -0
- data/lib/selfbootstrap/withchef/git.rb +86 -0
- data/lib/selfbootstrap/withchef/selfbootstrap.rb +41 -0
- data/lib/selfbootstrap/withchef/users.rb +161 -0
- data/lib/selfbootstrap/withchef/workstation.rb +77 -0
- data/lib/selfbootstrap/withchef/workstationresource.rb +60 -0
- data/lib/selfbootstrap/withchef.rb +55 -0
- data/lib/selfbootstrap/withlogger/defaultvalues.rb +33 -0
- data/lib/selfbootstrap/withlogger/selfbootstrap.rb +41 -0
- data/lib/selfbootstrap/withlogger/workstationresource.rb +59 -0
- data/lib/selfbootstrap/withlogger.rb +52 -0
- data/lib/selfbootstrap.rb +132 -0
- data.tar.gz.sig +0 -0
- metadata +117 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
#
|
2
|
+
# Chef Infra Documentation
|
3
|
+
# https://docs.chef.io/libraries/
|
4
|
+
#
|
5
|
+
|
6
|
+
#
|
7
|
+
# This module name was auto-generated from the cookbook name. This name is a
|
8
|
+
# single word that starts with a capital letter and then continues to use
|
9
|
+
# camel-casing throughout the remainder of the name.
|
10
|
+
#
|
11
|
+
module ChefWorkstationInitialize
|
12
|
+
module SelfBootstrap
|
13
|
+
module NoChef
|
14
|
+
module SuitesHelpers
|
15
|
+
#
|
16
|
+
# Define the methods that you would like to assist the work you do in recipes,
|
17
|
+
# resources, or templates.
|
18
|
+
#
|
19
|
+
# def my_helper_method
|
20
|
+
# # # help method implementation
|
21
|
+
# end
|
22
|
+
def default_suites
|
23
|
+
workstation_resource[:suites]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# The module you have defined may be extended within the recipe to grant the
|
32
|
+
# recipe the helper methods you define.
|
33
|
+
#
|
34
|
+
# Within your recipe you would write:
|
35
|
+
#
|
36
|
+
# extend ChefWorkstationInitialize::SuitesHelpers
|
37
|
+
#
|
38
|
+
# my_helper_method
|
39
|
+
#
|
40
|
+
# You may also add this to a single resource within a recipe:
|
41
|
+
#
|
42
|
+
# template '/etc/app.conf' do
|
43
|
+
# extend ChefWorkstationInitialize::SuitesHelpers
|
44
|
+
# variables specific_key: my_helper_method
|
45
|
+
# end
|
46
|
+
#
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# name 'Helper file for chef_workstation_initialize'
|
2
|
+
# maintainer 'Jimbo Dragon'
|
3
|
+
# maintainer_email 'jimbo_dragon@hotmail.com'
|
4
|
+
# license 'MIT'
|
5
|
+
# description 'Helper file for chef_workstation_initialize'
|
6
|
+
# version '0.1.0'
|
7
|
+
# chef_version '>= 16.6.14'
|
8
|
+
# issues_url 'https://github.com/jimbodragon/chef_workstation_initialize/issues'
|
9
|
+
# source_url 'https://github.com/jimbodragon/chef_workstation_initialize'
|
10
|
+
#
|
11
|
+
# Chef Infra Documentation
|
12
|
+
# https://docs.chef.io/libraries/
|
13
|
+
#
|
14
|
+
|
15
|
+
#
|
16
|
+
# This module name was auto-generated from the cookbook name. This name is a
|
17
|
+
# single word that starts with a capital letter and then continues to use
|
18
|
+
# camel-casing throughout the remainder of the name.
|
19
|
+
#
|
20
|
+
|
21
|
+
require_relative 'knife'
|
22
|
+
|
23
|
+
module ChefWorkstationInitialize
|
24
|
+
module SelfBootstrap
|
25
|
+
module NoChef
|
26
|
+
module UpdateHelpers
|
27
|
+
include ChefWorkstationInitialize::SelfBootstrap::NoChef::KnifeHelpers
|
28
|
+
|
29
|
+
def commit_state
|
30
|
+
worklog('Running method commit_state(auto_chef_repo)' + " for class #{self.class} inside file #{__FILE__}")
|
31
|
+
|
32
|
+
repository_list.each do |submodule|
|
33
|
+
%w(commit push).each do |action|
|
34
|
+
get_git_submodule(submodule, gitinfo['submodules'][submodule], action.to_sym, workstation_resource[:compile_time])
|
35
|
+
end unless parent_nil?(gitinfo, 'submodules', submodule)
|
36
|
+
end
|
37
|
+
get_self_git :commit, workstation_resource[:compile_time]
|
38
|
+
get_self_git :push, workstation_resource[:compile_time]
|
39
|
+
Chef::Log.warn('TODO manage branch and merge for the workflow')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
#
|
47
|
+
# The module you have defined may be extended within the recipe to grant the
|
48
|
+
# recipe the helper methods you define.
|
49
|
+
#
|
50
|
+
# Within your recipe you would write:
|
51
|
+
#
|
52
|
+
# extend ChefWorkstationInitialize::UpdateHelpers
|
53
|
+
#
|
54
|
+
# my_helper_method
|
55
|
+
#
|
56
|
+
# You may also add this to a single resource within a recipe:
|
57
|
+
#
|
58
|
+
# template '/etc/app.conf' do
|
59
|
+
# extend ChefWorkstationInitialize::UpdateHelpers
|
60
|
+
# variables specific_key: my_helper_method
|
61
|
+
# end
|
62
|
+
#
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# name 'Helper file for chef_workstation_initialize'
|
2
|
+
# maintainer 'Jimbo Dragon'
|
3
|
+
# maintainer_email 'jimbo_dragon@hotmail.com'
|
4
|
+
# license 'MIT'
|
5
|
+
# description 'Helper file for chef_workstation_initialize'
|
6
|
+
# version '0.1.0'
|
7
|
+
# chef_version '>= 16.6.14'
|
8
|
+
# issues_url 'https://github.com/jimbodragon/chef_workstation_initialize/issues'
|
9
|
+
# source_url 'https://github.com/jimbodragon/chef_workstation_initialize'
|
10
|
+
#
|
11
|
+
# Chef Infra Documentation
|
12
|
+
# https://docs.chef.io/libraries/
|
13
|
+
#
|
14
|
+
|
15
|
+
#
|
16
|
+
# This module name was auto-generated from the cookbook name. This name is a
|
17
|
+
# single word that starts with a capital letter and then continues to use
|
18
|
+
# camel-casing throughout the remainder of the name.
|
19
|
+
#
|
20
|
+
|
21
|
+
require_relative 'update'
|
22
|
+
|
23
|
+
module ChefWorkstationInitialize
|
24
|
+
module SelfBootstrap
|
25
|
+
module NoChef
|
26
|
+
module UsersHelpers
|
27
|
+
include ChefWorkstationInitialize::SelfBootstrap::NoChef::UpdateHelpers
|
28
|
+
|
29
|
+
def create_user(user, user_data)
|
30
|
+
require_implement_method('create_user', %w(user user_data))
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_group(groupname, groupcomment, users)
|
34
|
+
require_implement_method('create_group', %w(groupname groupcomment users))
|
35
|
+
end
|
36
|
+
|
37
|
+
def generate_user_data(user, home = '')
|
38
|
+
require_implement_method('generate_user_data', %w(user home))
|
39
|
+
end
|
40
|
+
|
41
|
+
def generate_secret
|
42
|
+
require_implement_method('generate_secret', [])
|
43
|
+
end
|
44
|
+
|
45
|
+
def set_cookbook_user_secret_key
|
46
|
+
require_implement_method('set_cookbook_user_secret_key', [])
|
47
|
+
end
|
48
|
+
|
49
|
+
def userdatabag
|
50
|
+
'users'
|
51
|
+
end
|
52
|
+
|
53
|
+
def secretdatabag
|
54
|
+
workstation_resource[:cookbook_source]
|
55
|
+
end
|
56
|
+
|
57
|
+
def secretdatabagitem
|
58
|
+
'cookbook_secret_keys'
|
59
|
+
end
|
60
|
+
|
61
|
+
def secretdatabagkey
|
62
|
+
'secret'
|
63
|
+
end
|
64
|
+
|
65
|
+
def user_fully_created?(user, user_data)
|
66
|
+
file_exist?(user_data[:home]) && file_exist?(sshdir) && file_exist?(privkey)
|
67
|
+
end
|
68
|
+
|
69
|
+
def generate_ssh_user_key(user, user_data)
|
70
|
+
unless user_fully_created?(user, user_data)
|
71
|
+
worklog("Generate SSH user key for {#{user}: #{user_data}}")
|
72
|
+
sshdir = ::File.join(user_data[:home], '.ssh')
|
73
|
+
privkey = ::File.join(sshdir, 'id_rsa')
|
74
|
+
create_user(user, user_data)
|
75
|
+
groupcomment = 'group for all new_resource user'
|
76
|
+
['docker', workstation_resource[:group]].each do |groupname|
|
77
|
+
create_group(groupname, groupcomment)
|
78
|
+
end
|
79
|
+
|
80
|
+
ssh_keygen("-m 'RFC4716' -N '' -P '' -f #{privkey}", { user: user, cwd: user_data[:home] })
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
#
|
89
|
+
# The module you have defined may be extended within the recipe to grant the
|
90
|
+
# recipe the helper methods you define.
|
91
|
+
#
|
92
|
+
# Within your recipe you would write:
|
93
|
+
#
|
94
|
+
# extend ChefWorkstationInitialize::ChefHelpers
|
95
|
+
#
|
96
|
+
# my_helper_method
|
97
|
+
#
|
98
|
+
# You may also add this to a single resource within a recipe:
|
99
|
+
#
|
100
|
+
# template '/etc/app.conf' do
|
101
|
+
# extend ChefWorkstationInitialize::ChefHelpers
|
102
|
+
# variables specific_key: my_helper_method
|
103
|
+
# end
|
104
|
+
#
|
105
|
+
|
106
|
+
# require_relative "../providers/git_resource"
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#
|
2
|
+
# Chef Infra Documentation
|
3
|
+
# https://docs.chef.io/libraries/
|
4
|
+
#
|
5
|
+
|
6
|
+
#
|
7
|
+
# This module name was auto-generated from the cookbook name. This name is a
|
8
|
+
# single word that starts with a capital letter and then continues to use
|
9
|
+
# camel-casing throughout the remainder of the name.
|
10
|
+
#
|
11
|
+
module ChefWorkstationInitialize
|
12
|
+
module SelfBootstrap
|
13
|
+
module NoChef
|
14
|
+
module VerifiersHelpers
|
15
|
+
#
|
16
|
+
# Define the methods that you would like to assist the work you do in recipes,
|
17
|
+
# resources, or templates.
|
18
|
+
#
|
19
|
+
# def my_helper_method
|
20
|
+
# worklog('Running method my_helper_method' + " for class #{self.class} inside file #{__FILE__}")
|
21
|
+
|
22
|
+
# # help method implementation
|
23
|
+
# end
|
24
|
+
|
25
|
+
def verifiers
|
26
|
+
worklog('Running method verifiers' + " for class #{self.class} inside file #{__FILE__}")
|
27
|
+
|
28
|
+
[inspec_verifier]
|
29
|
+
end
|
30
|
+
|
31
|
+
def inspec_verifier
|
32
|
+
worklog('Running method inspec_verifier' + " for class #{self.class} inside file #{__FILE__}")
|
33
|
+
|
34
|
+
{
|
35
|
+
name: 'inspec',
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# The module you have defined may be extended within the recipe to grant the
|
45
|
+
# recipe the helper methods you define.
|
46
|
+
#
|
47
|
+
# Within your recipe you would write:
|
48
|
+
#
|
49
|
+
# extend ChefWorkstationInitialize::VerifiersHelpers
|
50
|
+
#
|
51
|
+
# my_helper_method
|
52
|
+
#
|
53
|
+
# You may also add this to a single resource within a recipe:
|
54
|
+
#
|
55
|
+
# template '/etc/app.conf' do
|
56
|
+
# extend ChefWorkstationInitialize::VerifiersHelpers
|
57
|
+
# variables specific_key: my_helper_method
|
58
|
+
# end
|
59
|
+
#
|
@@ -0,0 +1,250 @@
|
|
1
|
+
#
|
2
|
+
# Chef Infra Documentation
|
3
|
+
# https://docs.chef.io/libraries/
|
4
|
+
#
|
5
|
+
|
6
|
+
#
|
7
|
+
# This module name was auto-generated from the cookbook name. This name is a
|
8
|
+
# single word that starts with a capital letter and then continues to use
|
9
|
+
# camel-casing throughout the remainder of the name.
|
10
|
+
#
|
11
|
+
|
12
|
+
require_relative 'users'
|
13
|
+
|
14
|
+
module ChefWorkstationInitialize
|
15
|
+
module SelfBootstrap
|
16
|
+
module NoChef
|
17
|
+
module WorkstationHelpers
|
18
|
+
include ChefWorkstationInitialize::SelfBootstrap::NoChef::UsersHelpers
|
19
|
+
|
20
|
+
attr_reader :workstationobj
|
21
|
+
|
22
|
+
def auto_repo(auto_repo_action = nil, auto_repo_compile_time = false)
|
23
|
+
require_implement_method('auto_repo', %w(auto_repo_action auto_repo_compile_time))
|
24
|
+
end
|
25
|
+
|
26
|
+
def node_infra_chef
|
27
|
+
require_implement_method('node_infra_chef', [])
|
28
|
+
end
|
29
|
+
|
30
|
+
def project_name
|
31
|
+
workstation_resource[:project_name]
|
32
|
+
end
|
33
|
+
|
34
|
+
def workstation_chef_repo_path
|
35
|
+
if ::File.basename(default_install_dir) == project_name
|
36
|
+
default_install_dir
|
37
|
+
else
|
38
|
+
::File.join(get_path(install_dir), project_name)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def workstation_cookbooks_dir
|
43
|
+
::File.join(get_path(workstation_chef_repo_path), 'cookbooks')
|
44
|
+
end
|
45
|
+
|
46
|
+
def workstation_config_dir
|
47
|
+
::File.join(get_path(workstation_chef_repo_path), '.chef')
|
48
|
+
end
|
49
|
+
|
50
|
+
def workstation_cache_path
|
51
|
+
::File.join(get_path(workstation_config_dir), 'local-mode-cache')
|
52
|
+
end
|
53
|
+
|
54
|
+
def workstation_cache_options_syntaxe_path
|
55
|
+
::File.join(get_path(workstation_config_dir), 'syntaxcache')
|
56
|
+
end
|
57
|
+
|
58
|
+
def workstation_checksum_path
|
59
|
+
::File.join(get_path(workstation_cache_path), 'checksums')
|
60
|
+
end
|
61
|
+
|
62
|
+
def workstation_acl_path
|
63
|
+
::File.join(get_path(workstation_chef_repo_path), 'acls')
|
64
|
+
end
|
65
|
+
|
66
|
+
def workstation_client_d_dir
|
67
|
+
::File.join(get_path(workstation_config_dir), 'client.d')
|
68
|
+
end
|
69
|
+
|
70
|
+
def workstation_client_key_path
|
71
|
+
::File.join(get_path(workstation_chef_repo_path), 'client_keys')
|
72
|
+
end
|
73
|
+
|
74
|
+
def workstation_client_path
|
75
|
+
::File.join(get_path(workstation_chef_repo_path), 'clients')
|
76
|
+
end
|
77
|
+
|
78
|
+
def workstation_config_d_dir
|
79
|
+
::File.join(get_path(workstation_config_dir), 'config.d')
|
80
|
+
end
|
81
|
+
|
82
|
+
def workstation_container_path
|
83
|
+
::File.join(get_path(workstation_chef_repo_path), 'containers')
|
84
|
+
end
|
85
|
+
|
86
|
+
def workstation_cookbook_artifact_path
|
87
|
+
::File.join(get_path(workstation_chef_repo_path), 'cookbook_artifacts')
|
88
|
+
end
|
89
|
+
|
90
|
+
def workstation_file_backup_path
|
91
|
+
::File.join(get_path(workstation_cache_path), 'backup')
|
92
|
+
end
|
93
|
+
|
94
|
+
def workstation_group_path
|
95
|
+
::File.join(get_path(workstation_chef_repo_path), 'groups')
|
96
|
+
end
|
97
|
+
|
98
|
+
def workstation_ohai_segment_plugin_path
|
99
|
+
::File.join(::File.join(get_path(workstation_config_dir), 'ohai'), 'cookbook_plugins')
|
100
|
+
end
|
101
|
+
|
102
|
+
def workstation_solo_d_dir
|
103
|
+
::File.join(get_path(workstation_config_dir), 'solo.d')
|
104
|
+
end
|
105
|
+
|
106
|
+
def workstation_user_path
|
107
|
+
::File.join(get_path(workstation_chef_repo_path), 'users')
|
108
|
+
end
|
109
|
+
|
110
|
+
def workstation_syntax_check_cache_path
|
111
|
+
::File.join(get_path(workstation_config_dir), 'syntaxcache')
|
112
|
+
end
|
113
|
+
|
114
|
+
def workstation_trusted_certs_dir
|
115
|
+
::File.join(get_path(workstation_config_dir), 'trusted_certs')
|
116
|
+
end
|
117
|
+
|
118
|
+
def workstation_file_cache_path
|
119
|
+
::File.join(get_path(workstation_cache_path), 'cache')
|
120
|
+
end
|
121
|
+
|
122
|
+
def workstation_logs_dir
|
123
|
+
::File.join(get_path(workstation_chef_repo_path), 'logs')
|
124
|
+
end
|
125
|
+
|
126
|
+
def workstation_libraries_dir
|
127
|
+
::File.join(get_path(workstation_chef_repo_path), 'libraries')
|
128
|
+
end
|
129
|
+
|
130
|
+
def workstation_file
|
131
|
+
::File.join(get_path(workstation_libraries_dir), 'selfbootstrap.rb')
|
132
|
+
end
|
133
|
+
|
134
|
+
def workstation_resources_dir
|
135
|
+
::File.join(get_path(workstation_chef_repo_path), 'resources')
|
136
|
+
end
|
137
|
+
|
138
|
+
def workstation_generators_dir
|
139
|
+
::File.join(get_path(workstation_chef_repo_path), 'generators')
|
140
|
+
end
|
141
|
+
|
142
|
+
def workstation_berks_vendor_dir
|
143
|
+
::File.join(get_path(workstation_chef_repo_path), 'berks-cookbooks')
|
144
|
+
end
|
145
|
+
|
146
|
+
def workstation_roles_dir
|
147
|
+
::File.join(get_path(workstation_chef_repo_path), 'roles')
|
148
|
+
end
|
149
|
+
|
150
|
+
def workstation_nodes_dir
|
151
|
+
::File.join(get_path(workstation_chef_repo_path), 'nodes')
|
152
|
+
end
|
153
|
+
|
154
|
+
def workstation_chef_environments_dir
|
155
|
+
::File.join(get_path(workstation_chef_repo_path), 'environments')
|
156
|
+
end
|
157
|
+
|
158
|
+
def workstation_scripts_dir
|
159
|
+
::File.join(get_path(workstation_chef_repo_path), 'scripts')
|
160
|
+
end
|
161
|
+
|
162
|
+
def workstation_data_bags_dir
|
163
|
+
::File.join(get_path(workstation_chef_repo_path), 'data_bags')
|
164
|
+
end
|
165
|
+
|
166
|
+
def workstation_cache_dir
|
167
|
+
::File.join(get_path(workstation_chef_repo_path), 'cache')
|
168
|
+
end
|
169
|
+
|
170
|
+
def workstation_download_dir
|
171
|
+
::File.join(get_path(workstation_chef_repo_path), 'download')
|
172
|
+
end
|
173
|
+
|
174
|
+
def workstation_policy_dir
|
175
|
+
::File.join(get_path(workstation_chef_repo_path), 'policies')
|
176
|
+
end
|
177
|
+
|
178
|
+
def workstation_policy_group_dir
|
179
|
+
::File.join(get_path(workstation_chef_repo_path), 'policy_group')
|
180
|
+
end
|
181
|
+
|
182
|
+
def workstation_policy_files_dir
|
183
|
+
::File.join(get_path(workstation_chef_repo_path), 'policyfiles')
|
184
|
+
end
|
185
|
+
|
186
|
+
def bootstrapping_progress_file
|
187
|
+
::File.join(get_path(workstation_chef_repo_path), 'bootstrapping_in_progress')
|
188
|
+
end
|
189
|
+
|
190
|
+
def main_generator_name
|
191
|
+
"#{project_name}_generator"
|
192
|
+
end
|
193
|
+
|
194
|
+
def create_main_generator
|
195
|
+
create_generator(main_generator_name)
|
196
|
+
end
|
197
|
+
|
198
|
+
def new_cookbook_name
|
199
|
+
worklog("Get cookbook_name between #{cookbook_name} and #{project_name}_#{cookbook_name}")
|
200
|
+
cookbook_name.include?(project_name) ? cookbook_name : "#{project_name}_#{cookbook_name}"
|
201
|
+
end
|
202
|
+
|
203
|
+
def change_unix_permission
|
204
|
+
[
|
205
|
+
"chown -R #{workstation_resource[:user]}:#{workstation_resource[:group]} #{get_path(workstation_chef_repo_path)}",
|
206
|
+
"find #{get_path(workstation_chef_repo_path)} -type d -exec chown -R #{workstation_resource[:user]}:#{workstation_resource[:group]} {} \\;",
|
207
|
+
"find #{get_path(workstation_chef_repo_path)} -type d -exec chmod 775 {} \\;",
|
208
|
+
"find #{get_path(workstation_chef_repo_path)} -type f -exec chown -R #{workstation_resource[:user]}:#{workstation_resource[:group]} {} \\;",
|
209
|
+
"find #{get_path(workstation_chef_repo_path)} -type f -exec chmod g+w {} \\;",
|
210
|
+
].each do |permission_command|
|
211
|
+
base_command(permission_command, [], { live: true, sudo: true })
|
212
|
+
worklog("Change unix permission :: #{permission_command}")
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def prepare_new_resource
|
217
|
+
node_infra_chef
|
218
|
+
set_cookbook_user_secret_key
|
219
|
+
generate_directory(workstation_chef_repo_path)
|
220
|
+
# include_recipe "#{new_cookbook_name}::#{workstation_resource[:environment]}" if new_cookbook_name.include?(project_name)
|
221
|
+
# include_recipe "#{new_cookbook_name}::#{project_name}" unless includes_recipe? new_cookbook_name.include?(project_name)
|
222
|
+
# generate_machine('chefserver')
|
223
|
+
debug_worklog("workstation_resource[:infra] = #{workstation_resource[:infra]}")
|
224
|
+
# unless workstation_resource[:infra].nil?
|
225
|
+
# worklog("Running workstation_resource[:infra]")
|
226
|
+
# workstation_resource[:infra]
|
227
|
+
# end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
#
|
235
|
+
# The module you have defined may be extended within the recipe to grant the
|
236
|
+
# recipe the helper methods you define.
|
237
|
+
#
|
238
|
+
# Within your recipe you would write:
|
239
|
+
#
|
240
|
+
# extend ChefWorkstationInitialize::WorkstationHelpers
|
241
|
+
#
|
242
|
+
# my_helper_method
|
243
|
+
#
|
244
|
+
# You may also add this to a single resource within a recipe:
|
245
|
+
#
|
246
|
+
# template '/etc/app.conf' do
|
247
|
+
# extend ChefWorkstationInitialize::WorkstationHelpers
|
248
|
+
# variables specific_key: my_helper_method
|
249
|
+
# end
|
250
|
+
#
|
@@ -0,0 +1,140 @@
|
|
1
|
+
#
|
2
|
+
# Chef Infra Documentation
|
3
|
+
# https://docs.chef.io/libraries/
|
4
|
+
#
|
5
|
+
|
6
|
+
#
|
7
|
+
# This module name was auto-generated from the cookbook name. This name is a
|
8
|
+
# single word that starts with a capital letter and then continues to use
|
9
|
+
# camel-casing throughout the remainder of the name.
|
10
|
+
#
|
11
|
+
|
12
|
+
require_relative 'workstation'
|
13
|
+
require_relative 'defaultworkstationresource'
|
14
|
+
|
15
|
+
module ChefWorkstationInitialize
|
16
|
+
module SelfBootstrap
|
17
|
+
module NoChef
|
18
|
+
module WorkstationResourceHelpers
|
19
|
+
include ChefWorkstationInitialize::SelfBootstrap::NoChef::WorkstationHelpers
|
20
|
+
|
21
|
+
def default_workstation_resource
|
22
|
+
@default_workstation_resource ||= DefaultWorkstationResource.new
|
23
|
+
end
|
24
|
+
|
25
|
+
def set_workstation_resource(new_resource_set)
|
26
|
+
workstation_resource_keys.each do |key|
|
27
|
+
workstation_resource[key.to_sym] = {}.symbolify_keys(workstation_resource[key.to_sym].respond_to?(:deep_merge) ? workstation_resource[key.to_sym].deep_merge(new_resource_set[key.to_s]) : new_resource_set[key.to_s]) unless parent_nil?(new_resource_set, key.to_s)
|
28
|
+
end
|
29
|
+
# if new_resource_set.respond_to?(:node) && new_resource_set.node[workstation_resource[:cookbook_source]].nil? == false
|
30
|
+
# workstation_resource_keys.each do |key|
|
31
|
+
# workstation_resource[key.to_sym] = node['infra_chef'][key.to_s]
|
32
|
+
# end
|
33
|
+
# end
|
34
|
+
workstation_resource
|
35
|
+
end
|
36
|
+
|
37
|
+
def swap_workstation(new_workstation)
|
38
|
+
@workstation = new_workstation.get_workstation
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_workstation
|
42
|
+
# ::File.join(get_path(workstation_chef_repo_path), __FILE__.gsub(/^.*cache/), '')
|
43
|
+
# @workstation_tool = new_workstation
|
44
|
+
# include new_workstation
|
45
|
+
@workstation = default_workstation_resource if @workstation.nil?
|
46
|
+
swap_workstation(ChefWorkstationInitialize::SelfBootstrap::WithChef) if respond_to? 'Chef'
|
47
|
+
@workstation
|
48
|
+
end
|
49
|
+
|
50
|
+
def workstation_resource
|
51
|
+
get_workstation
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_workstation_property(property_name)
|
55
|
+
require_implement_method('get_workstation_property', %w(property_name))
|
56
|
+
|
57
|
+
# debug_worklog("Get property #{property_name}") # if property_name == 'group'
|
58
|
+
# property = nil
|
59
|
+
# viarail = nil
|
60
|
+
# if respond_to?('workstation_' + property_name)
|
61
|
+
# viarail = 'self workstaion'
|
62
|
+
# property = send('workstation_' + property_name)
|
63
|
+
# elsif property_name != 'project_name' && respond_to?(property_name + '=')
|
64
|
+
# viarail = 'self'
|
65
|
+
# property = send(property_name)
|
66
|
+
# workstation_resource_property = workstation_resource[property_name.to_sym]
|
67
|
+
# if (property.nil? && !workstation_resource_property.nil?) || (!property.nil? && !workstation_resource_property.nil?)
|
68
|
+
# viarail += ' Using workstation_resource_property'
|
69
|
+
# property = set_workstation_property(property_name, workstation_resource_property) if property != workstation_resource_property
|
70
|
+
# elsif !property.nil? && workstation_resource_property.nil?
|
71
|
+
# viarail += ' Using property'
|
72
|
+
# property = set_workstation_property(property_name, property)
|
73
|
+
# elsif property.nil? && workstation_resource_property.nil?
|
74
|
+
# viarail += ' No property present'
|
75
|
+
# worklog("Property #{property_name} is not present")
|
76
|
+
# end
|
77
|
+
# elsif !respond_to?('new_resource') || new_resource.nil?
|
78
|
+
# viarail = 'workstation_resource'
|
79
|
+
# property = workstation_resource[property_name.to_sym]
|
80
|
+
# elsif new_resource.respond_to?(property_name)
|
81
|
+
# viarail = 'new_resource'
|
82
|
+
# property = new_resource.send(property_name)
|
83
|
+
# elsif new_resource.is_a?(Hash)
|
84
|
+
# viarail = 'new_resource(Hash)'
|
85
|
+
# property = new_resource[property_name.to_sym]
|
86
|
+
# else
|
87
|
+
# viarail = 'UNKNOWN'
|
88
|
+
# worklog("new_resource doesn't respond to #{property_name} :: #{new_resource.class} :: #{new_resource.methods}")
|
89
|
+
# property = nil
|
90
|
+
# end
|
91
|
+
# debug_worklog("property #{property_name} is #{property.is_a?(::Dir) ? get_path(property) : property} via #{viarail}") # if property_name == 'group'
|
92
|
+
# property
|
93
|
+
end
|
94
|
+
|
95
|
+
def set_workstation_property(property_name, value)
|
96
|
+
require_implement_method('set_workstation_property', %w(property_name value))
|
97
|
+
|
98
|
+
# debug_worklog("Assign property #{property_name} is value #{value.is_a?(::Dir) ? get_path(value) : value}")
|
99
|
+
# assign = false
|
100
|
+
# if property_name != 'project_name' && respond_to?(property_name + '=')
|
101
|
+
# assign = true
|
102
|
+
# send(property_name + '=', value)
|
103
|
+
# end
|
104
|
+
# if !respond_to?('new_resource') || new_resource.nil?
|
105
|
+
# assign = true
|
106
|
+
# workstation_resource[property_name.to_sym] = value
|
107
|
+
# end
|
108
|
+
# if respond_to?('new_resource') && new_resource.respond_to?(property_name)
|
109
|
+
# assign = true
|
110
|
+
# new_resource.send(property_name, value)
|
111
|
+
# end
|
112
|
+
# if respond_to?('new_resource') && new_resource.is_a?(Hash)
|
113
|
+
# assign = true
|
114
|
+
# new_resource[property_name] = value
|
115
|
+
# end
|
116
|
+
# worklog("new_resource could not assign value '#{value}' not respond to #{property_name} :: #{new_resource.class} :: #{new_resource.methods}") unless assign
|
117
|
+
# get_workstation_property(property_name)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
#
|
125
|
+
# The module you have defined may be extended within the recipe to grant the
|
126
|
+
# recipe the helper methods you define.
|
127
|
+
#
|
128
|
+
# Within your recipe you would write:
|
129
|
+
#
|
130
|
+
# extend ChefWorkstationInitialize::WorkstationHelpers
|
131
|
+
#
|
132
|
+
# my_helper_method
|
133
|
+
#
|
134
|
+
# You may also add this to a single resource within a recipe:
|
135
|
+
#
|
136
|
+
# template '/etc/app.conf' do
|
137
|
+
# extend ChefWorkstationInitialize::WorkstationHelpers
|
138
|
+
# variables specific_key: my_helper_method
|
139
|
+
# end
|
140
|
+
#
|