--- - 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: Get epoch timestamp shell: date +%s register: timestamp - name: Grab config - all servers hosts: ServersWithConfigs gather_facts: false vars: epoch: "{{ hostvars['localhost']['timestamp'].stdout }}" tasks: - block: - include: tasks/grab-config.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