Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add collateral path option #15

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 =>
Expand Down
7 changes: 6 additions & 1 deletion recipes/setup_rocketmonkey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down
24 changes: 14 additions & 10 deletions recipes/setup_virtualmonkey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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" +
Expand Down
6 changes: 3 additions & 3 deletions templates/default/rocketmonkey_config.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>"


#
Expand Down