Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Learning Locker automation #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions playbooks/roles/learninglocker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,23 @@
dest={{learninglocker__root}}/app/config/local/database.php
register: db_setup

- name: Populate database tables
shell: mongorestore -d {{learninglocker__active_db}} {{provision__base_dir}}/provision/playbooks/roles/learninglocker/templates/backup/learninglocker/

- name: Copy field update script
template:
src=restore.js
dest={{provision__base_dir}}/provision/scripts/update_ll_fields.js

- name: update LL fields
shell: mongo {{provision__base_dir}}/provision/scripts/update_ll_fields.js

- name: Perform DB migrations
command: php artisan migrate
args:
chdir: "{{learninglocker__root}}"
when: db_setup.changed

- name: Populate database tables
template: >
validate="mongoimport -d {{learninglocker__active_db}} -c {{item}} --upsert --file %s"
src="collections/{{item}}.json"
dest="/dev/null"
with_items:
- migrations
- oauth_scopes
- site
- user_tokens
- users

#- name: Create LL users
# shell: >
# php -r "print 'db.users.update(
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"learninglocker.client"}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"learninglocker.documentapi"}]}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"learninglocker.lrs"}]}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"learninglocker.migrations"}]}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"learninglocker.oauth_clients"}]}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"learninglocker.site"}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"learninglocker.statements"}]}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"learninglocker.user_tokens"}]}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"learninglocker.users"}]}
24 changes: 24 additions & 0 deletions playbooks/roles/learninglocker/templates/restore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var db = db.getSiblingDB('learninglocker');

var updateAdmin = {
email: '{{learninglocker__admin_email}}',
name: '{{learninglocker__admin_user}}'
};

var updateClient = {
'api.basic_key': '{{learninglocker__xapi_user}}',
'api.basic_secret': '{{learninglocker__xapi_pass}}',
};

var updateLRS = {
title: '{{learninglocker__lrs_name}}',
description: '{{learninglocker__lrs_description}}',
'users.0.email': updateAdmin.email,
'users.0.name': updateAdmin.name
};

db.users.update({ _id: ObjectId("555dd843b30b0d4f9a0041a7") }, { $set: updateAdmin });

db.client.update({_id: ObjectId("557c3f51b30b0d3d2c0041a7") }, { $set: updateClient });

db.lrs.update({ _id : ObjectId("555dd9c6b30b0d4f9a0041aa") }, { $set: updateLRS });
24 changes: 24 additions & 0 deletions scripts/update_ll_fields.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var db = db.getSiblingDB('learninglocker');

var updateAdmin = {
email: '[email protected]',
name: 'vagrant'
};

var updateClient = {
'api.basic_key': 'caae95f54d6545c76fc289f02a3c1d51c455f7e6',
'api.basic_secret': '40cb0287f95189298729f6ccc36f6277840604ad',
};

var updateLRS = {
title: 'Swag',
description: 'Swag!',
'users.0.email': updateAdmin.email,
'users.0.name': updateAdmin.name
};

db.users.update({ _id: ObjectId("555dd843b30b0d4f9a0041a7") }, { $set: updateAdmin });

db.client.update({_id: ObjectId("557c3f51b30b0d3d2c0041a7") }, { $set: updateClient });

db.lrs.update({ _id : ObjectId("555dd9c6b30b0d4f9a0041aa") }, { $set: updateLRS });