I want to start multiple service on playbook, but I want to remove end of service string like : a.service => a b.service => b
because I cannot use service a.service start, but I have to use service a start
because variable item is stored in default/main.yml role playbook like that :
name_services:
- a.service
- b.service
on main.yml
- name: start multiple service
service:
name: "{{ item }}"
state: started
with_items: "{{ name_services }}"
Use the filter splitext
- name: start multiple service
service:
name: "{{ item | splitext | first }}"
state: started
with_items: "{{ name_services }}"