Feature request: Add the possibility to avoid the scenario to be added to the hostname
Issue Type
- Feature request
Molecule and Ansible details
ansible 2.3.1.0
molecule, version 2.0.0.0rc11
- Molecule installation method: pip
- Ansible installation method: pip
Desired Behaviour
As your documentation says:
Molecule automatically appends the scenario name to the instances it is testing. It doesn’t seem useful to converge each scenario against the same static host.
But in special scenario we could need to avoid this functionnality. Let me take two examples happening in my case:
-
I want to use the static drivers, I have in my possession differents VM on my enterprise ESX, each VM corresponding to a different OS version or to a different configuration. I just wanna set to my platforms configuration the IP to the VM.
-
I would test my ansible role with different scenario on the same machine (VM, Vagrant, docker ...). I would love to test that my role is still working with differents vars. I have a role which install php, I want to install with default value, let's say PHP5.6, then relaunch the role with PHP7.1 on the same machine. It should find that there is already a PHP installed, remove it, install the new one etc ...
As you could see, english is not my first language, I hope I was clear enough.
I'll send you a PR to add this feature if you think it could be a good idea.
@Dorn- I wasn't initially a fan of this. However, your PR is very clean. I'll look this over more.
There are some use cases I don't think you are handling. If a user does not use the static driver and still relies on molecule to create the instances.
The molecule_instance_with_scenario_name will still try to append the scenario name via instance_with_scenario_name.
If the user provides `
platforms:
- name: static-instance-vagrant
append_scenario: False
Then that should short circuit all scenario name appending everywhere.
Also, the reason I like having the scenario name appended, it is very clear what is going on.
I want to use the static drivers, I have in my possession differents VM on my enterprise ESX, each VM corresponding to a different OS version or to a different configuration. I just wanna set to my platforms configuration the IP to the VM.
I would simply argue you should spin up static instances with the scenario name appended.
I would test my ansible role with different scenario on the same machine (VM, Vagrant, docker ...). I would love to test that my role is still working with differents vars. I have a role which install php, I want to install with default value, let's say PHP5.6, then relaunch the role with PHP7.1 on the same machine. It should find that there is already a PHP installed, remove it, install the new one etc ...
This particular use case is only a use case with the static driver. If a user allows Molecule to mange the instance, Molecule would create/destroy instances between scenarios.
This is probably the best argument for not including the scenairo name in the hostname. However, it is only a use case one can obtain from the static driver.
If you can address the comment above, I'll look it over.
Hello @retr0h, Thank you for your feedback.
I would simply argue you should spin up static instances with the scenario name appended.
If only I could... But atm I am currently working in a big company with different IT department, the one providing us the VM made 2 months to give us 6 boxes... I have no access to the ESX and I have to deal with IP, I could ask for an internal dns, but I'ld have to do it for each new scenario. This is kinda specific to my use but not so uncommon I think.
Just to be clear and to be sure to do the right thing, you want to add this option for all the others drivers beside the static one ? To do so, you think I should update the instance_with_scenario_name method ? I am not familiar neither with molecule nor python, any help/tips would be really useful.
What is the best way to organize the code, if I add a condition into the instance_with_scenario_name function, it will be kinda weird to have a function called instance_with_scenario_name and which returns sometimes an instance with no scenario name. It will be prettier to have a more generic function which will call either the instance_with_scenario_name function or the new one which could be called instance_without_scenario_name
Kind regards
I'm thinking it doesn't make sense to append the scenario name anyways. I'll take a look at your PR and massage it a bit.
Supplemented by #895.