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

The provision::abs task fails if litmus_inventory.yaml already exists #187

Closed
jpartlow opened this issue Dec 16, 2021 · 0 comments
Closed
Labels

Comments

@jpartlow
Copy link
Contributor

Describe the Bug

If you run provision::abs when spec/fixtures/litmus_inventory.yaml already exists, it will fail with a NoMethodError.

Expected Behavior

The provision::abs task should go about it's business whether or not the litmus_inventory.yaml already exists.

Steps to Reproduce

Bumped into this in a test case in #186.

jpartlow added a commit to jpartlow/provision that referenced this issue Feb 12, 2022
I introduced this in cd72bb6.

When the newly structured abs task calls lib/task_helper's
get_inventory_hash() method and finds a pre-existing inventory_full_path
file. It attempts to call
PuppetLitmus::InventoryManipulation.inventory_hash_from_inventory_file()
which fails, because that method is not a class method.

The puzzling thing about this is why it ever worked, because I was wrong
that puppetlabs#187 was pre-existing.

The issue here is that the abs (the previous version), docker,
docker_exp, and vagrant tasks all use 'include PuppetLitmus::InventoryManipulation'
or 'include PuppetLitmus' (which includes InventoryManipulation) in the
scope of global functions declared implicitly on the main Object. This
causes the included module to be included in the base Object class,
which effectively makes its methods available everywhere. So a call to
PuppetLitmus::InventoryManipulation.inventory_hash_from_inventory_file()
actually works, as would String.inventory_hash_from_inventory_file or
anything else...

When I 'fixed' the abs task to include PuppetLitmus::InventoryManipulation
within the new ABSProvision class, I broke that global behavior
but only for abs.

The fix is straightforward now that I know what's going on. Removing the
module prefix from the method call works for both the new abs task and
the other tasks that still rely on the global behavior. In the abs task
case, InventoryManipulation is included in the class, so the methods are
available. For the other tasks, InventoryManipulation is still included
by main, and the methods are available everywhere anyway.
jpartlow added a commit that referenced this issue Feb 14, 2022
(GH-187) Fixes abs failing provision if inventory file exists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant