Skip to content

Commit

Permalink
use env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
sudo-shashank committed Mar 27, 2024
1 parent 5ebd15c commit 47630a4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions ansible/archival-snapshots/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@
ansible.builtin.shell:
cmd: "./init.sh"
chdir: "{{ remote_resources_path }}"
environment:
ARCHIVAL_SLACK_TOKEN: "{{ lookup('env', 'ARCHIVAL_SLACK_TOKEN') }}"
ENDPOINT: "{{ lookup('env', 'ENDPOINT') }}"
5 changes: 2 additions & 3 deletions ansible/archival-snapshots/resources/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
## Enable strict error handling, command tracing, and pipefail
set -euxo pipefail

ENDPOINT="$1"
FOREST_CLI="/home/archie/forest-v0.16.3/forest-cli"
FOREST_TOOL="/home/archie/forest-v0.16.3/forest-tool"

Expand All @@ -28,10 +27,10 @@ while ((LATEST_EPOCH - CURRENT_EPOCH > 30000)); do

# Generate and upload diff snapshots
./diff_script.sh "$CURRENT_EPOCH" "$CURRENT_SNAPSHOT" "$NEW_SNAPSHOT"
./upload_diff.sh "$CURRENT_EPOCH"
./upload_diff.sh "$ENDPOINT"

CURRENT_EPOCH=$NEW_EPOCH
done

# Send notification on slack
# Send notification on slack channel
ruby notify.rb "$CURRENT_EPOCH"
4 changes: 2 additions & 2 deletions ansible/archival-snapshots/resources/notify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

require 'slack-ruby-client'

CHANNEL = ENV.fetch('SLACK_CHANNEL')
SLACK_TOKEN = ENV.fetch('SLACK_TOKEN')
CHANNEL = '#forest-notifications'
SLACK_TOKEN = ENV.fetch('ARCHIVAL_SLACK_TOKEN')
EPOCH = ARGV[0]

client = Slack::Web::Client.new(token: SLACK_TOKEN)
Expand Down

0 comments on commit 47630a4

Please sign in to comment.