Class: JimboDragon::Knife

Inherits:
Object
  • Object
show all
Defined in:
lib/jimbodragon/knife.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(knife_or_chefclient) ⇒ Knife

Returns a new instance of Knife.



8
9
10
# File 'lib/jimbodragon/knife.rb', line 8

def initialize(knife_or_chefclient)
  @knife_or_chefclient = knife_or_chefclient
end

Instance Attribute Details

#knife_or_chefclientObject

Returns the value of attribute knife_or_chefclient.



6
7
8
# File 'lib/jimbodragon/knife.rb', line 6

def knife_or_chefclient
  @knife_or_chefclient
end

Instance Method Details

#chef_path(relative_chef_repo_path) ⇒ Object



75
76
77
# File 'lib/jimbodragon/knife.rb', line 75

def chef_path(relative_chef_repo_path)
  ::File.expand_path(::File.join(chef_repo_path, relative_chef_repo_path))
end

#chef_repo_pathObject



71
72
73
# File 'lib/jimbodragon/knife.rb', line 71

def chef_repo_path
  ::File.expand_path(::File.join(::File.dirname(JimboDragon::JimboEnv::ENVIRONMENT_FILE), 'chef_repo'))
end

#load_knifeObject



17
18
19
20
21
22
23
24
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/jimbodragon/knife.rb', line 17

def load_knife
  send_to_chef(:chef_license, 'accept')
  send_to_chef(:log_level, :info)
  send_to_chef(:node_name, JimboDragon::JimboEnv::KNIFE_USER)

  send_to_chef(:client_key, chef_path(::File.join([
    'profiles.d',
    JimboDragon::JimboEnv::KNIFE_USER,
    'chef',
    "#{JimboDragon::JimboEnv::KNIFE_USER}.pem",
  ])))
  send_to_chef(:chef_server_url, 'https://api.chef.io/organizations/jimbodragon')

  send_to_chef(:chef_repo_path, chef_repo_path)
  send_to_chef(:cookbook_path, [
      chef_path('cookbooks'),
      chef_path('libraries'),
      chef_path('resources'),
      chef_path('berks-cookbooks'),
    ]
  )
  send_to_chef(:data_bags_path, chef_path('data_bags'))
  send_to_chef(:environment_path, chef_path('environments'))
  send_to_chef(:node_path, chef_path('nodes'))
  send_to_chef(:policy_group_path, chef_path('policy_group'))
  send_to_chef(:policy_path, chef_path('policies'))
  send_to_chef(:role_path, chef_path('roles'))
  send_to_chef(:log_location, chef_path(::File.join(['logs', "#{JimboDragon::JimboEnv::KNIFE_USER}.log"])))
  send_to_chef(:cache_path, chef_path('.chef/local-mode-cache'))
  send_to_chef(:checksum_path, chef_path('.chef/local-mode-cache/checksums'))
  send_to_chef(:acl_path, chef_path('acls'))
  send_to_chef(:client_d_dir, chef_path('.chef/client.d'))
  send_to_chef(:client_key_path, chef_path('client_keys'))
  send_to_chef(:client_path, chef_path('clients'))
  send_to_chef(:color, true)
  send_to_chef(:config_d_dir, chef_path('.chef/config.d'))
  send_to_chef(:config_dir, chef_path('.chef'))
  send_to_chef(:container_path, chef_path('containers'))
  send_to_chef(:cookbook_artifact_path, chef_path('cookbook_artifacts'))
  send_to_chef(:enable_reporting, false)
  send_to_chef(:file_backup_path, chef_path('.chef/local-mode-cache/backup'))
  send_to_chef(:file_cache_path, chef_path('.chef/local-mode-cache/cache'))
  send_to_chef(:group_path, chef_path('groups'))
  send_to_chef(:lockfile, chef_path('.chef/local-mode-cache/cache/chef-client-running.pid'))
  send_to_chef(:ohai_segment_plugin_path, chef_path('.chef/ohai/cookbook_plugins'))
  send_to_chef(:solo_d_dir, chef_path('.chef/solo.d'))
  send_to_chef(:user_path, chef_path('users'))
  send_to_chef(:syntax_check_cache_path, chef_path('.chef/syntaxcache'))
  send_to_chef(:trusted_certs_dir, chef_path('.chef/trusted_certs'))
  send_to_chef(:validation_client_name, "#{JimboDragon::JimboEnv::HAB_ORIGIN}-validator")
  send_to_chef(:data_bag_encrypt_version, 3)
  send_to_chef(:named_run_list, JimboDragon::JimboEnv::NAMED_RUN_LIST)
end

#send_to_chef(method, parameter) ⇒ Object



12
13
14
15
# File 'lib/jimbodragon/knife.rb', line 12

def send_to_chef(method, parameter)
  Chef::Log.debug("Adding #{method} with value #{parameter}")
  knife_or_chefclient.send(method, parameter)
end