ansible slack模块的问题

时间:2016-10-18 16:14:41

标签: ansible ansible-playbook ansible-2.x

我正在尝试使用带有ansible 2.1的松弛模块。我创建了一个松弛的api令牌(今天重新创建它以进行测试)并在角色的任务中使用它。但是,当调用任务时,我会在下面复制错误:

- name: Send notification message via Slack all options
  local_action:
    module: slack
    token: "test-12121212121-12121212121-121212121-thiswasgeneratedtoday"
    msg: "{{ inventory_hostname }} completed"
    channel: "#valid-slack-channel-name"
    username: "valid-slack-user-name"
   # parse: 'none'

错误

fatal: [localhost -> localhost]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"attachments": null, "channel": "#slack-channel-test", "color": "normal", "domain": null, "icon_emoji": null, "icon_url": "http://www.ansible.com/favicon.ico", "link_names": 1, "msg": "localhost completed", "parse": null, "token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "username": "valid-user", "validate_certs": true}, "module_name": "slack"}, "msg": "Slack has updated its webhook API.  You need to specify a token of the form XXXX/YYYY/ZZZZ in your playbook"}

一旦我将域添加到任务中,我就会在下面复制错误:

"msg": " failed to send payload={\"username\": \"valid-slack-user-name\", \"text\": \"localhost completed\", \"link_names\": 1, \"channel\": \"#valid-slack-channel-name\", \"icon_url\": \"http://www.ansible.com/favicon.ico\"} to https://hooks.slack.com/services/[obscured]: HTTP Error 404: Not Found"

1 个答案:

答案 0 :(得分:1)

确保以正确的格式指定令牌 这在Ansible 2.1.2.0中适用于我:

httpResponseMessage.Content = new StreamContent(file);