-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
set -ue | ||
|
||
## ansible-playbook is a wrapper script used to send a notification to slack | ||
# whenever a new ansible deploy is triggered | ||
|
||
ANSIBLE_SLACK_CMD=`printf "%q " "$0" "$@"` | ||
ANSIBLE_SLACK_CMD="${ANSIBLE_SLACK_CMD% }" # strip trailing whitespace | ||
export ANSIBLE_SLACK_CMD | ||
|
||
ansible localhost --module-name include_role --args name=notify-slack | ||
ansible-playbook "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
- name: "notify #ooni-bots at openobservatory.slack.com" | ||
slack: | ||
token: "{{ lookup('amazon.aws.aws_ssm', '/oonidevops/secrets/ansible_slack_token', profile='oonidevops_user_prod') }}" | ||
channel: "#ooni-bots" | ||
msg: "{{ lookup('template', 'notify-slack.j2') }}" | ||
delegate_to: localhost | ||
run_once: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% set cleanness = 'dirty' if lookup('pipe', 'git status -s') else 'clean' %} | ||
{% set head = lookup('pipe', 'git rev-parse HEAD') %} | ||
{% set head7 = lookup('pipe', 'git rev-parse --short HEAD') %} | ||
{% set branch = lookup('pipe', 'git describe --always --exact-match --all HEAD') | replace('heads/', '') %} | ||
{% set user_slug = lookup('pipe', 'whoami') + '@' + lookup('pipe', 'hostname') %} | ||
{% if lookup('file', '~/.ooni-sysadmin/user_slug', errors='ignore') %} | ||
{% set user_slug = lookup('file', '~/.ooni-sysadmin/user_slug') %} | ||
{% endif %} | ||
|
||
{{ user_slug }} runs `{{ lookup('env', 'ANSIBLE_SLACK_CMD') }}` on top of {{ cleanness }} `<https://github.com/ooni/sysadmin/commit/{{ head }}|{{ head7 }}>` (`{{ branch }}`) |