From 63424d104d9d98e2bb80d0274efdfe62eada39d9 Mon Sep 17 00:00:00 2001 From: Shubham Shinde Date: Tue, 1 Oct 2024 20:49:11 +0530 Subject: [PATCH] (CAT-2052) Pass target container URI instead of container SHA ID to add_feature_to_node() method There is a bug in the 'install_agent' task. It is supposed to install the agent on a host (a VM or a docker container) using bolt and then add the 'puppet-agent' feature to the host in the litmus_inventory file. Bolt returns the SHA ID of the container instead of the localhost URI after it installs the agent. The feature is added through the add_feature_to_node() method. The last parameter of the method is being sent as result["target"]. This is fine in the case of VMs since its their IPv4 address and the method is expecting just that. But in case of docker containers it is their SHA container ID and the method expecting the localhost:{port} URI. This results in the feature not being added to the host. Since bolt is returning the results in the same order it is provided the input 'targets', we can add the feature by indexing the 'targets' array in that order. See https://perforce.atlassian.net/browse/CAT-2052?focusedCommentId=2970824 --- lib/puppet_litmus/rake_tasks.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/puppet_litmus/rake_tasks.rb b/lib/puppet_litmus/rake_tasks.rb index dcb2fe6..3f08a59 100644 --- a/lib/puppet_litmus/rake_tasks.rb +++ b/lib/puppet_litmus/rake_tasks.rb @@ -128,6 +128,7 @@ Rake::Task['spec_prep'].invoke results = install_agent(args[:collection], targets, inventory_hash) + target_index = 0 results.each do |result| command_to_run = "bolt task run puppet_agent::install --targets #{result['target']} --inventoryfile spec/fixtures/litmus_inventory.yaml --modulepath #{DEFAULT_CONFIG_DATA['modulepath']}" raise "Failed on #{result['target']}\n#{result}\ntry running '#{command_to_run}'" if result['status'] != 'success' @@ -157,7 +158,8 @@ end # add puppet-agent feature to successful nodes - inventory_hash = add_feature_to_node(inventory_hash, 'puppet-agent', result['target']) + inventory_hash = add_feature_to_node(inventory_hash, 'puppet-agent', targets[target_index]) + target_index += 1 end # update the inventory with the puppet-agent feature set per node