## [slack - Send Slack notifications][1]
~~~
- name: Send notification message via Slack
slack:
token: thetoken/generatedby/slack
msg: '{{ inventory_hostname }} completed'
delegate_to: localhost
- name: Send notification message via Slack all options
slack:
token: thetoken/generatedby/slack
msg: '{{ inventory_hostname }} completed'
channel: '#ansible'
username: 'Ansible on {{ inventory_hostname }}'
icon_url: http://www.example.com/some-image-file.png
link_names: 0
parse: 'none'
delegate_to: localhost
- name: insert a color bar in front of the message for visibility purposes and use the default webhook icon and name configured in Slack
slack:
token: thetoken/generatedby/slack
msg: '{{ inventory_hostname }} is alive!'
color: good
username: ''
icon_url: ''
- name: Use the attachments API
slack:
token: thetoken/generatedby/slack
attachments:
- text: Display my system load on host A and B
color: '#ff00dd'
title: System load
fields:
- title: System A
value: "load average: 0,74, 0,66, 0,63"
short: True
- title: System B
value: 'load average: 5,16, 4,64, 2,43'
short: True
- name: Send a message with a link using Slack markup
slack:
token: thetoken/generatedby/slack
msg: We sent this message using <https://www.ansible.com|Ansible>!
- name: Send a message with angle brackets and ampersands
slack:
token: thetoken/generatedby/slack
msg: This message has <brackets> & ampersands in plain text.
~~~
[1]:https://docs.ansible.com/ansible/latest/modules/slack_module.html#slack-module
- 目录
- ansible基础
- ansible简介
- ansible安装和测试
- ansible配置文件
- 常用命令
- yaml在ansible中的用法
- inventory
- 变量与facts
- when语句
- handler模块
- 大杂烩
- ansible模块
- assert 模块
- copy模块
- cron模块
- debug模块
- django_manage模块
- file模块
- filesystem模块
- git模块
- hostname模块
- lineinfile模块
- mount模块
- mysql_user模块
- mysql_db模块
- pip模块
- selinux
- setup模块
- shell 和 command 模块
- stat模块
- supervisorctl
- systemd
- timezone
- unarchive模块
- user模块
- wait_for
- yum和service模块
- 其他模块或者方法
- setup模块
- url模块
- slack 模块
- pause 模块
- 其他
- 报错处理
- playbooks
- 复杂的playbook
- 循环
- roles
- YAML
- jinja2