--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b52e8df2-34bf-4807-b68b-e54cf6386390n%40googlegroups.com.
[utoddl@tango ansible]$ cat select-artifact.yml
---
- name: Select artifact based on value
hosts: localhost
gather_facts: false
tasks:
- name: Match an artifact based on a value
ansible.builtin.debug:
msg: "Value {{ item }} matches artifact {{ artifacts[item] | default('!missing!') }}."
vars:
artifacts:
green: cucumbers
red: tomatoes
purple: cabage
yellow: squash
loop:
- red
- orange
- yellow
- green
- blue
- indigo
- violet
[utoddl@tango ansible]$ ansible-playbook select-artifact.yml
PLAY [Select artifact based on value] *********************************************************
TASK [Match an artifact based on a value] *****************************************************
ok: [localhost] => (item=red) => {
"msg": "Value red matches artifact tomatoes."
}
ok: [localhost] => (item=orange) => {
"msg": "Value orange matches artifact !missing!."
}
ok: [localhost] => (item=yellow) => {
"msg": "Value yellow matches artifact squash."
}
ok: [localhost] => (item=green) => {
"msg": "Value green matches artifact cucumbers."
}
ok: [localhost] => (item=blue) => {
"msg": "Value blue matches artifact !missing!."
}
ok: [localhost] => (item=indigo) => {
"msg": "Value indigo matches artifact !missing!."
}
ok: [localhost] => (item=violet) => {
"msg": "Value violet matches artifact !missing!."
}
PLAY RECAP ************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Cheers,--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2927e3e7-9dae-26e1-d51c-e42a3acd6607%40gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9B6013A3-11F0-4D69-B9E6-56BAEC15EA40%40nist.gov.
- name: validate filename lookup valueassert:that:- my_var in file_table.keys()fail_msg: "File lookup key '{{ my_var }}' is not valid"
success_msg: "File lookup key '{{ my_var }}' is valid"
- name: do my file-based taskdebug:
msg: "File name is {{file_table[my_var] }}"
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8EAC318D-AF10-40AE-8787-0710A5BD552F%40nist.gov.