Need help for ternary operator in ansible

16 views
Skip to first unread message

Rahul Kumar

unread,
Jun 24, 2020, 3:11:56 AM6/24/20
to ansible...@googlegroups.com
Hi Ansible Gurus ,
i have below task :
- name: RPM EPOCH Finder
    #command: rpm -qa --qf '%|EPOCH?{%{EPOCH}}:{0}|\n' {{ item.split('.')[0] | regex_replace('-\d+', '')}}
    command: rpm -qa --qf '%|EPOCH?{%{EPOCH}}:{0}|\n' {{ item.split('.')[0] | regex_replace('-\d+', '')}}
    with_items:
      - "{{ my_hotfix_rpms }}"
    register: r
    args:
      warn: false 
 I am trying to get a part of RPM name (Epoch) from rpm list in a system. If Epoch is present then it prints the value otherwise prints “0”. Since this package name can have any version , so I am using regex to fetch only the name from the variable.
But I am getting an error telling it is an incomplete Jinja template .Is it because of the ternary operator used?  Any idea ?

Regards
Rahul   

BIJAY PARIDA

unread,
Jun 25, 2020, 1:37:16 AM6/25/20
to Ansible Project
Try escaping the % character.

Thanks
Bijay
Reply all
Reply to author
Forward
0 new messages