Sha256: bbc8a22ff5b70ad9ebb3f12eaa8edd48bb42191da1beced0412c998b7f5ae5c4
Contents?: true
Size: 1.8 KB
Versions: 6
Compression:
Stored size: 1.8 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 ChefNode 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 clientrb_file = '/etc/chef/client.rb' clientpem_file = '/etc/chef/client.pem' Dir.mkdir('/etc/chef') unless Dir.exist?('/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('chef env --chef-license accept') end end end
Version data entries
6 entries across 6 versions & 1 rubygems