os-migrate
os-migrate copied to clipboard
openstacksdk check fails in prelude_common
Out of the box it seems like the check for openstacksdk in os_migrate/roles/prelude_common/tasks/main.yml fails.
Error:
TASK [prelude_common : set openstacksdk version]
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'openstacksdk'\n\nThe error appears to be in '/home/ubuntu/.ansible/collections/ansible_collections/os_migrate/os_migrate/roles/prelude_common/tasks/main.yml': line 25, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: set openstacksdk version\n ^ here\n"}
After debugging what output is genereated which is wanted to set the next variable _installed_openstacksdk_versions, the output from _installed_openstacksdk returns package python-openstacksdk with version 0.5.2, and as a requirement to this pip package the openstacksdk is also installed with version 0.46.0, but this is not fetched by the task.
$ pip3 list | grep openstack
openstacksdk 0.46.0
python-openstackclient 5.2.0
python-openstacksdk 0.5.2
Output:
$ $OSM_CMD $OSM_DIR/playbooks/export_networks.yml
Using /etc/ansible/ansible.cfg as config file
[WARNING]: running playbook inside collection os_migrate.os_migrate
PLAY [migrator]
TASK [Gathering Facts]
ok: [localhost]
TASK [prelude_common : get the current openstacksdk version]
ok: [localhost] => {"changed": false, "packages": {"pip": {"python-openstacksdk": [{"name": "python-openstacksdk", "source": "pip", "version": "0.5.2"}]}}}
If changing the following task to use python-openstacksdk instead of openstacksdk this obviously fails the version check later on.
TASK [prelude_common : print the current installed version of openstacksdk]
ok: [localhost] => {
"_installed_openstacksdk_versions": "0.5.2",
"changed": false
}
TASK [prelude_common : fail if the user has an unsupported openstacksdk version]
fatal: [localhost]: FAILED! => {
"assertion": "_installed_openstacksdk_versions is version(os_migrate_common_minimum_openstacksdk_version, '>=')",
"changed": false,
"evaluated_to": false,
"msg": "The installed openstacksdk version 0.5.2\nmust be >= than 0.36.0\n"
}
Removing python-openstacksdk and keeping openstacksdk reutrn nothing in the play.
$ pip3 list | grep openstack
openstacksdk 0.46.0
python-openstackclient 5.2.0
Output:
$ $OSM_CMD $OSM_DIR/playbooks/export_networks.yml
Using /etc/ansible/ansible.cfg as config file
[WARNING]: running playbook inside collection os_migrate.os_migrate
PLAY [migrator]
TASK [Gathering Facts]
ok: [localhost]
TASK [prelude_common : get the current openstacksdk version]
ok: [localhost] => {"changed": false, "packages": {"pip": {}}}
TASK [prelude_common : set openstacksdk version]
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'openstacksdk'\n\nThe error appears to be in '/home/ubuntu/.ansible/collections/ansible_collections/os_migrate/os_migrate/roles/prelude_common/tasks/main.yml': line 21, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: set openstacksdk version\n ^ here\n"}
PLAY RECAP
localhost : ok=2 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
Not sure if I am going about this all wrong or if this is a bug?
Thank you!
Did a distro upgrade and ended up at a different error now.
Forcing it to check what it can see:
In os_migrate/roles/prelude_common/tasks/main.yml setting
- name: set openstacksdk version
ansible.builtin.set_fact:
_installed_openstacksdk_versions: "{{ _installed_openstacksdk['packages']['pip']['python-openstacksdk'] | map(attribute='version') | list | first }}"
and then running with command
$OSM_CMD $OSM_DIR/playbooks/export_networks.yml -e "os_migrate_common_minimum_openstacksdk_version=0.5.2" -vvv
Returns:
TASK [os_migrate.os_migrate.prelude_src : fetch information about currently authenticated user/project]
task path: [~]/.ansible/collections/ansible_collections/os_migrate/os_migrate/roles/prelude_src/tasks/main.yml:5
The full traceback is:
File "/tmp/ansible_os_migrate.os_migrate.auth_info_payload_vc7fnyes/ansible_os_migrate.os_migrate.auth_info_payload.zip/ansible_collections/openstack/cloud/plugins/module_utils/openstack.py", line 169, in openstack_cloud_from_module
ensure_compatibility(sdk.version.__version__,
File "/tmp/ansible_os_migrate.os_migrate.auth_info_payload_vc7fnyes/ansible_os_migrate.os_migrate.auth_info_payload.zip/ansible_collections/openstack/cloud/plugins/module_utils/openstack.py", line 75, in ensure_compatibility
raise ImportError(
fatal: [localhost]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"api_timeout": null,
"auth": null,
"auth_type": null,
"ca_cert": null,
"client_cert": null,
"client_key": null,
"cloud": "src",
"interface": "public",
"region_name": null,
"sdk_log_level": "INFO",
"sdk_log_path": null,
"timeout": 180,
"validate_certs": null,
"wait": true
}
},
"msg": "Incompatible openstacksdk library found: Version MUST be >=1.0 and <=None, but 0.61.0 is smaller than minimum version 1.0."
}
Is it mixing something up?
$ python --version
Python 3.10.6
$ pip list | grep openstack
openstacksdk 0.61.0
python-openstackclient 5.8.0
python-openstacksdk 0.5.2
Version of the collections are:
"namespace": "community",
"name": "general",
"version": "4.8.10",
"namespace": "community",
"name": "crypto",
"version": "2.11.1",
"namespace": "openstack",
"name": "cloud",
"version": "2.0.0",
"namespace": "os_migrate",
"name": "os_migrate",
"version": "0.14.0",
Any thoughts or ideas?
Hi there! I'm having the same problem. Did you find a way to fix it?
The latter error message "Incompatible openstacksdk library found: Version MUST be >=1.0 and <=None, but 0.61.0 is smaller than minimum version 1.0." looks like it would be coming from the openstack.cloud Ansible collection [1] which OS Migrate depends on. That message could be printed by openstack.cloud collection 2.0 or newer, which we don't yet support with OS Migrate.
For OS Migrate right now it should be ensured that:
- openstacksdk version is < 0.99
- openstack.cloud collection version is < 2.0
We do specify the openstacksdk pin in docs [2] and the openstack.cloud dependency pin in galaxy manifest [3], but depending on how you're installing things, some of these may not have been used perhaps.
[1] https://galaxy.ansible.com/openstack/cloud [2] https://os-migrate.github.io/os-migrate/user/install-from-galaxy.html#using-virtualenv-for-prerequisites [3] https://github.com/os-migrate/os-migrate/blob/385fec8842d84e8db968cc30b42915ccf88781d3/os_migrate/galaxy.yml#L22
working on a fix in #631 - able to reproduce the error, will close this issue once patch is merged.