File tree 3 files changed +23
-19
lines changed
3 files changed +23
-19
lines changed Original file line number Diff line number Diff line change @@ -72,17 +72,17 @@ deploy_after:
72
72
- " {{ playbook_dir }}/vendor/roles/slack-notify/tasks/deploy_success.yml"
73
73
` ` `
74
74
75
- Add your Slack webhook token (end of the webhook URL) and channel into ` group_vars/all/main .yml`
75
+ Add your Slack webhook token(s) (end of the webhook URL) and channel into ` group_vars/{environment}/vault .yml`
76
76
77
77
` ` ` yaml
78
- # group_vars/all/main .yml
79
- slack_notifications :
80
- - name: Organisation1
81
- token: XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXX
82
- channel: "#site-status"
83
- - name: Organisation2
84
- token: XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXX
85
- channel: "#deployments"
78
+ # group_vars/{environment}/vault .yml
79
+ vault_wordpress_sites :
80
+ example.com.au:
81
+ slack_deploy_token:
82
+ - XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXX
83
+ - XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXX
84
+ env:
85
+ ...
86
86
` ` `
87
87
88
88
# # Usage
@@ -98,6 +98,8 @@ slack_notifications:
98
98
3. Setup a Webhook for your desired Workspace
99
99
4. Copy the Webhook URL for use in [Installation](#installation)
100
100
101
+ Note : Each Webhook can only post to one channel since Slack changed their API. You will need to set up a webhook per channel you wish to notify.
102
+
101
103
# # See Also
102
104
103
105
- [Incoming WebHooks for Slack](https://get.slack.help/hc/en-us/articles/115005265063-Incoming-webhooks-for-Slack)
Original file line number Diff line number Diff line change 1
1
---
2
2
- name : Send initial deployment notification to Slack
3
3
slack :
4
- token : " {{ item.token }}"
5
- channel : " {{ item.channel }}"
4
+ token : " {{ slack_deploy_token }}"
6
5
attachments :
7
6
- text : " *{{ lookup('pipe', 'git config user.name') }}* has started deploying {{ site }} to *<https://{{ project.site_hosts | map(attribute='canonical') | first }}|{{ env }}>*"
8
7
color : warning
9
- loop : " {{ slack_notifications }}"
8
+ with_items : " {{ vault_wordpress_sites[site].slack_deploy_token }}"
9
+ loop_control :
10
+ loop_var : slack_deploy_token
10
11
when :
11
- - slack_notifications is defined
12
- - slack_notifications | length > 0
12
+ - vault_wordpress_sites[site].slack_deploy_token is defined
13
+ - vault_wordpress_sites[site].slack_deploy_token | length > 0
13
14
delegate_to : localhost
14
15
ignore_errors : yes
Original file line number Diff line number Diff line change 15
15
16
16
- name : Send successful deployment notification to Slack
17
17
slack :
18
- token : " {{ item.token }}"
19
- channel : " {{ item.channel }}"
18
+ token : " {{ slack_deploy_token }}"
20
19
attachments :
21
20
- text : " *{{ git_username }}* successfully deployed {{ site }} to *<{{ target_env_url }}>* {% if using_github %} [<{{ github_commit_url }}|deployed commit>] {% else %} [{{ git_clone.after }}] {% endif %}"
22
21
color : good
23
- loop : " {{ slack_notifications }}"
22
+ with_items : " {{ vault_wordpress_sites[site].slack_deploy_token }}"
23
+ loop_control :
24
+ loop_var : slack_deploy_token
24
25
when :
25
- - slack_notifications is defined
26
- - slack_notifications | length > 0
26
+ - vault_wordpress_sites[site].slack_deploy_token is defined
27
+ - vault_wordpress_sites[site].slack_deploy_token | length > 0
27
28
delegate_to : localhost
28
29
ignore_errors : yes
You can’t perform that action at this time.
0 commit comments