Module: DeployRubygem

Included in:
Project
Defined in:
lib/deploy_rubygem.rb,
lib/deploy_rubygem/rake.rb,
lib/deploy_rubygem/rspec.rb,
lib/deploy_rubygem/kitchen.rb,
lib/deploy_rubygem/project.rb,
lib/deploy_rubygem/rubygem.rb,
lib/deploy_rubygem/testing.rb,
lib/deploy_rubygem/version.rb,
lib/deploy_rubygem/cookbook.rb,
lib/deploy_rubygem/chef_admin.rb,
lib/deploy_rubygem/rspec/chef.rb,
lib/deploy_rubygem/rspec/ruby.rb,
lib/deploy_rubygem/workstation.rb,
lib/deploy_rubygem/inspectestor.rb,
lib/deploy_rubygem/rake/default.rb,
lib/deploy_rubygem/rspec/inspec.rb,
lib/deploy_rubygem/inspec_result.rb,
lib/deploy_rubygem/rake/cookbook.rb,
lib/deploy_rubygem/rake/cucumber.rb,
lib/deploy_rubygem/rake/cookbook/chef.rb,
lib/deploy_rubygem/rake/cookbook/knife.rb,
lib/deploy_rubygem/rake/cookbook/inspec.rb

Overview

DeployRubygem module helper for rubygem

Defined Under Namespace

Modules: ChefCookbookTask, InspecCookbookTask, KnifeCookbookTask, RSpecTesting Classes: ChefAdmin, Cookbook, InspecTestor, InspecTestorResult, Kitchen, Project, RakeCookbookTask, RakeCucumberTask, RakeDefaultTask, RakeTask, Rubygem, Testing, Workstation

Constant Summary collapse

VERSION =

VERSION = new_deploy_rubygem.gvb_version.short_version

'0.60.47'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.deployerObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/deploy_rubygem.rb', line 36

def self.deployer
  chefrepo_path = File.join(%w[test exemple chefrepo])
  project_options = {
    project_name: 'rubygem_test',
    git: '[email protected]:/Exemple/rubygem',
    chefrepo_git: '[email protected]:/Exemple/chefrepo',
    chefrepo_path: chefrepo_path,
    binaries: %w[exemple_deploy],
    dependencies: %w[deploy_rubygem],
    path: File.join(chefrepo_path, %w[projects rubygem_test]),
    cookbooks: {
      exemple_cookbook: exemple_cookbook
    }
  }
  @deployer ||= DeployRubygem::Project.new(project_options)
end

.exemple_cookbookObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/deploy_rubygem.rb', line 22

def self.exemple_cookbook
  {
    git: '[email protected]:/Exemple/exemple_cookbook.git',
    path: File.join(Dir.home, 'jimbo_management_site'),
    kitchens: %w[base],
    compliance_profiles: {
      input: 'compliance/inputs/user.yml',
      profile: 'jimbodragon-management-site'
    },
    execute_profiles: %w[jimbodragon-accept],
    groups: %w[base]
  }
end

Instance Method Details

#bootstrap_chef_workstation(option_file) ⇒ Object



73
74
75
76
77
78
79
80
81
# File 'lib/deploy_rubygem.rb', line 73

def bootstrap_chef_workstation(option_file)
  workstation_options = JSON.parse(File.read(option_file))

  if workstation_options['user_folder'] == '/root'
    DeployRubygem::ChefAdmin.new(workstation_options).boostrap
  else
    DeployRubygem::Workstation.new(workstation_options).boostrap_workstation
  end
end

#chef_accept_cmdObject



10
11
12
# File 'lib/deploy_rubygem/rspec/chef.rb', line 10

def chef_accept_cmd
  'chef show-policy jimbo_management_site base --chef-license accept'
end

#chef_env_cmdObject



6
7
8
# File 'lib/deploy_rubygem/rspec/chef.rb', line 6

def chef_env_cmd
  'chef --chef-license accept env'
end

#install_chef_workstationObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/deploy_rubygem.rb', line 53

def install_chef_workstation
  workstation_options = {
    user_folder: '/root',
    node_name: ENV.fetch('NODENAME'),
    knife_name: ENV.fetch('KNIFE_NAME'),
    policyname: ENV.fetch('POLICYNAME'),
    policygroup: ENV.fetch('POLICYGROUP'),
    chef_server_url: ENV.fetch('CHEF_SERVER_URL'),
    chef_client_key: ENV.fetch('CHEF_CLIENT_KEY'),
    chef_knife_key: ENV.fetch('CHEF_KNIFE_KEY')
  }

  File.write('node_options', JSON.generate(workstation_options))
  system('sudo deploy_rubygem bootstrap node_options')

  workstation_options[:user_folder] = Dir.home
  File.write('workstation_options', JSON.generate(workstation_options))
  system('deploy_rubygem bootstrap workstation_options')
end

#no_option_txtObject



10
11
12
# File 'lib/deploy_rubygem.rb', line 10

def no_option_txt
  'Use "deploy_rubygem install" to install Chef dependencies'
end

#rubygem_testObject



18
19
20
# File 'lib/deploy_rubygem.rb', line 18

def rubygem_test
  DeployRubygem.deployer
end

#unknown_option_txt(options) ⇒ Object



14
15
16
# File 'lib/deploy_rubygem.rb', line 14

def unknown_option_txt(options)
  "#{no_option_txt}\nUnknown options #{options}"
end