Need help for ternary operator in ansible

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

Try escaping the % character.

Thanks
Bijay