Skip to content

Commit

Permalink
(bug) - Fix empty inventory
Browse files Browse the repository at this point in the history
this provides a default inventory location in the event that one is not
supplied to the provision service task.
  • Loading branch information
jordanbreen28 committed Aug 5, 2024
1 parent 5b26d04 commit 4a98922
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tasks/provision_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,22 @@ def tear_down(node_name, inventory, _vars, retry_attempts)
response.to_json
end

# Runs the provision or tear_down action based on the provided parameters.
# Expects the following parameters in JSON format from stdin:
# - action: The action to perform ('provision' or 'tear_down').
# - node_name: The name of the node to provision or tear down.
# - platform: The platform to provision.
# - vars: Additional variables to assign to nodes.
# - retry_attempts: The number of retry attempts for provisioning or tearing down.
# - inventory_location: The location of the inventory file. If not provided, defaults to './spec/fixtures/litmus_inventory.yaml'.
# The result of the action is printed to stdout in JSON format.
# Exits with status 0 on success, or 1 on failure.
def self.run
params = JSON.parse($stdin.read)
params.transform_keys!(&:to_sym)
action, node_name, platform, vars, retry_attempts, inventory_location = params.values_at(:action, :node_name, :platform, :vars, :retry_attempts, :inventory)

inventory_location ||= File.join(Dir.pwd, '/spec/fixtures/litmus_inventory.yaml')
inventory = InventoryHelper.open(inventory_location)

runner = new
Expand Down

0 comments on commit 4a98922

Please sign in to comment.