diff --git a/attributes/default.rb b/attributes/default.rb index d8b77e9..8e3c2fb 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -132,6 +132,8 @@ default[:virtualmonkey][:virtualmonkey][:monkey_repo_branch] = "" # Collateral Repository URL default[:virtualmonkey][:virtualmonkey][:collateral_repo_url] = "" +# Collateral Repository URL +default[:virtualmonkey][:virtualmonkey][:collateral_repo_path] = "" # Collateral Repository Branch default[:virtualmonkey][:virtualmonkey][:collateral_repo_branch] = "" # Right API Objects Repository URL diff --git a/metadata.rb b/metadata.rb index 56ebec9..a5b651f 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license 'Apache 2.0' description 'Installs/Configures VirtualMonkey' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '13.10.1' +version '13.11.0' supports "centos" supports "redhat" @@ -306,6 +306,14 @@ :required => "required", :recipes => ["virtualmonkey::setup_virtualmonkey"] +attribute "virtualmonkey/virtualmonkey/collateral_repo_path", + :display_name => "Collateral Repo Path", + :description => + "Subdirectory containing virtualmonkey collateral for Git project. Defaults to root dir", + :required => "recommended", + :default => "", + :recipes => ["virtualmonkey::setup_virtualmonkey", "virtualmonkey::setup_rocketmonkey"] + attribute "virtualmonkey/virtualmonkey/collateral_repo_branch", :display_name => "Collateral Repo Branch", :description => diff --git a/recipes/setup_rocketmonkey.rb b/recipes/setup_rocketmonkey.rb index 984f80b..82808f4 100644 --- a/recipes/setup_rocketmonkey.rb +++ b/recipes/setup_rocketmonkey.rb @@ -49,6 +49,11 @@ # The rocketmonkey main configuration file is created from a template initially # allowing custom edits on the configuration. +collateral_dir = ::File.join( + node[:virtualmonkey][:user_home], + node[:virtualmonkey][:virtualmonkey][:collateral_name], + node[:virtualmonkey][:virtualmonkey][:collateral_repo_path]) + template "#{node[:virtualmonkey][:user_home]}/.rocketmonkey/rocketmonkey.yaml" do source "rocketmonkey_config.yaml.erb" owner node[:virtualmonkey][:user] @@ -59,7 +64,7 @@ :jenkins_password => node[:'rs-jenkins'][:server][:password], :right_acct_id => node[:virtualmonkey][:rest][:right_acct_id], :right_subdomain => node[:virtualmonkey][:rest][:right_subdomain], - :collateral_repo_name => node['virtualmonkey']['virtualmonkey']['collateral_name'], + :collateral_dir => collateral_dir, :servertemplate_mapping_file_name => node['virtualmonkey']['rocketmonkey']['servertemplate_mapping_file_name'] ) action :create_if_missing diff --git a/recipes/setup_virtualmonkey.rb b/recipes/setup_virtualmonkey.rb index 4063f5c..c1a259e 100644 --- a/recipes/setup_virtualmonkey.rb +++ b/recipes/setup_virtualmonkey.rb @@ -99,27 +99,32 @@ basename_cmd.error! node[:virtualmonkey][:virtualmonkey][:collateral_name] = basename_cmd.stdout.chomp +collateral_dir = ::File.join( + node[:virtualmonkey][:user_home], + node[:virtualmonkey][:virtualmonkey][:collateral_name], + node[:virtualmonkey][:virtualmonkey][:collateral_repo_path]) +repo_checkout_dir = ::File.join( + node[:virtualmonkey][:user_home], + node[:virtualmonkey][:virtualmonkey][:collateral_name]) -log " Checking out collateral repo to" + - " #{node[:virtualmonkey][:virtualmonkey][:collateral_name]}" -git "#{node[:virtualmonkey][:user_home]}/" + - "#{node[:virtualmonkey][:virtualmonkey][:collateral_name]}" do + + +log " Checking out collateral repo to #{repo_checkout_dir}" +git repo_checkout_dir do repository node[:virtualmonkey][:virtualmonkey][:collateral_repo_url] reference node[:virtualmonkey][:virtualmonkey][:collateral_repo_branch] action :sync end execute "git checkout" do - cwd "#{node[:virtualmonkey][:user_home]}/" + - "#{node[:virtualmonkey][:virtualmonkey][:collateral_name]}" + cwd repo_checkout_dir command "git checkout" + " #{node[:virtualmonkey][:virtualmonkey][:collateral_repo_branch]}" end log " Installing gems required for the collateral project" execute "bundle install on collateral" do - cwd "#{node[:virtualmonkey][:user_home]}/" + - "#{node[:virtualmonkey][:virtualmonkey][:collateral_name]}" + cwd collateral_dir # Bundler loads in /usr/local/bin in Ubuntu. Chef looks at system path, so we need to add this explicitly. environment("PATH" => "#{ENV["PATH"]}:/usr/local/bin") command "bundle install --no-color --system" @@ -153,8 +158,7 @@ # Populate all virtualmonkey cloud variables log " Populating virtualmonkey cloud variables" execute "populate cloud variables" do - cwd "#{node[:virtualmonkey][:user_home]}/" + - "#{node[:virtualmonkey][:virtualmonkey][:collateral_name]}" + cwd collateral_dir # Bundler loads in /usr/local/bin in Ubuntu. Chef looks at system path, so we need to add this explicitly. environment("PATH" => "#{ENV["PATH"]}:/usr/local/bin") command "bundle exec monkey populate_all_cloud_vars" + diff --git a/templates/default/rocketmonkey_config.yaml.erb b/templates/default/rocketmonkey_config.yaml.erb index 9266d4c..8a448a8 100644 --- a/templates/default/rocketmonkey_config.yaml.erb +++ b/templates/default/rocketmonkey_config.yaml.erb @@ -57,19 +57,19 @@ # # troop_path - Path to troop files # -:troop_path: "/root/<%= @collateral_repo_name %>/updatedTroops/" +:troop_path: "<%= @collateral_dir %>/updatedTroops/" # # suite_path - Path to test suites # -:suite_path: "/root/<%= @collateral_repo_name %>/suites/" +:suite_path: "<%= @collateral_dir %>/suites/" # # server_template_map_file - Path to server template map file # -:server_template_map_file: "/root/<%= @collateral_repo_name %>/config/servertemplate_mapping/<%= @servertemplate_mapping_file_name %>" +:server_template_map_file: "<%= @collateral_dir %>/config/servertemplate_mapping/<%= @servertemplate_mapping_file_name %>" #