require 'deploy_rubygem/rubygem' require 'deploy_rubygem/cookbook' require 'deploy_rubygem/version' module DeployRubygem def self.self_project_options project_name = 'deploy_rubygem' { project_name: project_name, binaries: %w( deploy_rubygem prepare_workstation test_deploy_rubygem deploy_jimbodragon ), dependencies: %w( deploy_rubygem jimbo_management_site ), path: DeployRubygem.deploy_rubygem_path, cookbooks: { jimbo_management_site: { chef_repo: DeployRubygem.chefrepo_path, git: 'git@github.com:JimboDragonGit/jimbo_management_site.git', kitchens: %w(base), profiles: %w( jimbodragon-accept jimbodragon-applications jimbodragon-deploy-context jimbodragon-environment jimbodragon-git/ jimbodragon-linux-baseline jimbodragon-manual-push jimbodragon-push jimbodragon-services jimbodragon-users jimbodragon-workstation ), execute_profiles: %w(jimbodragon-accept), groups: %w(base) } } } end def self.self_deploy Rubygem.new(self_project_options).deploy end def self.deploy_jimbo_management_site self_project_options[:cookbooks].each do |cookbook_name, cookbook_options| Cookbook.new(cookbook_name, cookbook_options).deploy end end def self.deploy_rubygem_path File.join(ENV['HOME'], 'deploy_rubygem') end def self.jimbo_management_site_path File.join(ENV['HOME'], 'jimbo_management_site') end def self.chefrepo_path '/usr/local/chef/repo/jimbodragon' end def self.change_to_directory(git_path, git_url) if not Dir.exist?(chefrepo_path) system("git clone #{git_url}") end Dir.chdir(git_path) end def self.main DeployRubygem.change_to_directory(DeployRubygem.chefrepo_path, 'git@github.com:JimboDragonGit/jimbodragon.git') DeployRubygem.change_to_directory(DeployRubygem.jimbo_management_site_path, 'git@github.com:JimboDragonGit/jimbo_management_site.git') DeployRubygem.change_to_directory(DeployRubygem.deploy_rubygem_path, 'git@github.com:JimboDragonGit/deploy_rubygem.git') DeployRubygem.self_deploy DeployRubygem.deploy_jimbo_management_site end def self.test DeployRubygem.change_to_directory(DeployRubygem.deploy_rubygem_path, 'git@github.com:JimboDragonGit/deploy_rubygem.git') system("rake install:local") system("rake") end def self.deploy_jimbodragon Dir.chdir(jimbo_management_site_path) system('sudo rm -rf /tmp/jimbodragon/; chef exec inspec exec compliance/profiles/jimbodragon-chef') end end