Module: ChefWorkstationInitialize::SelfBootstrap::NoChef::WorkstationHelpers

Includes:
UsersHelpers
Included in:
WorkstationResourceHelpers
Defined in:
lib/selfbootstrap/nochef/workstation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from UsersHelpers

#create_group, #create_user, #generate_secret, #generate_ssh_user_key, #generate_user_data, #secretdatabag, #secretdatabagitem, #secretdatabagkey, #set_cookbook_user_secret_key, #user_fully_created?, #userdatabag

Methods included from UpdateHelpers

#commit_state

Methods included from KnifeHelpers

#get_solo_cmd, #is_knife?, #knife, #knife_get_node_attribute, #knife_search_self_cmd, #knife_self_bootstrap_cmd, #self_bootstrap_options

Methods included from ChefRepoHelpers

#create_attribute_file, #create_chef_additionnal_dir, #create_chef_infra_cookbook, #create_cookbook, #create_generator, #create_recipe, #create_template_file, #define_cron_job, #ensure_main_environment, #project_environment_json, #project_role_json, #render_template, #write_Solo_file, #write_kitchen_file, #write_main_environment, #write_main_role, #write_main_role_environment, #write_role_environment

Methods included from KitchenHelpers

#building_kitchen, #generate_kitchen, #generate_machine, #is_kitchen_command?, #kitchen, #kitchen_machine, #kitchen_root

Methods included from ProvisionersHelpers

#chef_zero_provisioner, #provisioners

Methods included from PlatformsHelpers

#default_platforms

Methods included from SuitesHelpers

#default_suites

Methods included from VerifiersHelpers

#inspec_verifier, #verifiers

Methods included from ChefHelpers

#chef, #chef_client, #install_chef_workstation, #is_chef_cli_command?, #is_chef_client_command?, #is_chef_command?, #is_chef_enabled?, #is_chef_installed?, #is_chef_profile_set?, #is_chefworkstation_available?, #is_knife_gem_install?

Methods included from BerksHelpers

#berks, #berks_vendor, #berks_vendor_all_cookbook, #berks_vendor_cookbook, #berks_vendor_init, #delete_all_berkslock, #delete_cookbook_berkslock, #reset_berks_vendor_dir, #self_berks_vendor

Methods included from GitHelpers

#all_cookbooks, #generate_git_submodules, #generate_json_repo, #get_git_path, #get_git_relative_path, #get_git_server, #get_git_submodule, #get_self_git, #git_exec, #git_submodule_init, #repository_list

Methods included from SSHHelpers

#delete_hostkey, #delete_hostkey_ip_or_name, #generate_private_key, #ssh, #ssh_command, #ssh_keygen

Methods included from CommandlineHelpers

#base_command, #get_homedir, #is_mixlib_disabled?, #main_command, #run_options

Methods included from DefaultMethodsHelpers

#analyse_object, #check_install_dir, #debug_worklog, #default_chefzero_portrange, #default_hostname, #default_install_dir, #define_resource_requirements, #error_worklog, #generate_default_install_dir, #generate_directory, #get_out_of_cache_path, #get_out_of_folder, #get_out_of_local_chef_path, #get_path, #is_chef_constant_enabled?, #parent_nil?, #require_implement_method, #search_local_project_folder, #warning_worklog, #worklog, #worklog_counter

Instance Attribute Details

#workstationobj ⇒ Object (readonly)

Returns the value of attribute workstationobj.



20
21
22
# File 'lib/selfbootstrap/nochef/workstation.rb', line 20

def workstationobj
  @workstationobj
end

Instance Method Details

#auto_repo(auto_repo_action = nil, auto_repo_compile_time = false) ⇒ Object



22
23
24
# File 'lib/selfbootstrap/nochef/workstation.rb', line 22

def auto_repo(auto_repo_action = nil, auto_repo_compile_time = false)
  require_implement_method('auto_repo', %w(auto_repo_action auto_repo_compile_time))
end

#bootstrapping_progress_file ⇒ Object



186
187
188
# File 'lib/selfbootstrap/nochef/workstation.rb', line 186

def bootstrapping_progress_file
  ::File.join(get_path(workstation_chef_repo_path), 'bootstrapping_in_progress')
end

#change_unix_permission ⇒ Object



203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/selfbootstrap/nochef/workstation.rb', line 203

def change_unix_permission
  [
    "chown -R #{workstation_resource[:user]}:#{workstation_resource[:group]} #{get_path(workstation_chef_repo_path)}",
    "find #{get_path(workstation_chef_repo_path)} -type d -exec chown -R #{workstation_resource[:user]}:#{workstation_resource[:group]} {} \\;",
    "find #{get_path(workstation_chef_repo_path)} -type d -exec chmod 775 {} \\;",
    "find #{get_path(workstation_chef_repo_path)} -type f -exec chown -R #{workstation_resource[:user]}:#{workstation_resource[:group]} {} \\;",
    "find #{get_path(workstation_chef_repo_path)} -type f -exec chmod g+w {} \\;",
  ].each do |permission_command|
    base_command(permission_command, [], { live: true, sudo: true })
    worklog("Change unix permission :: #{permission_command}")
  end
end

#create_main_generator ⇒ Object



194
195
196
# File 'lib/selfbootstrap/nochef/workstation.rb', line 194

def create_main_generator
  create_generator(main_generator_name)
end

#main_generator_name ⇒ Object



190
191
192
# File 'lib/selfbootstrap/nochef/workstation.rb', line 190

def main_generator_name
  "#{project_name}_generator"
end

#new_cookbook_name ⇒ Object



198
199
200
201
# File 'lib/selfbootstrap/nochef/workstation.rb', line 198

def new_cookbook_name
  worklog("Get cookbook_name between #{cookbook_name} and #{project_name}_#{cookbook_name}")
  cookbook_name.include?(project_name) ? cookbook_name : "#{project_name}_#{cookbook_name}"
end

#node_infra_chef ⇒ Object



26
27
28
# File 'lib/selfbootstrap/nochef/workstation.rb', line 26

def node_infra_chef
  require_implement_method('node_infra_chef', [])
end

#prepare_new_resource ⇒ Object



216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/selfbootstrap/nochef/workstation.rb', line 216

def prepare_new_resource
  node_infra_chef
  set_cookbook_user_secret_key
  generate_directory(workstation_chef_repo_path)
  # include_recipe "#{new_cookbook_name}::#{workstation_resource[:environment]}" if new_cookbook_name.include?(project_name)
  # include_recipe "#{new_cookbook_name}::#{project_name}" unless includes_recipe? new_cookbook_name.include?(project_name)
  # generate_machine('chefserver')
  debug_worklog("workstation_resource[:infra] = #{workstation_resource[:infra]}")
  # unless workstation_resource[:infra].nil?
  #   worklog("Running workstation_resource[:infra]")
  #   workstation_resource[:infra]
  # end
end

#project_name ⇒ Object



30
31
32
# File 'lib/selfbootstrap/nochef/workstation.rb', line 30

def project_name
  workstation_resource[:project_name]
end

#workstation_acl_path ⇒ Object



62
63
64
# File 'lib/selfbootstrap/nochef/workstation.rb', line 62

def workstation_acl_path
  ::File.join(get_path(workstation_chef_repo_path), 'acls')
end

#workstation_berks_vendor_dir ⇒ Object



142
143
144
# File 'lib/selfbootstrap/nochef/workstation.rb', line 142

def workstation_berks_vendor_dir
  ::File.join(get_path(workstation_chef_repo_path), 'berks-cookbooks')
end

#workstation_cache_dir ⇒ Object



166
167
168
# File 'lib/selfbootstrap/nochef/workstation.rb', line 166

def workstation_cache_dir
  ::File.join(get_path(workstation_chef_repo_path), 'cache')
end

#workstation_cache_options_syntaxe_path ⇒ Object



54
55
56
# File 'lib/selfbootstrap/nochef/workstation.rb', line 54

def workstation_cache_options_syntaxe_path
  ::File.join(get_path(workstation_config_dir), 'syntaxcache')
end

#workstation_cache_path ⇒ Object



50
51
52
# File 'lib/selfbootstrap/nochef/workstation.rb', line 50

def workstation_cache_path
  ::File.join(get_path(workstation_config_dir), 'local-mode-cache')
end

#workstation_checksum_path ⇒ Object



58
59
60
# File 'lib/selfbootstrap/nochef/workstation.rb', line 58

def workstation_checksum_path
  ::File.join(get_path(workstation_cache_path), 'checksums')
end

#workstation_chef_environments_dir ⇒ Object



154
155
156
# File 'lib/selfbootstrap/nochef/workstation.rb', line 154

def workstation_chef_environments_dir
  ::File.join(get_path(workstation_chef_repo_path), 'environments')
end

#workstation_chef_repo_path ⇒ Object



34
35
36
37
38
39
40
# File 'lib/selfbootstrap/nochef/workstation.rb', line 34

def workstation_chef_repo_path
  if ::File.basename(default_install_dir) == project_name
    default_install_dir
  else
    ::File.join(get_path(install_dir), project_name)
  end
end

#workstation_client_d_dir ⇒ Object



66
67
68
# File 'lib/selfbootstrap/nochef/workstation.rb', line 66

def workstation_client_d_dir
  ::File.join(get_path(workstation_config_dir), 'client.d')
end

#workstation_client_key_path ⇒ Object



70
71
72
# File 'lib/selfbootstrap/nochef/workstation.rb', line 70

def workstation_client_key_path
  ::File.join(get_path(workstation_chef_repo_path), 'client_keys')
end

#workstation_client_path ⇒ Object



74
75
76
# File 'lib/selfbootstrap/nochef/workstation.rb', line 74

def workstation_client_path
  ::File.join(get_path(workstation_chef_repo_path), 'clients')
end

#workstation_config_d_dir ⇒ Object



78
79
80
# File 'lib/selfbootstrap/nochef/workstation.rb', line 78

def workstation_config_d_dir
  ::File.join(get_path(workstation_config_dir), 'config.d')
end

#workstation_config_dir ⇒ Object



46
47
48
# File 'lib/selfbootstrap/nochef/workstation.rb', line 46

def workstation_config_dir
  ::File.join(get_path(workstation_chef_repo_path), '.chef')
end

#workstation_container_path ⇒ Object



82
83
84
# File 'lib/selfbootstrap/nochef/workstation.rb', line 82

def workstation_container_path
  ::File.join(get_path(workstation_chef_repo_path), 'containers')
end

#workstation_cookbook_artifact_path ⇒ Object



86
87
88
# File 'lib/selfbootstrap/nochef/workstation.rb', line 86

def workstation_cookbook_artifact_path
  ::File.join(get_path(workstation_chef_repo_path), 'cookbook_artifacts')
end

#workstation_cookbooks_dir ⇒ Object



42
43
44
# File 'lib/selfbootstrap/nochef/workstation.rb', line 42

def workstation_cookbooks_dir
  ::File.join(get_path(workstation_chef_repo_path), 'cookbooks')
end

#workstation_data_bags_dir ⇒ Object



162
163
164
# File 'lib/selfbootstrap/nochef/workstation.rb', line 162

def workstation_data_bags_dir
  ::File.join(get_path(workstation_chef_repo_path), 'data_bags')
end

#workstation_download_dir ⇒ Object



170
171
172
# File 'lib/selfbootstrap/nochef/workstation.rb', line 170

def workstation_download_dir
  ::File.join(get_path(workstation_chef_repo_path), 'download')
end

#workstation_file ⇒ Object



130
131
132
# File 'lib/selfbootstrap/nochef/workstation.rb', line 130

def workstation_file
  ::File.join(get_path(workstation_libraries_dir), 'selfbootstrap.rb')
end

#workstation_file_backup_path ⇒ Object



90
91
92
# File 'lib/selfbootstrap/nochef/workstation.rb', line 90

def workstation_file_backup_path
  ::File.join(get_path(workstation_cache_path), 'backup')
end

#workstation_file_cache_path ⇒ Object



118
119
120
# File 'lib/selfbootstrap/nochef/workstation.rb', line 118

def workstation_file_cache_path
  ::File.join(get_path(workstation_cache_path), 'cache')
end

#workstation_generators_dir ⇒ Object



138
139
140
# File 'lib/selfbootstrap/nochef/workstation.rb', line 138

def workstation_generators_dir
  ::File.join(get_path(workstation_chef_repo_path), 'generators')
end

#workstation_group_path ⇒ Object



94
95
96
# File 'lib/selfbootstrap/nochef/workstation.rb', line 94

def workstation_group_path
  ::File.join(get_path(workstation_chef_repo_path), 'groups')
end

#workstation_libraries_dir ⇒ Object



126
127
128
# File 'lib/selfbootstrap/nochef/workstation.rb', line 126

def workstation_libraries_dir
  ::File.join(get_path(workstation_chef_repo_path), 'libraries')
end

#workstation_logs_dir ⇒ Object



122
123
124
# File 'lib/selfbootstrap/nochef/workstation.rb', line 122

def workstation_logs_dir
  ::File.join(get_path(workstation_chef_repo_path), 'logs')
end

#workstation_nodes_dir ⇒ Object



150
151
152
# File 'lib/selfbootstrap/nochef/workstation.rb', line 150

def workstation_nodes_dir
  ::File.join(get_path(workstation_chef_repo_path), 'nodes')
end

#workstation_ohai_segment_plugin_path ⇒ Object



98
99
100
# File 'lib/selfbootstrap/nochef/workstation.rb', line 98

def workstation_ohai_segment_plugin_path
  ::File.join(::File.join(get_path(workstation_config_dir), 'ohai'), 'cookbook_plugins')
end

#workstation_policy_dir ⇒ Object



174
175
176
# File 'lib/selfbootstrap/nochef/workstation.rb', line 174

def workstation_policy_dir
  ::File.join(get_path(workstation_chef_repo_path), 'policies')
end

#workstation_policy_files_dir ⇒ Object



182
183
184
# File 'lib/selfbootstrap/nochef/workstation.rb', line 182

def workstation_policy_files_dir
  ::File.join(get_path(workstation_chef_repo_path), 'policyfiles')
end

#workstation_policy_group_dir ⇒ Object



178
179
180
# File 'lib/selfbootstrap/nochef/workstation.rb', line 178

def workstation_policy_group_dir
  ::File.join(get_path(workstation_chef_repo_path), 'policy_group')
end

#workstation_resources_dir ⇒ Object



134
135
136
# File 'lib/selfbootstrap/nochef/workstation.rb', line 134

def workstation_resources_dir
  ::File.join(get_path(workstation_chef_repo_path), 'resources')
end

#workstation_roles_dir ⇒ Object



146
147
148
# File 'lib/selfbootstrap/nochef/workstation.rb', line 146

def workstation_roles_dir
  ::File.join(get_path(workstation_chef_repo_path), 'roles')
end

#workstation_scripts_dir ⇒ Object



158
159
160
# File 'lib/selfbootstrap/nochef/workstation.rb', line 158

def workstation_scripts_dir
  ::File.join(get_path(workstation_chef_repo_path), 'scripts')
end

#workstation_solo_d_dir ⇒ Object



102
103
104
# File 'lib/selfbootstrap/nochef/workstation.rb', line 102

def workstation_solo_d_dir
  ::File.join(get_path(workstation_config_dir), 'solo.d')
end

#workstation_syntax_check_cache_path ⇒ Object



110
111
112
# File 'lib/selfbootstrap/nochef/workstation.rb', line 110

def workstation_syntax_check_cache_path
  ::File.join(get_path(workstation_config_dir), 'syntaxcache')
end

#workstation_trusted_certs_dir ⇒ Object



114
115
116
# File 'lib/selfbootstrap/nochef/workstation.rb', line 114

def workstation_trusted_certs_dir
  ::File.join(get_path(workstation_config_dir), 'trusted_certs')
end

#workstation_user_path ⇒ Object



106
107
108
# File 'lib/selfbootstrap/nochef/workstation.rb', line 106

def workstation_user_path
  ::File.join(get_path(workstation_chef_repo_path), 'users')
end