Skip to content

Conversation

@dkruces
Copy link
Contributor

@dkruces dkruces commented Jun 27, 2025

guestfs main task YAML file import_tasks for intalling dependencies with:
file: "{{ role_path }}/tasks/install-deps/main.yml"

That file also import_tasks using distro specific tasks. This file path needs to use the path from the role tasks/ path and not from where the file is located.

Logs:
make bringup
...
ansible-playbook -vv
--inventory localhost,
playbooks/guestfs.yml
--extra-vars=@./extra_vars.yaml
--tags install-deps
ansible-playbook [core 2.19.0b2]
config file = /scratch/dagomez/linux-kdevops/kdevops/ansible.cfg
configured module search path =
['/home/dagomez/.ansible/plugins/modules',
'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /home/dagomez/.ansible/collections:/usr
/share/ansible/collections
executable location = /usr/bin/ansible-playbook
python version = 3.13.3 (main, Apr 10 2025, 21:38:51) [GCC 14.2.0]
(/usr/bin/python3)
jinja version = 3.1.6
pyyaml version = 6.0.2 (with libyaml v0.2.5)
Using /scratch/dagomez/linux-kdevops/kdevops/ansible.cfg as config file statically imported:
/scratch/dagomez/linux-kdevops/kdevops/playbooks/roles/guestfs/tasks/ install-deps/main.yml
[ERROR]: Unable to retrieve file contents.
Could not find or access
'/scratch/dagomez/linux-kdevops/kdevops/playbooks/debian/main.yml' on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option: [Errno 2] No such file or directory: '/scratch/dagomez/linux-kdevops/kdevops/playbooks/debian/main.yml

@dkruces dkruces requested a review from chucklever June 27, 2025 08:17
@dkruces
Copy link
Contributor Author

dkruces commented Jun 27, 2025

@chucklever this is also a GitHub PR for testing the process you are discussing.

Note: I would have merged this fix directly into mainline if the tests passed. However, I wanted to check with you first: do you have any preference for using relative paths versus full paths, such as those used in the main guestfs role’s main.yaml file?

This

-    file: install-deps/debian/main.yml
+    file: "{{ role_path }}/tasks/install-deps/main.yml"

Note that I haven't tested the proposal but I assume it works too for nested import_tasks.

@chucklever
Copy link
Contributor

I have been using full pathnames only recently. I agree that should be more reliable in general. What I don't yet understand here is why I didn't see this problem during my own testing.

@chucklever
Copy link
Contributor

On a related note, I'm not convinced that import_tasks is better than include_tasks for install-deps/. All of these have a when: clause, which possibly makes dynamic inclusion a more reliable choice.

@dkruces
Copy link
Contributor Author

dkruces commented Jun 27, 2025

I have been using full pathnames only recently. I agree that should be more reliable in general. What I don't yet understand here is why I didn't see this problem during my own testing.

I think this is because of the Ansible version my machine has. This is what I'm seeing:

This is the version I'm currently using:

ansible --version
ansible [core 2.19.0b2]
  config file = /scratch/dagomez/linux-kdevops/kdevops/ansible.cfg
  configured module search path = ['/home/dagomez/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/dagomez/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.13.3 (main, Apr 10 2025, 21:38:51) [GCC 14.2.0] (/usr/bin/python3)
  jinja version = 3.1.6
  pyyaml version = 6.0.2 (with libyaml v0.2.5)
  

  ansible-playbook --version
ansible-playbook [core 2.19.0b2]
  config file = /scratch/dagomez/linux-kdevops/kdevops/ansible.cfg
  configured module search path = ['/home/dagomez/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/dagomez/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-playbook
  python version = 3.13.3 (main, Apr 10 2025, 21:38:51) [GCC 14.2.0] (/usr/bin/python3)
  jinja version = 3.1.6
  pyyaml version = 6.0.2 (with libyaml v0.2.5)
  
  
python3 -m pip list | grep ansi
ansible                      12.0.0a2
ansible-core                 2.19.0b2

@chucklever
Copy link
Contributor

Just for comparison:

cel@renoir:~$ cat /etc/redhat-release 
Fedora release 41 (Forty One)
cel@renoir:~$ ansible --version
ansible [core 2.16.14]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/cel/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.13/site-packages/ansible
  ansible collection location = /home/cel/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.13.3 (main, Apr 22 2025, 00:00:00) [GCC 14.2.1 20250110 (Red Hat 14.2.1-7)] (/usr/bin/python3)
  jinja version = 3.1.6
  libyaml = True
cel@renoir:~$ python3 -m pip list | grep ansi
ansible-compat                          24.9.0
ansible-core                            2.16.14
ansible-lint                            24
ansible-pylibssh                        1.2.2
cel@renoir:~$

I don't have any problem adding {{ role_path }} to the pathnames.

@dkruces
Copy link
Contributor Author

dkruces commented Jun 27, 2025

I don't have any problem adding {{ role_path }} to the pathnames.

I'll add the role_path and merge this.

@dkruces
Copy link
Contributor Author

dkruces commented Jun 27, 2025

Just for comparison:

cel@renoir:~$ cat /etc/redhat-release 
Fedora release 41 (Forty One)
cel@renoir:~$ ansible --version
ansible [core 2.16.14]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/cel/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.13/site-packages/ansible
  ansible collection location = /home/cel/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.13.3 (main, Apr 22 2025, 00:00:00) [GCC 14.2.1 20250110 (Red Hat 14.2.1-7)] (/usr/bin/python3)
  jinja version = 3.1.6
  libyaml = True
cel@renoir:~$ python3 -m pip list | grep ansi
ansible-compat                          24.9.0
ansible-core                            2.16.14
ansible-lint                            24
ansible-pylibssh                        1.2.2
cel@renoir:~$

I think I'm running a "too new" release and yours it's a bit "too old"?

2.16 is EOL May 2026
https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html

@chucklever
Copy link
Contributor

I think I'm running a "too new" release and yours it's a bit "too old"?

Fwiw, I think I am using the release packaged by Fedora, just to lower my own administrative chores ... but they are often one or two versions backlevel for everything, even on the currently supported Fedora releases. F41 will be EOL in a few months.

Thank you for testing the guestfs playbook!

@dkruces
Copy link
Contributor Author

dkruces commented Jun 27, 2025

Fwiw, I think I am using the release packaged by Fedora, just to lower my own administrative chores ... but they are often one or two versions backlevel for everything, even on the currently supported Fedora releases. F41 will be EOL in a few months.

Ansible in Debian trixie uses beta releases... I'd probably get v2.19.0b4 if I update now. Latest beta is b6.

https://packages.debian.org/trixie/ansible-core
https://github.com/ansible/ansible/releases/tag/v2.19.0b2
https://github.com/ansible/ansible/releases/tag/v2.19.0b4
https://github.com/ansible/ansible/releases/tag/v2.19.0b6

@dkruces dkruces force-pushed the dagomez/fix-guestfs-role-import-tasks branch from e464487 to 625e294 Compare June 27, 2025 15:05
guestfs main task YAML file import_tasks for intalling dependencies
with:
  file: "{{ role_path }}/tasks/install-deps/main.yml"

That file also import_tasks using distro specific tasks. This file path
needs to use the path from the role tasks/ path and not from where the
file is located.

Logs:
make bringup
...
ansible-playbook -vv \
        --inventory localhost, \
        playbooks/guestfs.yml \
        --extra-vars=@./extra_vars.yaml \
        --tags install-deps
ansible-playbook [core 2.19.0b2]
  config file = /scratch/dagomez/linux-kdevops/kdevops/ansible.cfg
  configured module search path =
['/home/dagomez/.ansible/plugins/modules',
'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/dagomez/.ansible/collections:/usr
  /share/ansible/collections
  executable location = /usr/bin/ansible-playbook
  python version = 3.13.3 (main, Apr 10 2025, 21:38:51) [GCC 14.2.0]
(/usr/bin/python3)
  jinja version = 3.1.6
  pyyaml version = 6.0.2 (with libyaml v0.2.5)
Using /scratch/dagomez/linux-kdevops/kdevops/ansible.cfg as config file
statically imported:
/scratch/dagomez/linux-kdevops/kdevops/playbooks/roles/guestfs/tasks/
install-deps/main.yml
[ERROR]: Unable to retrieve file contents.
Could not find or access
'/scratch/dagomez/linux-kdevops/kdevops/playbooks/debian/main.yml' on
the Ansible Controller.
If you are using a module and expect the file to exist on the remote,
see the remote_src option: [Errno 2] No such file or directory:
'/scratch/dagomez/linux-kdevops/kdevops/playbooks/debian/main.yml

Signed-off-by: Daniel Gomez <[email protected]>
@dkruces dkruces force-pushed the dagomez/fix-guestfs-role-import-tasks branch from 625e294 to 7b43ac7 Compare July 1, 2025 14:00
@dkruces dkruces merged commit 4d8e504 into main Jul 1, 2025
8 checks passed
@dkruces dkruces deleted the dagomez/fix-guestfs-role-import-tasks branch July 2, 2025 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants