Commit 028b14e8 by e0d

Merge pull request #1620 from edx/han/jenkins-certs

Using ansible instead of ssh for jenkins scripts
parents 3cea827e 304ddf59
#!/bin/bash
cd configuration
pip install -r requirements.txt
env
ip=$(python playbooks/ec2.py | jq -r '."tag_Name_prod-edge-worker"[0] | strings')
ssh="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
manage="cd /edx/app/edxapp/edx-platform && sudo -u www-data /edx/bin/python.edxapp ./manage.py"
echo "$username" > /tmp/username.txt
for x in $(cat /tmp/username.txt); do
$ssh ubuntu@"$ip" "$manage lms cert_whitelist -a $x -c $course_id --settings aws"
done
rm /tmp/username.txt
......@@ -4,14 +4,21 @@ cd configuration
pip install -r requirements.txt
env
ip=$(python playbooks/ec2.py | jq -r '."tag_Name_prod-edx-worker"[0] | strings')
ssh="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
manage="cd /edx/app/edxapp/edx-platform && sudo -u www-data /edx/bin/python.edxapp ./manage.py"
ansible="ansible first_in_tag_Name_${environment}-${deployment}-worker -i playbooks/ec2.py -u ubuntu -s -U www-data -a"
manage="/edx/bin/python.edxapp /edx/bin/manage.edxapp lms --settings aws cert_whitelist"
echo "$username" > /tmp/username.txt
for x in $(cat /tmp/username.txt); do
$ssh ubuntu@"$ip" "$manage lms cert_whitelist -a $x -c $course_id --settings aws"
done
if [ "$addremove" = "add" ]; then
for x in $(cat /tmp/username.txt); do
echo "Adding $x"
$ansible "$manage --add $x -c $course_id"
done
elif [ "$addremove" = "remove" ]; then
for x in $(cat /tmp/username.txt); do
echo "Removing $x"
$ansible "$manage --del $x -c $course_id"
done
fi
rm /tmp/username.txt
cd configuration
pip install -r requirements.txt
env
ansible="ansible first_in_tag_Name_${environment}-${deployment}-worker -i playbooks/ec2.py -u ubuntu -s -U www-data -a"
manage="/edx/bin/python.edxapp /edx/bin/manage.edxapp lms change_enrollment --settings aws"
if [ "$noop" = true ]; then
$ansible "$manage --noop --course $course --to $to --from $from"
else
$ansible "$manage --course $course --to $to --from $from"
fi
cd configuration
pip install -r requirements.txt
env
ip=$(python playbooks/ec2.py | jq -r '."tag_Name_prod-edge-worker"[0] | strings')
ssh="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
manage="cd /edx/app/edxapp/edx-platform && sudo -u www-data /edx/bin/python.edxapp ./manage.py lms change_enrollment"
if [ $"noop" ]; then
if [ ! -z "$username" ]; then
$ssh ubuntu@"$ip" "$manage --noop --course $course --user $name --to $to --from $from --settings aws"
else
$ssh ubuntu@"$ip" "$manage --noop --course $course --to $to --from $from --settings aws"
fi
elif [ ! -z "$username" ]; then
$ssh ubuntu@"$ip" "$manage --course $course --user $name --to $to --from $from --settings aws"
else
$ssh ubuntu@"$ip" "$manage --course $course --to $to --from $from --settings aws"
fi
fi
......@@ -2,27 +2,11 @@ cd configuration
pip install -r requirements.txt
env
stageip=$(python playbooks/ec2.py | jq -r '."tag_Name_stage-edx-worker"[0] | strings')
prodip=$(python playbooks/ec2.py | jq -r '."tag_Name_prod-edx-worker"[0] | strings')
ansible="ansible first_in_tag_Name_${environment}-${deployment}-worker -i playbooks/ec2.py -u ubuntu -s -U www-data -a"
manage="/edx/bin/python.edxapp /edx/bin/manage.edxapp lms change_enrollment --settings aws"
if [ "$cluster" = "prod" ]; then
ip=$stageip
if [ "$noop" = true ]; then
$ansible "$manage --noop --course $course --user $name --to $to --from $from"
else
ip=$prodip
fi
ssh="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
manage="cd /edx/app/edxapp/edx-platform && sudo -u www-data /edx/bin/python.edxapp ./manage.py lms change_enrollment"
if [ $"noop" ]; then
if [ ! -z "$username" ]; then
$ssh ubuntu@"$ip" "$manage --noop --course $course --user $name --to $to --from $from --settings aws"
else
$ssh ubuntu@"$ip" "$manage --noop --course $course --to $to --from $from --settings aws"
fi
elif [ ! -z "$username" ]; then
$ssh ubuntu@"$ip" "$manage --course $course --user $name --to $to --from $from --settings aws"
else
$ssh ubuntu@"$ip" "$manage --course $course --to $to --from $from --settings aws"
fi
$ansible "$manage --course $course --user $name --to $to --from $from"
fi
#!/bin/bash
cd configuration
pip install -r requirements.txt
env
ip=$(python playbooks/ec2.py | jq -r '."tag_Name_prod-edge-worker"[0] | strings')
ssh="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
manage="cd /edx/app/edxapp/edx-platform && sudo -u www-data /edx/bin/python.edxapp ./manage.py"
if [ "$service_variant" != "UNSET" ]; then
manage="$manage $service_variant"
fi
if [ "$help" = "true" ]; then
manage="$manage help"
fi
$ssh ubuntu@"$ip" "$manage $command $options --settings aws"
......@@ -4,25 +4,15 @@ cd configuration
pip install -r requirements.txt
env
stageip=$(python playbooks/ec2.py | jq -r '."tag_Name_stage-edx-worker"[0] | strings')
prodip=$(python playbooks/ec2.py | jq -r '."tag_Name_prod-edx-worker"[0] | strings')
if [ "$cluster" = "prod" ]; then
ip=$stageip
else
ip=$prodip
fi
ssh="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
manage="cd /edx/app/edxapp/edx-platform && sudo -u www-data /edx/bin/python.edxapp ./manage.py"
ansible="ansible first_in_tag_Name_${environment}-${deployment}-worker -i playbooks/ec2.py -u ubuntu -s -U www-data -a"
manage="/edx/bin/python.edxapp ./manage.py chdir=/edx/app/edxapp/edx-platform"
if [ "$service_variant" != "UNSET" ]; then
manage="$manage $service_variant"
manage="$manage $service_variant --settings aws"
fi
if [ "$help" = "true" ]; then
manage="$manage help"
fi
$ssh ubuntu@"$ip" "$manage $command $options --settings aws"
$ansible "$manage $command $options --settings aws"
......@@ -4,17 +4,16 @@ cd configuration
pip install -r requirements.txt
env
ip=$(python playbooks/ec2.py | jq -r '."tag_Name_prod-edx-worker"[0] | strings')
ssh="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
manage="cd /edx/app/edxapp/edx-platform && sudo -u www-data /edx/bin/python.edxapp ./manage.py"
ansible="ansible first_in_tag_Name_${environment}-${deployment}-worker -i playbooks/ec2.py -u ubuntu -s -U www-data -m shell -a"
manage="/edx/bin/python.edxapp /edx/bin/manage.edxapp lms --settings aws"
if [ "$report" = "true" ]; then
$ssh ubuntu@"$ip" "$manage lms gen_cert_report -c $course_id --settings aws"
$ansible "$manage gen_cert_report -c $course_id" | grep -A2 "Looking up certificate states for" | sed 's/rm:.*//'
elif [ "$regenerate" = "true" ] ; then
$ssh ubuntu@"$ip" "$manage lms regenerate_user -c $course_id -u $username --settings aws"
$ansible "$manage regenerate_user -c $course_id -u $username"
else
$ssh ubuntu@"$ip" "$manage lms ungenerated_certs -c $course_id --settings aws"
$ansible "$manage ungenerated_certs -c $course_id && $manage gen_cert_report -c $course_id" | grep -A2 "Looking up certificate states for" | sed 's/rm:.*//'
if [ "$force_certificate_state" ]; then
$ssh ubuntu@"$ip" "$manage lms ungenerated_certs -c $course_id -f $force_certificate_state --settings aws"
$ansible "$manage ungenerated_certs -c $course_id $force_certificate_state && $manage gen_cert_report -c $course_id" | grep -A2 "Looking up certificate states for" | sed 's/rm:.*//'
fi
fi
#!/bin/bash
cd configuration
pip install -r requirements.txt
env
ip=$(python playbooks/ec2.py | jq -r '."tag_Name_prod-edge-worker"[0] | strings')
ssh="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
manage="cd /edx/app/edxapp/edx-platform && sudo -u www-data /edx/bin/python.edxapp ./manage.py"
if [ "$report" = "true" ]; then
$ssh ubuntu@"$ip" "$manage lms gen_cert_report -c $course_id --settings aws"
elif [ "$regenerate" = "true" ] ; then
$ssh ubuntu@"$ip" "$manage lms regenerate_user -c $course_id -u $username --settings aws"
else
$ssh ubuntu@"$ip" "$manage lms ungenerated_certs -c $course_id --settings aws"
if [ "$force_certificate_state" ]; then
$ssh ubuntu@"$ip" "$manage lms ungenerated_certs -c $course_id -f $force_certificate_state --settings aws"
fi
fi
#!/bin/bash
cd configuration
pip install -r requirements.txt
env
command="/edx/bin/supervisorctl restart xqueue"
ansible tag_Name_${environment}-${deployment}-commoncluster -i playbooks/ec2.py -u ubuntu -s -a "$command"
#!/bin/bash
cd configuration
pip install -r requirements.txt
env
command="/edx/bin/supervisorctl restart xqueue_consumer"
ansible tag_Name_${environment}-${deployment}-commoncluster -i playbooks/ec2.py -u ubuntu -s -a "$command"
#!/bin/bash
cd configuration
pip install -r requirements.txt
env
command="/edx/app/xqwatcher/venvs/supervisor/bin/supervisorctl -c /edx/app/xqwatcher/supervisor/supervisord.conf restart xqwatcher"
ansible tag_Name_${environment}-${deployment}-xqwatcher -i playbooks/ec2.py -u ubuntu -s -a "$command"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment