From 07eaad81993219d9d1e6b2ce2e6deefe926845b2 Mon Sep 17 00:00:00 2001 From: thomashaw Date: Tue, 11 Apr 2017 11:46:44 +0100 Subject: [PATCH] Project Vagrantfile's now use relative paths. This enables distribution of project's without having to mess with paths. --- lib/helpers/constants.rb | 3 --- lib/output/project_files_creator.rb | 6 ++++++ lib/templates/Vagrantfile.erb | 4 ++-- modules/build/environments/production/environment.conf | 0 4 files changed, 8 insertions(+), 5 deletions(-) delete mode 100644 modules/build/environments/production/environment.conf diff --git a/lib/helpers/constants.rb b/lib/helpers/constants.rb index 47e67d2d9..52aaaec9f 100644 --- a/lib/helpers/constants.rb +++ b/lib/helpers/constants.rb @@ -24,9 +24,6 @@ BUILDS_SCHEMA_FILE = "#{ROOT_DIR}/lib/schemas/build_metadata_schema.xsd" # Path to projects directory PROJECTS_DIR = "#{ROOT_DIR}/projects" -# Path to environments directory -ENVIRONMENTS_DIR = "#{ROOT_DIR}/modules/build/environments" - # Path to modules directories MODULES_DIR = "#{ROOT_DIR}/modules/" VULNERABILITIES_DIR = "#{MODULES_DIR}vulnerabilities/" diff --git a/lib/output/project_files_creator.rb b/lib/output/project_files_creator.rb index e9ef6bfab..b8e7e5a15 100644 --- a/lib/output/project_files_creator.rb +++ b/lib/output/project_files_creator.rb @@ -34,6 +34,7 @@ class ProjectFilesCreator def write_files FileUtils.mkpath "#{@out_dir}" unless File.exists?("#{@out_dir}") FileUtils.mkpath "#{@out_dir}/puppet/" unless File.exists?("#{@out_dir}/puppet/") + FileUtils.mkpath "#{@out_dir}/environments/production/" unless File.exists?("#{@out_dir}/environments/production/") threads = [] # for each system, create a puppet modules directory using librarian-puppet @@ -48,6 +49,11 @@ class ProjectFilesCreator GemExec.exe('librarian-puppet', path, 'install') end + # Create environments/production/environment.conf - Required in Puppet 4+ + efile = "#{@out_dir}/environments/production/environment.conf" + Print.std "Creating Puppet Environent file: #{efile}" + FileUtils.touch(efile) + vfile = "#{@out_dir}/Vagrantfile" Print.std "Creating Vagrant file: #{vfile}" template_based_file_write(VAGRANT_TEMPLATE_FILE, vfile) diff --git a/lib/templates/Vagrantfile.erb b/lib/templates/Vagrantfile.erb index 2a744e893..0075408d4 100644 --- a/lib/templates/Vagrantfile.erb +++ b/lib/templates/Vagrantfile.erb @@ -78,10 +78,10 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| } <% end -%> <%=module_name%>.module_path = "<%="puppet/#{system.name}/modules"%>" - <%=module_name%>.environment_path = "<%="#{ENVIRONMENTS_DIR}"%>" + <%=module_name%>.environment_path = "environments/" <%=module_name%>.environment = "production" <%=module_name%>.synced_folder_type = "rsync" - <%=module_name%>.manifests_path = "<%="#{ROOT_DIR}/#{selected_module.module_path}/"%>" + <%=module_name%>.manifests_path = "<%="puppet/#{system.name}/modules/#{selected_module.module_path_end}"%>" <%=module_name%>.manifest_file = "<%="#{selected_module.module_path_end}.pp"%>" end <% end -%> diff --git a/modules/build/environments/production/environment.conf b/modules/build/environments/production/environment.conf deleted file mode 100644 index e69de29bb..000000000