to test plans and tasks against an inventory that I've created via pecdm
to run my plans and tasks using the --inventoryfile option. In other words, if have a test plan in /a/test/module and my pecdm inventory file lives beneath /my/peadm/gcp/inventory.yaml, then I want to be able to test my new hello plan with bolt by running cd /a/test/module && bolt plan run module::hello --inventoryfile=/my/peadm/gcp/inventory.yaml --targets=all. Curently this will not work because /my/peadm/gcp/inventory.yaml uses relative paths to the various terraform directories, e.g.,
Can we have some option to produce fullpaths as well?
Describe Alternatives You've Considered
I've created a ruby script to amend all my terraform inventory.yaml files so that I can achieve the above. For example, I added the following script to my PATH and then I run this from any GCP terraform inventory.yaml directories
#!/opt/puppetlabs/puppet/bin/ruby
require 'yaml'
require 'fileutils'
# ABORT IF:
# (1) current directory does not contain the inventory.yaml file
# (2) inventory.yaml is not using terraform, i.e. no "_plugin: terraform" entries
abort("ERROR: current directory does not contain the inventory.yaml file") unless File.exist?('inventory.yaml')
abort("INFO: inventory.yaml is not using the terraform plugin so no need to proceed") unless File.read('inventory.yaml').include?('_plugin: terraform')
# ensure all "dir" entries contain fullpath to the directory containing the inventory.yaml file
directory = File.expand_path(File.dirname('inventory.yaml'))
File.open('inventory.yaml', "r+") do |file|
contents = file.read
contents.gsub!("dir: .terraform", "dir: #{directory}/.terraform")
contents.gsub!("dir: terraform", "dir: #{directory}/terraform")
file.rewind
file.write(contents)
end
Use Case
As a module developer, I want to be able
--inventoryfile
option. In other words, if have a test plan in/a/test/module
and my pecdm inventory file lives beneath/my/peadm/gcp/inventory.yaml
, then I want to be able to test my newhello
plan with bolt by runningcd /a/test/module && bolt plan run module::hello --inventoryfile=/my/peadm/gcp/inventory.yaml --targets=all
. Curently this will not work because/my/peadm/gcp/inventory.yaml
uses relative paths to the various terraform directories, e.g.,I believe that the above is generated via the inventory_yaml.epp
Describe the Solution You Would Like
Can we have some option to produce fullpaths as well?
Describe Alternatives You've Considered
I've created a ruby script to amend all my terraform inventory.yaml files so that I can achieve the above. For example, I added the following script to my PATH and then I run this from any GCP terraform inventory.yaml directories