Skip to content

Commit

Permalink
Learning Locker automation
Browse files Browse the repository at this point in the history
password for admin should be Tunapanda2

tasks/main.yml changes didn't commit?

migrate after populating db
  • Loading branch information
Jakeii committed Jun 14, 2015
1 parent d7cc5fe commit 6f09322
Show file tree
Hide file tree
Showing 22 changed files with 68 additions and 12 deletions.
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"}]}
Empty file.
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"}]}
Empty file.
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.
Empty file.
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 });

0 comments on commit 6f09322

Please sign in to comment.