с Миллером(https://github.com/johnkerl/miller/releases)
mlr --nidx --fs " " join -j 1 -f file2 file2
у вас есть
a 1
a 1
b 2
c 3
c 3
c 3
d 4
d 4
Я бы предложил использовать loop
вместо того, чтобы создавать шаблоны плейбуков.
---
- name: Firewalld check
hosts: localhost
become: yes
vars:
source:
- 172.16.2.114
- 172.16.2.115
tasks:
- name: Allow ICMP traffic
firewalld:
rich_rule: rule family='ipv4' source address="{{ item }}" protocol value="icmp" accept
permanent: no
state: enabled
loop: "{{ source }}"