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

Vagrant: test_vagrant_root[box_url] fails due to missing box (#274) #275

Merged
merged 2 commits into from
Oct 4, 2024

Conversation

dinadins
Copy link
Contributor

@dinadins dinadins commented Oct 3, 2024

Replacing obsolete box/checksum with CentOS-8-Vagrant-8.4.2105-20210603.0.x86_64.vagrant-libvirt.box / 37cc017738bf12cafce3a97c4de73526452da6332cc5c0516723988644e62620.

With these values in test/vagrant-plugin/scenarios/molecule/box_url/molecule.yml the test passes.

@@ -8,8 +8,8 @@ driver:
platforms:
- name: instance
box: centos/stream9
box_url: "https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-Vagrant-9-20230704.1.x86_64.vagrant-libvirt.box"
box_download_checksum: "8a9fe7e8083421047e5404131daa007b4c1bcc466f3d9b29d0e7c7e432891a0e"
box_url: "https://cloud.centos.org/centos/8/vagrant/x86_64/images/CentOS-8-Vagrant-8.4.2105-20210603.0.x86_64.vagrant-libvirt.box"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the box: centos/stream9 but the box_url points to an old Centos 8.

but why not https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-Vagrant-9-20240930.0.x86_64.vagrant-virtualbox.box?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, no vbox specific box please... well, one could argue that we're using libvirt box, breaking tests for vbox ...
I noticed this bug too and my idea was to do some ugly hack like using python httpserver to serve the testbox but -ENOTIME.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is this box will "expire" in less than a year, while the Centos-8 will be there "forever". There's 5 v8 libvirt boxes now, the oldest from 2019, but even if they decide to clean up at some point, there's a good chance they will keep the most recent one just for reference.

Copy link
Contributor Author

@dinadins dinadins Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the box: centos/stream9 but the box_url points to an old Centos 8.

Hm, missed that :)

Interestingly, I got a brand new centos/stream9 box in Vagrant storage, so it seems that when config.vm.box_url is specified, config.vm.box (normally used to identify boxes in Vagrant Cloud) will be retained to name the vm in local Vagrant repo.

I ran the test with box: centos/8-legacy and sure enough I got a centos/8-legacy in local storage.

The Vagrant documentation is unclear on this matter:

  • config.vm.box (string) - This configures what box the machine will be brought up against. The value here should be the name of an installed box or a shorthand name of a box in HashiCorp's Vagrant Cloud.
  • config.vm.box_url (string, array of strings) - The URL that the configured box can be found at. If config.vm.box is a shorthand to a box in HashiCorp's Vagrant Cloud then this value does not need to be specified. Otherwise, it should point to the proper place where the box can be found if it is not installed. This can also be an array of multiple URLs. The URLs will be tried in order.

So I can either:

  • update the box_url entry to something like centos/8-legacy, or
  • update box_url, box_download_checksum to latest Centos 9.

As you wish.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote to update box_url and box_download_checksum to latest Centos 9, so we use current up-to-date images.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to CentOS-Stream-Vagrant-9-20240930.0.x86_64.vagrant-libvirt.box. Test passes (but see discussion below).

@apatard
Copy link
Member

apatard commented Oct 3, 2024

hm. test is still failing here with:

fatal: [instance]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "changed": false, "module_stderr": "", "module_stdout": "/bin/sh: /usr/bin/python3: No such file or directory\r\n", "msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error", "rc": 127}

Not sure if it's a local issue but:

sudo dnf install python3
CentOS Linux 8 - AppStream                                                                                                                                                         0.0  B/s |   0  B     00:00    
Errors during downloading metadata for repository 'appstream':
  - Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=vag [Could not resolve host: mirrorlist.centos.org]
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=vag [Could not resolve host: mirrorlist.centos.org]

@dinadins
Copy link
Contributor Author

dinadins commented Oct 3, 2024

@apatard There is no reference in the plugin code to mirrors.centos,org. This seems to be an issue with your setup, I take it you are running on Centos 8. mirrors.centos.org is indeed defunct.

Here's a workaround.

@apatard
Copy link
Member

apatard commented Oct 4, 2024

@apatard There is no reference in the plugin code to mirrors.centos,org. This seems to be an issue with your setup, I take it you are running on Centos 8. mirrors.centos.org is indeed defunct.

Here's a workaround.

I don't need any workaround. What I did was:

$ tox -e py311
<wait>
========================================================================= 1 failed, 24 passed, 9 skipped, 2 xfailed 
py311: exit 1 (551.52 seconds) /vagrant/projects/molecule-plugins-up> pytest --color=yes -s pid=47157

So 1 test was still failing. Turns out it was box_url. So did :

$ source .tox/py311/bin/activate
$ cd test/vagrant-plugin/scenarios
$ molecule test -s box_url

At that point, noticed that it managed so create the box. Was happy to see the issue fixed. Then got the error:

TASK [Sample task] *************************************************************
fatal: [instance]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "changed": false, "module_stderr": "", "module_stdout": "/bin/sh: /usr/bin/python3: No such file or directory\r\n", "msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error", "rc": 127}

This means that the test is still broken and I should not have to do some manual workaround to make the test pass. And any workaround like that should not be added to the test suite.

@dinadins
Copy link
Contributor Author

dinadins commented Oct 4, 2024

@apatard I misread your initial comment, I though the problem was with the host you were running the tests on and suggested to apply the workaround on that, not in the test.

I am not using tox, just running pytest test/vagrant-plugin/functional/test_func.py::test_vagrant_root[box_url], which passes with the Centos 8 box.

However, since there seems to be an issue, I went to ~/.cache/molecule/scenarios/box_url and ran vagrant up, which succeded. Noted box IP and updated inventory/ansible_inventory.yml. Then vagrant ssh.

Verified OS version:

Last login: Fri Oct  4 09:02:46 2024 from 192.168.121.1
[vagrant@instance ~]$ rpm -qa | grep release
centos-linux-release-8.4-1.2105.el8.noarch
[vagrant@instance ~]$ 

The file /usr/lib/python3 is indeed absent:

[vagrant@instance ~]$ stat /usr/bin/python3
stat: cannot stat '/usr/bin/python3': No such file or directory
[vagrant@instance ~]$ cat /etc/issue

dnf install fails with the same error you get:

sudo dnf install python3
CentOS Linux 8 - AppStream                                                                                                                                 0.0  B/s |   0  B     00:00    
Errors during downloading metadata for repository 'appstream':
  - Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=vag [Could not resolve host: mirrorlist.centos.org]
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=vag [Could not resolve host: mirrorlist.centos.org]
[vagrant@instance ~]$

But I could run the test playbook successfully:

~/.cache/molecule/scenarios/box_url$ ansible-playbook -i inventory/ansible_inventory.yml ~/deleteme/molecule-plugins/test/vagrant-plugin/scenarios/molecule/box_url/converge.yml -vv
ansible-playbook [core 2.14.0]
  config file = /home/xxxxxxxx/.cache/molecule/scenarios/box_url/ansible.cfg
  configured module search path = ['/home/xxxxxxxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/xxxxxxxx/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/xxxxxxxx/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/xxxxxxxx/.local/bin/ansible-playbook
  python version = 3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True
Using /home/xxxxxxxx/.cache/molecule/scenarios/box_url/ansible.cfg as config file
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: converge.yml ********************************************************************************************************************************************************************************************
1 plays in /home/xxxxxxxx/deleteme/molecule-plugins/test/vagrant-plugin/scenarios/molecule/box_url/converge.yml

PLAY [Converge] ***************************************************************************************************************************************************************************************************

TASK [Sample task] ************************************************************************************************************************************************************************************************
task path: /home/xxxxxxxx/deleteme/molecule-plugins/test/vagrant-plugin/scenarios/molecule/box_url/converge.yml:7
ok: [instance] => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"}, "changed": false, "cmd": "uname", "delta": "0:00:00.003423", "end": "2024-10-04 09:02:46.239947", "msg": "", "rc": 0, "start": "2024-10-04 09:02:46.236524", "stderr": "", "stderr_lines": [], "stdout": "Linux", "stdout_lines": ["Linux"]}

PLAY RECAP ********************************************************************************************************************************************************************************************************
instance                   : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Note different python interpreter location. Also, I am on ansible 2.14.0.

Not sure where to go from here.

@apatard
Copy link
Member

apatard commented Oct 4, 2024

@apatard I misread your initial comment, I though the problem was with the host you were running the tests on and suggested to apply the workaround on that, not in the test.

I am not using tox, just running pytest test/vagrant-plugin/functional/test_func.py::test_vagrant_root[box_url], which passes with the Centos 8 box.

However, since there seems to be an issue, I went to ~/.cache/molecule/scenarios/box_url and ran vagrant up, which succeded. Noted box IP and updated inventory/ansible_inventory.yml. Then vagrant ssh.

iirc, after a full molecule test, the cache files are useless/wrong.

Verified OS version:

Last login: Fri Oct  4 09:02:46 2024 from 192.168.121.1
[vagrant@instance ~]$ rpm -qa | grep release
centos-linux-release-8.4-1.2105.el8.noarch
[vagrant@instance ~]$ 

The file /usr/lib/python3 is indeed absent:

[vagrant@instance ~]$ stat /usr/bin/python3
stat: cannot stat '/usr/bin/python3': No such file or directory
[vagrant@instance ~]$ cat /etc/issue

dnf install fails with the same error you get:

sudo dnf install python3
CentOS Linux 8 - AppStream                                                                                                                                 0.0  B/s |   0  B     00:00    
Errors during downloading metadata for repository 'appstream':
  - Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=vag [Could not resolve host: mirrorlist.centos.org]
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=vag [Could not resolve host: mirrorlist.centos.org]
[vagrant@instance ~]$

But I could run the test playbook successfully:

~/.cache/molecule/scenarios/box_url$ ansible-playbook -i inventory/ansible_inventory.yml ~/deleteme/molecule-plugins/test/vagrant-plugin/scenarios/molecule/box_url/converge.yml -vv
ansible-playbook [core 2.14.0]
  config file = /home/xxxxxxxx/.cache/molecule/scenarios/box_url/ansible.cfg
  configured module search path = ['/home/xxxxxxxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/xxxxxxxx/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/xxxxxxxx/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/xxxxxxxx/.local/bin/ansible-playbook
  python version = 3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True
Using /home/xxxxxxxx/.cache/molecule/scenarios/box_url/ansible.cfg as config file
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: converge.yml ********************************************************************************************************************************************************************************************
1 plays in /home/xxxxxxxx/deleteme/molecule-plugins/test/vagrant-plugin/scenarios/molecule/box_url/converge.yml

PLAY [Converge] ***************************************************************************************************************************************************************************************************

TASK [Sample task] ************************************************************************************************************************************************************************************************
task path: /home/xxxxxxxx/deleteme/molecule-plugins/test/vagrant-plugin/scenarios/molecule/box_url/converge.yml:7
ok: [instance] => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"}, "changed": false, "cmd": "uname", "delta": "0:00:00.003423", "end": "2024-10-04 09:02:46.239947", "msg": "", "rc": 0, "start": "2024-10-04 09:02:46.236524", "stderr": "", "stderr_lines": [], "stdout": "Linux", "stdout_lines": ["Linux"]}

PLAY RECAP ********************************************************************************************************************************************************************************************************
instance                   : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Note different python interpreter location. Also, I am on ansible 2.14.0.

Not sure where to go from here.

No idea what's exactly happening. Anyway, with your latest changes I've tested while having lunch are working fine. Thanks. I'm going to merge this PR.

@apatard apatard merged commit 8b2e896 into ansible-community:main Oct 4, 2024
11 checks passed
@dinadins
Copy link
Contributor Author

dinadins commented Oct 7, 2024

FWIW, I found that ansible 2.17 dropped support for python 3.6, which is "platform-python" for RHEL/CentOS 8, Ubuntu 18.04, and opensuse 15. Consequently, these platforms are supported only up to ansible 2.16.

This is why the test was passing for me on CentOS 8 and ansible 2.14, and failing for you on (I presume) ansible 2.17+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vagrant
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants