Hi,
On Wed, Jun 22, 2022 at 12:56 PM Miro Hrončok <mhroncok(a)redhat.com> wrote:
Hello,
please bare with me because my Ansible skills are close to none. I only use it
for Fedora CI.
I've read
https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.ht...
I have this (simplified) tests.yml:
---
- hosts: localhost
roles:
- role: standard-test-basic
tests:
- smoke:
dir: python/smoke
run: VERSION=3.11 ./venv.sh
required_packages:
- python3.11
- python3.11-devel
Full version in
https://src.fedoraproject.org/rpms/python3.11/blob/rawhide/f/tests/tests.yml
I would like to replace all occurrences of 3.11 with a variable:
---
- hosts: localhost
roles:
- role: standard-test-basic
tests:
- smoke:
dir: python/smoke
run: VERSION={{ pybasever }} ./venv.sh
required_packages:
- python{{ pybasever }}
- python{{ pybasever }}-devel
But where do I put pybasever: '3.11' exactly?
Vars can be defined on the same level as roles and hosts:
- hosts: localhost
vars:
pybasever: 3.11
roles:
- role: standard-test-basic
...
Bonus question: Can I read the tested package name and regex it into
the variable?
pybasever: {{ xxx_package_name|pex_regex_replace('^python', '') }}
I would need to dig more for this one.
The easiest way is to make a test run with a test just printing all
ENV variables, and checking if you can find the variable with the
right data in the log.
My uneducated guess would be that
"{{ lookup('env', 'TEST_SUBJECTS') }}"
will provide the data. And then some more Ansible filter magic needed
to get the substring from it.
For example, with split
https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html...
Or with regex_search,
https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html...
Thanks,
--
Miro Hrončok
--
Phone: +420777974800
IRC: mhroncok
_______________________________________________
CI mailing list -- ci(a)lists.fedoraproject.org
To unsubscribe send an email to ci-leave(a)lists.fedoraproject.org
Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedoraproject.org/archives/list/ci@lists.fedoraproject.org
Do not reply to spam on the list, report it:
https://pagure.io/fedora-infrastructure
--
Aleksandra Fedorova
bookwar