Module: ChefWorkstationInitialize::SelfBootstrap::NoChef::WorkstationResourceHelpers

Includes:
WorkstationHelpers
Included in:
SelfBootstrapHelpers
Defined in:
lib/selfbootstrap/nochef/workstationresource.rb,
lib/selfbootstrap/nochef/defaultworkstationresource.rb

Instance Attribute Summary

Attributes included from WorkstationHelpers

#workstationobj

Instance Method Summary collapse

Methods included from WorkstationHelpers

#auto_repo, #bootstrapping_progress_file, #change_unix_permission, #create_main_generator, #main_generator_name, #new_cookbook_name, #node_infra_chef, #prepare_new_resource, #project_name, #workstation_acl_path, #workstation_berks_vendor_dir, #workstation_cache_dir, #workstation_cache_options_syntaxe_path, #workstation_cache_path, #workstation_checksum_path, #workstation_chef_environments_dir, #workstation_chef_repo_path, #workstation_client_d_dir, #workstation_client_key_path, #workstation_client_path, #workstation_config_d_dir, #workstation_config_dir, #workstation_container_path, #workstation_cookbook_artifact_path, #workstation_cookbooks_dir, #workstation_data_bags_dir, #workstation_download_dir, #workstation_file, #workstation_file_backup_path, #workstation_file_cache_path, #workstation_generators_dir, #workstation_group_path, #workstation_libraries_dir, #workstation_logs_dir, #workstation_nodes_dir, #workstation_ohai_segment_plugin_path, #workstation_policy_dir, #workstation_policy_files_dir, #workstation_policy_group_dir, #workstation_resources_dir, #workstation_roles_dir, #workstation_scripts_dir, #workstation_solo_d_dir, #workstation_syntax_check_cache_path, #workstation_trusted_certs_dir, #workstation_user_path

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 Method Details

#default_workstation_data ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/selfbootstrap/nochef/workstationresource.rb', line 25

def default_workstation_data
  {
    install_dir: ::Dir.getwd,
    project_name: ::File.basename(::Dir.getwd),
    cookbook_source: 'infra_chef',
    project_description: nil,
    environments: nil,
    initial_command: nil,
    cron_chef_solo_command: nil,
    chef_boostrapped: nil,
    environment: nil,
    user: ENV['USER'],
    group: ENV['GROUP'].nil? ? ENV['USER'] : ENV['GROUP'],
    home: ENV['HOME'],
    run_for_type: nil,
    gitinfo: nil,
    cron: nil,
    provisioners: nil,
    verifiers: nil,
    platforms: nil,
    suites: nil,
    default_attributes: nil,
    override_attributes: nil,
    solo: true,
    data_bag_encrypt_version: 3,
    file_cache_path: '',
    debug: false,
  }
end

#get_workstation ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/selfbootstrap/nochef/workstationresource.rb', line 71

def get_workstation
  # ::File.join(get_path(workstation_chef_repo_path), __FILE__.gsub(/^.*cache/), '')
  # @workstation_tool = new_workstation
  # include new_workstation
  @workstation = default_workstation_resource if @workstation.nil?
  swap_workstation(ChefWorkstationInitialize::SelfBootstrap::WithChef) if respond_to? 'Chef'
  @workstation
end

#set_workstation_data(workstation_data) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/selfbootstrap/nochef/workstationresource.rb', line 80

def set_workstation_data(workstation_data)
  # ::File.join(get_path(workstation_chef_repo_path), __FILE__.gsub(/^.*cache/), '')
  # @workstation_tool = new_workstation
  # include new_workstation
  # @workstation = default_workstation_resource if @workstation.nil?
  # swap_workstation(ChefWorkstationInitialize::SelfBootstrap::WithChef) if respond_to? 'Chef'
  # @workstation

  workstation_data.send(:extend, ChefWorkstationInitialize::SelfBootstrap)
  workstation_data
end

#set_workstation_resource(new_resource_set) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/selfbootstrap/nochef/workstationresource.rb', line 55

def set_workstation_resource(new_resource_set)
  workstation_resource_keys.each do |key|
    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)
  end
  # if new_resource_set.respond_to?(:node) && new_resource_set.node[workstation_resource[:cookbook_source]].nil? == false
  #   workstation_resource_keys.each do |key|
  #     workstation_resource[key.to_sym] = node['infra_chef'][key.to_s]
  #   end
  # end
  workstation_resource
end

#swap_workstation(new_workstation) ⇒ Object



67
68
69
# File 'lib/selfbootstrap/nochef/workstationresource.rb', line 67

def swap_workstation(new_workstation)
  @workstation = new_workstation.get_workstation
end

#workstation_resource ⇒ Object



92
93
94
# File 'lib/selfbootstrap/nochef/workstationresource.rb', line 92

def workstation_resource
  default_workstation_data
end

#workstation_resource_keys ⇒ Object



21
22
23
# File 'lib/selfbootstrap/nochef/workstationresource.rb', line 21

def workstation_resource_keys
  default_workstation_data.keys
end