How to change flavor or sg of a virtual machine with Ansible?
Hello, I'm new in this Openstack world and I love Ansible. I'm trying to use the openstack.cloud Ansible collection to manage virtual machines. There is no problems in adding or deleting a virtual machine (vm). The openstack.cloud.server module works very well. I'm in trouble if I want to update a vm. The server module has only the "present" state: the resource is not updated after the creation if I change something in the module parameters. So, I can't use openstack.cloud.server module in order to change the flavor or security group of an already existing vm. The "server_action" module is not useful because it has not update actions about sg or flavor. I tried the CRUD "resource" module in some way such as --- - name: Change resources hosts: localhost tasks: - name: Change flavor to vm openstack.cloud.resource: cloud: myStack service: compute type: server attributes: name: vm-name flavor_id: 22b4d2c2-0fff-437b-a67c-009244f89403 state: present wait: true but the play fails with fatal: [localhost]: FAILED! => {"changed": false, "extra_data": {"data": null, "details": "Invalid input for field/attribute server. Value: {'flavorRef': '22b4d2c2-0fd8-437b-a67c-009244f89403'}. Additional properties are not allowed ('flavorRef' was unexpected)" If I try with "flavor" or "security_groups" attributes in place of "flavor_id" the error doesn't change. Could you help me? My env is: [root@cnt-ansible]/workdir/openstack# ansible-galaxy collection list | grep openstack openstack.cloud 2.5.0 [root@cnt-ansible]/workdir/openstack# pip3 list | grep openstack openstacksdk 4.9.0 ansible [core 2.16.14] Thank you very much Kind Regards Marco
Hi Marco, I am not 100% sure, but I think this operation is currently not implemented in the openstack.cloud collection. I'd assume that the openstack.cloud.server_action module should be responsible for an operation like this [1], but `resize` is not in the list of actions. Regarding openstack.cloud.resource - I frankly never properly played with it to suggest anything, but if to refer to openstacksdk documentation, it still should be `resize_server`, which is not listed as supported. Thus, I'd guess your best choice would be to use ansible.builtin.command with supplying `-f json`, to be able to register and parse stdout with | from_json.... [1] https://docs.ansible.com/projects/ansible/latest/collections/openstack/cloud... [2] https://docs.openstack.org/openstacksdk/latest/user/proxies/compute.html#mod... пн, 2 февр. 2026 г. в 15:45, Marco Favero <marco.favero@csi.it>:
Hello,
I'm new in this Openstack world and I love Ansible. I'm trying to use the openstack.cloud Ansible collection to manage virtual machines.
There is no problems in adding or deleting a virtual machine (vm). The openstack.cloud.server module works very well.
I'm in trouble if I want to update a vm. The server module has only the "present" state: the resource is not updated after the creation if I change something in the module parameters.
So, I can't use openstack.cloud.server module in order to change the flavor or security group of an already existing vm.
The "server_action" module is not useful because it has not update actions about sg or flavor.
I tried the CRUD "resource" module in some way such as
--- - name: Change resources hosts: localhost tasks: - name: Change flavor to vm openstack.cloud.resource: cloud: myStack service: compute type: server attributes: name: vm-name flavor_id: 22b4d2c2-0fff-437b-a67c-009244f89403 state: present wait: true
but the play fails with
fatal: [localhost]: FAILED! => {"changed": false, "extra_data": {"data": null, "details": "Invalid input for field/attribute server. Value: {'flavorRef': '22b4d2c2-0fd8-437b-a67c-009244f89403'}. Additional properties are not allowed ('flavorRef' was unexpected)"
If I try with "flavor" or "security_groups" attributes in place of "flavor_id" the error doesn't change.
Could you help me?
My env is:
[root@cnt-ansible]/workdir/openstack# ansible-galaxy collection list | grep openstack openstack.cloud 2.5.0 [root@cnt-ansible]/workdir/openstack# pip3 list | grep openstack openstacksdk 4.9.0
ansible [core 2.16.14]
Thank you very much Kind Regards
Marco
Hi Dmitriy, thank you for the help. Reading the documentation and trying better I see that with server module I can change the sg. :) But I can't change the flavor. I think I have to modify the collection in server_action in order to perform a flavor change. Because it seems that resource module can't do that :( Thank you Kind Regards Marco
Hello, I see that a patch for "flavor change" exists already: https://review.opendev.org/c/openstack/ansible-collections-openstack/+/84505... It was abandoned, but I asked to reopen it. Unfortunately after some years the patch needs to be rebased. I have done this work and I have tested it in my cloud. Reading at documentation I think I have to submit the patch for the review. I committed the change with the old Change-Id, I created a opendev account and I generated my HTTP Password. I can't perform the git review: # git review Username for 'https://opendev.org': <my user> Password for 'https://<my user>@opendev.org': remote: Failed to authenticate user fatal: Authentication failed for 'https://opendev.org/openstack/ansible-collections-openstack.git/' Could you help me? Thank you Kind Regards Marco Il 03/02/2026 10:07, marco.favero@csi.it ha scritto:
Hi Dmitriy,
thank you for the help. Reading the documentation and trying better I see that with server module I can change the sg. :)
But I can't change the flavor.
I think I have to modify the collection in server_action in order to perform a flavor change. Because it seems that resource module can't do that :(
Thank you Kind Regards Marco
On Tue, Feb 10, 2026, at 1:32 AM, Marco Favero wrote:
Hello, I see that a patch for "flavor change" exists already:
https://review.opendev.org/c/openstack/ansible-collections-openstack/+/84505...
It was abandoned, but I asked to reopen it. Unfortunately after some years the patch needs to be rebased.
I have done this work and I have tested it in my cloud.
Reading at documentation I think I have to submit the patch for the review.
I committed the change with the old Change-Id, I created a opendev account and I generated my HTTP Password.
I can't perform the git review:
# git review Username for 'https://opendev.org': <my user> Password for 'https://<my user>@opendev.org': remote: Failed to authenticate user fatal: Authentication failed for 'https://opendev.org/openstack/ansible-collections-openstack.git/'
Could you help me?
It looks like you are trying to push to https://opendev.org rather than review.opendev.org. The gitea instance at opendev.org does not accept pushes you need to push to Gerrit at review.opendev.org instead. The .gitreview configuration file for that repo is configured to use review.opendev.org and SSH (not HTTPS) here https://opendev.org/openstack/ansible-collections-openstack/src/branch/maste... Do you know why your gerrit remote is set to https://opendev.org? I would probably delete the gerrit git remote and then rerun git review -s so that it can configure an SSH remote to review.opendev.org that you can push to.
Thank you Kind Regards Marco
On 2026-02-10 08:12:36 -0800 (-0800), Clark Boylan wrote:
On Tue, Feb 10, 2026, at 1:32 AM, Marco Favero wrote: [...]
Reading at documentation I think I have to submit the patch for the review.
I committed the change with the old Change-Id, I created a opendev account and I generated my HTTP Password.
I can't perform the git review:
# git review Username for 'https://opendev.org': <my user> Password for 'https://<my user>@opendev.org': remote: Failed to authenticate user fatal: Authentication failed for 'https://opendev.org/openstack/ansible-collections-openstack.git/'
Could you help me?
It looks like you are trying to push to https://opendev.org rather than review.opendev.org. The gitea instance at opendev.org does not accept pushes you need to push to Gerrit at review.opendev.org instead. The .gitreview configuration file for that repo is configured to use review.opendev.org and SSH (not HTTPS) here https://opendev.org/openstack/ansible-collections-openstack/src/branch/maste... Do you know why your gerrit remote is set to https://opendev.org? [...]
Also, what documentation were you reading? It would be good to go over The OpenStack Contributor Guide in its entirety, but in particular the Using Gerrit section at https://docs.openstack.org/contributors/code-and-documentation/using-gerrit.... covers what you want to do, including a subsection for Checking Out Others' Changes. -- Jeremy Stanley
participants (5)
-
Clark Boylan
-
Dmitriy Rabotyagov
-
Jeremy Stanley
-
Marco Favero
-
marco.favero@csi.it