I have a problem when trying to invoke an include tasks with tags from handlers but when executing it, it does not take the tags and executes all the tasks of the playbook
services.yaml
- name: stop service
become: true
systemd:
name: httpd
state: stopped
tags: stop
- name: start service
become: true
systemd:
name: httpd
state: started
tags: start
main.yaml
- hosts: webservers
tasks:
- name: ask stop / start
pause:
prompt: "please type start or stop"
echo: yes
register: ask
changed_when: true
notify: service
tags: restarting
handlers:
- name: service
include_tasks: services.yaml
tags: "{{ ask.user_input }}"
execute
ansible-playbook main.yam -t restarting
When I run it launches all the tasks omitting the tag