Referencing fact mid-text in when statement

11 views
Skip to first unread message

John Harmon

unread,
Apr 24, 2018, 6:02:29 PM4/24/18
to Ansible Project
I have seen other people attempting similar things, but what works for them in their scenarios doesn't seem to work for me.  I am sure it must be a syntax issue.  I have a similar when statement, but don't know how to correctly reference my fact within the string as seen below (tried these two, and various other iterations):
- name: Install Spacewalk Repos
  yum
:
    name
: "{{ item }}"
    state
: present
  with_items
:
   
- first-package-['ansible_distribution_major_version'].noarch.rpm
   
- second-package[ansible_distribution_major_version].noarch.rpm


John Harmon

unread,
Apr 24, 2018, 6:12:44 PM4/24/18
to Ansible Project
Figured it out:

- name: Install Spacewalk Repos
  yum
:
    name
: "{{ item }}"
    state
: present
  with_items
:
   
- "first-package-{{ ansible_distribution_major_version }}.noarch.rpm"
   
- "second-package{{ ansible_distribution_major_version }}.noarch.rpm"



Reply all
Reply to author
Forward
0 new messages