Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
configuration
Commits
1d1a03a7
Commit
1d1a03a7
authored
Mar 27, 2014
by
Han Su Kim
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #932 from edx/han/sendlogstos3
Cleaning up dollar vars
parents
50fee8ef
e51bfcdd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
12 deletions
+7
-12
playbooks/roles/aws/templates/send-logs-to-s3.j2
+7
-12
No files found.
playbooks/roles/aws/templates/send-logs-to-s3.j2
View file @
1d1a03a7
...
...
@@ -10,12 +10,7 @@ if (( $EUID != 0 )); then
exit 1
fi
S3_LOGFILE="{{ aws_s3_logfile }}"
NOTIFY_EMAIL={{ AWS_S3_LOGS_NOTIFY_EMAIL }}
FROM_EMAIL={{ AWS_S3_LOGS_FROM_EMAIL }}
AWS_CMD={{ aws_cmd }}
exec > >(tee $S3_LOGFILE)
exec > >(tee "{{ aws_s3_logfile }}")
exec 2>&1
shopt -s extglob
...
...
@@ -57,7 +52,7 @@ done
# bucket
# If there are any errors from this point
# send mail to
$NOTIFY_EMAIL
# send mail to
{{ AWS_S3_LOGS_NOTIFY_EMAIL }}
set -e
...
...
@@ -68,16 +63,16 @@ s3_path=unset
onerror() {
if [[ -z $noop ]]; then
message_file=/var/tmp/message-$$.json
message_string="Error syncing $s3_path: inst_id=$instance_id ip=$ip region=
$region
"
if [[ -r
$S3_LOGFILE
]]; then
python -c "import json; d={'Subject':{'Data':'$message_string'},'Body':{'Text':{'Data':open('
$S3_LOGFILE
').read()}}};print json.dumps(d)" > $message_file
message_string="Error syncing $s3_path: inst_id=$instance_id ip=$ip region=
{{ region }}
"
if [[ -r
"{{ aws_s3_logfile }}"
]]; then
python -c "import json; d={'Subject':{'Data':'$message_string'},'Body':{'Text':{'Data':open('
"{{ aws_s3_logfile }}"
').read()}}};print json.dumps(d)" > $message_file
else
cat << EOF > $message_file
{"Subject": { "Data": "$message_string" }, "Body": { "Text": { "Data": "!! ERROR !! no logfile" } } }
EOF
fi
echo "ERROR: syncing $s3_path on $instance_id"
$AWS_CMD ses send-email --from $FROM_EMAIL --to $NOTIFY_EMAIL --message file://$message_file --region $region
{{ aws_cmd }} ses send-email --from {{ AWS_S3_LOGS_FROM_EMAIL }} --to {{ AWS_S3_LOGS_NOTIFY_EMAIL }} --message file://$message_file --region {{ region }}
else
echo "Error syncing $s3_path on $instance_id"
fi
...
...
@@ -95,5 +90,5 @@ region=${availability_zone:0:${{lb}}#availability_zone{{rb}} - 1}
s3_path="${2}/$sec_grp/"
{% for item in AWS_S3_LOG_PATHS -%}
$noop
$AWS_CMD
sync {{ item['path'] }} "s3://{{ item['bucket'] }}/$sec_grp/${instance_id}-${ip}/"
$noop
{{ aws_cmd }}
sync {{ item['path'] }} "s3://{{ item['bucket'] }}/$sec_grp/${instance_id}-${ip}/"
{% endfor %}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment