--- - name: Slack hosts: localhost gather_facts: false vars: playbook_file: "{{ (lookup('file', '/proc/self/cmdline') | regex_replace('\0',' ')).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: Start AOS hosts: AOS gather_facts: false tasks: - block: - include: tasks/start-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