--- - name: Slack hosts: localhost gather_facts: false vars: playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\u0000',' ')).split() | select('match','^.*[.]ya?ml$') | list | first }}" tasks: - name: Send notification message via Slack community.general.slack: token: "{{ slack_token }}" msg: Starting {{ playbook_file }} - name: Stop AOS hosts: AOS gather_facts: false tasks: - block: - include: tasks/stop-aos.yaml rescue: - include: tasks/task-failed-slack.yaml - name: Slack hosts: localhost gather_facts: false tasks: - name: Send notification message via Slack community.general.slack: token: "{{ slack_token }}" msg: All done