-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
lxd_container: support lxd instance types #3661
lxd_container: support lxd instance types #3661
Conversation
This comment has been minimized.
This comment has been minimized.
2edd7f8
to
af218bd
Compare
Hi @rchicoli, there are several people who are currently working on providing the functionality of the 4.x lxd-api version. It is to late so i didn't look deep on the changes. Thanks Frank |
Hi @conloos I've seen the open MR 3480, but like I mentioned I've took a different approach. If the machine "type" is given, then it uses FYI: this new API exists since LXD v3.19. I wouldn't rename or symlink to lxd, because is too generic. For example, if we would create a different module for managing LXC Volumes, then I would expect another module named
What do you think? Have a good day |
It can be set to "/1.0/instances" for creating instances of type container or virtual-machine. | ||
- If the LXD server version is older than 3.19, then this should be set to "/1.0/containers". | ||
type: str | ||
required: false | ||
architecture: | ||
description: | ||
- 'The architecture for the container (for example C(x86_64) or C(i686)). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen in the documentation that there are multiple lines that reference to container and not an instance. I can update this tonight, if this MR is welcome
af218bd
to
ca40c41
Compare
Update the lxd_container module to enable the new LXD API endpoint, which supports different types of instances, such as containers and virtual machines. The type attributes can be set explicitly to create containers or virtual machines.
ca40c41
to
fc27c49
Compare
Hi @rchicoli, I looked at your changes and was wondering if "api_endpoint" is needed at all. I agree that all documentation have to be updated, like it is done in #3519. Greetings Frank |
I think something like |
Ok. the changes should always be backwards compatible, imho to give the user the opportunity to switch to a new endpoint would have been the better choice. Let me try to explain. I see only one problem. If the user deploys a container and for whatever reason, he changes its "type" to virtual-machine and set the "state" to absent, then the container won't be deleted and Ansible will report that there is nothing to be changed. Anyways, I will revert that..
|
hey @felixfontein thanks for the review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Just some nit comments. @conloos what do you think?
Hi, sorry for not participating in the discussion earlier but, isn't a bit misleading to have a module named Otherwise, disregarding that terminology conundrum, it LGTM. |
@russoz at the beginning of this PR @conloos wrote the above. I think renaming it is a good idea (I don't care whether |
Hello @ALL, from my point of view everything looks fine and the changes don't break anything. In the next step, the module should be completely reviewed/rewritten. I can make that, but if @rchicoli is interested I'm fine with that. The second thing is the name of the module. I vote for "renaming to: lxd_instance and set a deprecate message by using lxd_container" as @rchicoli it has already suggested. Maybe a symlink and check which name was used to call up the module is possible? Thanks Frank |
In that case I will merge once the final nits are fixed.
The symlink will mainly be needed for Ansible 2.9, for ansible-base 2.10 and later an entry in meta/runtime.yml will be needed. I can help with the rename; if someone starts a PR for the rename which renames the module (and does all the documentation updates etc. that are necessary) and keeps the checkbox for maintainer pushes enabled, I can push the remaining technical parts to it. |
I agree.
Exactly. I have the feeling they didn't want to duplicate the swagger api to add the "containers" and "virtual-machines" endpoints. So you are wondering here is the API implementation:
you can take over this time. At the moment I am kinda busy with other projects. I want to be a bit precautious before squashing all commits, since it is my first contribution. If I understood it right, further changes will be done as a nextt step in a separated MR. I am glad to contribute to the code. Thanks everyone for the support. |
Merging since there's an implicit 'shipit' by @conloos in #3661 (comment) (sorry, missed that). |
Backport to stable-4: 💚 backport PR created✅ Backport PR branch: Backported as #3761 🤖 @patchback |
* lxd_container: support lxd instance types Update the lxd_container module to enable the new LXD API endpoint, which supports different types of instances, such as containers and virtual machines. The type attributes can be set explicitly to create containers or virtual machines. * lxd_container: rename references from containers to instances * lxd_container: add an example of creating vms * lxd_container: update doc * lxd_container: fix pylint * resolve converstation * remove type from config * remove outdated validation related to the instance api * correct diff * changing last bits * add missing dot (cherry picked from commit 58eb94f)
* lxd_container: support lxd instance types Update the lxd_container module to enable the new LXD API endpoint, which supports different types of instances, such as containers and virtual machines. The type attributes can be set explicitly to create containers or virtual machines. * lxd_container: rename references from containers to instances * lxd_container: add an example of creating vms * lxd_container: update doc * lxd_container: fix pylint * resolve converstation * remove type from config * remove outdated validation related to the instance api * correct diff * changing last bits * add missing dot (cherry picked from commit 58eb94f) Co-authored-by: rchicoli <rchicoli@users.noreply.github.com>
SUMMARY
This MR adds support to lxd_container module to deploy either containers or virtual-machines. For that it was necessary to create two new parameters
api_endpoint
andtype
:api_endpoint
: is required in order to be backwards compatible with old LXD servers, which does not support the new API endpoint/1.0/virtual-machines
or/1.0/instances
(implemented in lxd 3.19)type
: there is two different types of instances, “container” or “virtual-machine”It is related to:
It is a different approach of an open MR:
ISSUE TYPE
COMPONENT NAME
lxd_container
ADDITIONAL INFORMATION
The old functionality has not changed. Additionally I've tested the changes only with the latest LXD version 4.19.
container
tovirtual-machine
or vice-versa, it fails with a warning, otherwise I was only getting changed as status, which is not correct.