Re: [PATCH v2 26/37] Add an Ansible requirements.yml file

Chuck Lever <[email protected]>
Newsgroups dev.linux.lists.kdevops
Organization kernel.org
Message-ID <[email protected]>
On 9/2/25 4:06 PM, Daniel Gomez wrote:
> On 02/09/2025 15.54, Chuck Lever wrote:
>> From: Chuck Lever <[email protected]>
>>
>> Commit b90d89d27659 ("Switch to the cloud.terraform.terraform
>> module") introduced the use of the cloud.terraform module, and
>> commit 7ccb64834eeb ("guestfs: Replace scripts/destroy_guestfs.sh
>> with an Ansible playbook") introduced the use of the
>> community.libvirt module. It would be friendly if kdevops could
>> pull in the Ansible modules it needs transparently.
>>
>> The requirements.yml file is a manifest of Ansible collections that
>> the project needs to run. Installation of these collections is made
>> automatic by adding:
>>
>>   ansible-galaxy install -r requirements.yml
>>
>> to the "make ansible_cfg" step. This mechanism can keep cached
>> versions of collections up to date, and can also constrain a
>> cached collection to a specific version, if that's needed.
> 
> I don't see the link between the galaxy step and the ansible_cfg target in the
> changes below.

AIUI, just the requirements.yml file itself is not enough. The
"ansible-galaxy install" step is needed to actually do the install.

It's arguable whether the ansible_cfg target is the best place to
handle it, but that target is done quite early. Suggestions are
welcome!


> But in case we have it, I think this should be distro specific.
> Last time I checked, all these galaxy dependencies are provided in Debian by the
> ansible package. So it's not needed there.

On my systems, some of the packaged versions of the collections are
already installed anyway. But on some they are not.

It's better to not have to keep track of whether the distros provide
these or whether they are installed. We document the requirements in
requirements.yml, and the rest is handled automatically (and
declaratively).


>> The initial file contains requirements I could find easily, and
>> should be updated over time as new collection dependencies are
>> introduced.
>>
>> See also:
>>
>> https://docs.ansible.com/ansible/latest/user_guide/collections_using.html
>>
>> Reviewed-by: Luis Chamberlain <[email protected]>
>> Signed-off-by: Chuck Lever <[email protected]>
>> ---
>>  requirements.yml         | 8 ++++++++
>>  scripts/ansible.Makefile | 5 +++++
>>  2 files changed, 13 insertions(+)
>>  create mode 100644 requirements.yml
>>
>> diff --git a/requirements.yml b/requirements.yml
>> new file mode 100644
>> index 000000000000..a22691d3f86b
>> --- /dev/null
>> +++ b/requirements.yml
>> @@ -0,0 +1,8 @@
>> +---
>> +collections:
>> +  - name: ansible.posix
>> +  - name: ansible.utils
>> +  - name: cloud.terraform
>> +  - name: community.docker
>> +  - name: community.general
>> +  - name: community.libvirt
>> diff --git a/scripts/ansible.Makefile b/scripts/ansible.Makefile
>> index b0d2a8c12ee7..4efcf3e93b0e 100644
>> --- a/scripts/ansible.Makefile
>> +++ b/scripts/ansible.Makefile
>> @@ -2,3 +2,8 @@
>>  
>>  AV ?= 0
>>  export ANSIBLE_VERBOSE := $(shell scripts/validate_av.py --av "$(AV)")
>> +
>> +ansible-requirements:
>> +	@$(Q)ansible-galaxy install -r requirements.yml
> 
> Can you remove the "@"? That is controlled by the $(Q) var.

I copied that from elsewhere. It can be removed.


>> +PHONY += ansible-requirements
>> +DEFAULT_DEPS += ansible-requirements


-- 
Chuck Lever
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.