Sha256: 82bdcda321f089b014e4b66456a7025af75afdc9d2ca288b157a67bebbcefec3
Contents?: true
Size: 1.96 KB
Versions: 5
Compression:
Stored size: 1.96 KB
Contents
# frozen_string_literal: true require 'fileutils' # DeployRubygem - deploy a gem using rake # Containing a class module DeployRubygem # Using Project to deploy and manage Project class ChefAdmin attr_reader :chef_server_url, :nodename, :policyname, :policygroup, :knife_name, :chef_client_key def initialize(options) @chef_server_url = options['chef_server_url'] @nodename = options['node_name'] @policyname = options['policyname'] @policygroup = options['policygroup'] @knife_name = options['knife_name'] @chef_client_key = options['chef_client_key'] end def clientrb { log_location: '/var/log/chef-client.log', chef_server_url: chef_server_url, chef_license: 'accept', file_cache_path: '/var/chef/cache', file_backup_path: '/var/chef/backup', node_name: nodename, policy_name: policyname, policy_group: policygroup }.map do |key, value| abort("key #{key} need to have a value :: #{value.class}") if value.nil? || value.empty? key_pair = [key, "'#{value}'"] key_pair.join(' ') end.join("\n") end def read_file(file_path) puts "REading file #{file_path}" puts File.read(file_path) puts "Had read #{File.read(file_path).split('\n').length} lines" end def boostrap extend DeployRubygem clientrb_file = '/etc/chef/client.rb' clientpem_file = '/etc/chef/client.pem' FileUtils.mkdir_p('/etc/chef') File.write(clientrb_file, clientrb) File.write(clientpem_file, chef_client_key.split('\\n').join("\n")) [clientrb_file, clientpem_file].each do |file_path| FileUtils.chmod(0o600, file_path) # read_file(file_path) end system('curl -L https://omnitruck.chef.io/install.sh > chef_install.sh') system('bash chef_install.sh -P chef-workstation -s once') || abort('Chef not installable') system(chef_accept_cmd) end end end
Version data entries
5 entries across 5 versions & 1 rubygems