From 6f093227c677793154558f1a10bb71b1fd0998c1 Mon Sep 17 00:00:00 2001 From: Jakeii Date: Sat, 13 Jun 2015 22:03:57 +0100 Subject: [PATCH] Learning Locker automation password for admin should be Tunapanda2 tasks/main.yml changes didn't commit? migrate after populating db --- playbooks/roles/learninglocker/tasks/main.yml | 23 ++++++++--------- .../backup/learninglocker/client.bson | Bin 0 -> 291 bytes .../learninglocker/client.metadata.json | 1 + .../backup/learninglocker/documentapi.bson | 0 .../learninglocker/documentapi.metadata.json | 1 + .../templates/backup/learninglocker/lrs.bson | Bin 0 -> 278 bytes .../backup/learninglocker/lrs.metadata.json | 1 + .../backup/learninglocker/migrations.bson | Bin 0 -> 614 bytes .../learninglocker/migrations.metadata.json | 1 + .../backup/learninglocker/oauth_clients.bson | Bin 0 -> 180 bytes .../oauth_clients.metadata.json | 1 + .../templates/backup/learninglocker/site.bson | Bin 0 -> 300 bytes .../backup/learninglocker/site.metadata.json | 1 + .../backup/learninglocker/statements.bson | 0 .../learninglocker/statements.metadata.json | 1 + .../backup/learninglocker/system.indexes.bson | Bin 0 -> 1729 bytes .../backup/learninglocker/user_tokens.bson | 0 .../learninglocker/user_tokens.metadata.json | 1 + .../backup/learninglocker/users.bson | Bin 0 -> 235 bytes .../backup/learninglocker/users.metadata.json | 1 + .../roles/learninglocker/templates/restore.js | 24 ++++++++++++++++++ scripts/update_ll_fields.js | 24 ++++++++++++++++++ 22 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/client.bson create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/client.metadata.json create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/documentapi.bson create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/documentapi.metadata.json create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/lrs.bson create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/lrs.metadata.json create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/migrations.bson create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/migrations.metadata.json create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/oauth_clients.bson create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/oauth_clients.metadata.json create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/site.bson create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/site.metadata.json create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/statements.bson create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/statements.metadata.json create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/system.indexes.bson create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/user_tokens.bson create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/user_tokens.metadata.json create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/users.bson create mode 100644 playbooks/roles/learninglocker/templates/backup/learninglocker/users.metadata.json create mode 100644 playbooks/roles/learninglocker/templates/restore.js create mode 100755 scripts/update_ll_fields.js diff --git a/playbooks/roles/learninglocker/tasks/main.yml b/playbooks/roles/learninglocker/tasks/main.yml index ddbc8a47..dd71c192 100644 --- a/playbooks/roles/learninglocker/tasks/main.yml +++ b/playbooks/roles/learninglocker/tasks/main.yml @@ -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( diff --git a/playbooks/roles/learninglocker/templates/backup/learninglocker/client.bson b/playbooks/roles/learninglocker/templates/backup/learninglocker/client.bson new file mode 100644 index 0000000000000000000000000000000000000000..dd91a34a18c27824b63f533a278e28952eab7e60 GIT binary patch literal 291 zcmXw#O-chn5QWQxAVEBUZe0l?-RZ7QS`hUBE=0wJi=n!!I}T=knCZa;ypIR)EFQx% zXeW?ey$>Gmqs|Th4vUiE`Sa%C`{?-k0`9)X)RwRYfRUrV^u>GFzVOU#@mW3uX6r7aS3opzfDoc{{=Bn$r zLMM3;5t*$wP6;PiM@vFzNd#jW(p%G&X#=^t53w%#l literal 0 HcmV?d00001 diff --git a/playbooks/roles/learninglocker/templates/backup/learninglocker/client.metadata.json b/playbooks/roles/learninglocker/templates/backup/learninglocker/client.metadata.json new file mode 100644 index 00000000..951ef638 --- /dev/null +++ b/playbooks/roles/learninglocker/templates/backup/learninglocker/client.metadata.json @@ -0,0 +1 @@ +{"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"learninglocker.client"}]} \ No newline at end of file diff --git a/playbooks/roles/learninglocker/templates/backup/learninglocker/documentapi.bson b/playbooks/roles/learninglocker/templates/backup/learninglocker/documentapi.bson new file mode 100644 index 00000000..e69de29b diff --git a/playbooks/roles/learninglocker/templates/backup/learninglocker/documentapi.metadata.json b/playbooks/roles/learninglocker/templates/backup/learninglocker/documentapi.metadata.json new file mode 100644 index 00000000..5fb9356f --- /dev/null +++ b/playbooks/roles/learninglocker/templates/backup/learninglocker/documentapi.metadata.json @@ -0,0 +1 @@ +{"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"learninglocker.documentapi"}]} \ No newline at end of file diff --git a/playbooks/roles/learninglocker/templates/backup/learninglocker/lrs.bson b/playbooks/roles/learninglocker/templates/backup/learninglocker/lrs.bson new file mode 100644 index 0000000000000000000000000000000000000000..24602bb0e3b44ffa5a655f9d65efe276fb14f914 GIT binary patch literal 278 zcmWe*WME*A&rD$mjlFqnGdHjQEC$C_OeL8mIjIb+3=9mx<%#JGOev|w$wiq3C7Jno z3~W$QMF!^l^1Rd{26dnS6UYcjAj8zuG$qBt#5l>=Aju%bB+W9>z`(>X(VT&SrL;J; zsF=api5S z8N?2DvZzhM$KzFILWn(Vt(e_>J$&vTd_Riwr`=_H=P9;*Cyx2P0I3kBSOQO_RE1KbitR-2$08XA$;8S*tD&;G~~iwb3>0CbYoyIUmhX+4rJGxA#^pCocAxd@nW z85AR#W*gVLj+SoZ=GuKv+@W2yS(yYi)e{Ws&R|cg*q~Xo*|p`W_(q`Mmov|3`M9(<5@eV|qFI>Rt;0GJ#D z!QrvpzoxUz5_ZoF+ra1a#f#B1R;ogePI@bA7Fw8wwAZT9s`QP)QW90QgMW8rjGTV0 zaatQGNf=UAX-h&mZ5%gJS`;YE%2(D&f-EwH$e50|7+^kbPbu~5q8NrD=ez6rmUFyx G1;7Vf?J`#Y literal 0 HcmV?d00001 diff --git a/playbooks/roles/learninglocker/templates/backup/learninglocker/oauth_clients.metadata.json b/playbooks/roles/learninglocker/templates/backup/learninglocker/oauth_clients.metadata.json new file mode 100644 index 00000000..44f0e93b --- /dev/null +++ b/playbooks/roles/learninglocker/templates/backup/learninglocker/oauth_clients.metadata.json @@ -0,0 +1 @@ +{"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"learninglocker.oauth_clients"}]} \ No newline at end of file diff --git a/playbooks/roles/learninglocker/templates/backup/learninglocker/site.bson b/playbooks/roles/learninglocker/templates/backup/learninglocker/site.bson new file mode 100644 index 0000000000000000000000000000000000000000..c4c9accd92e1204256cc361bb15117775a6b3448 GIT binary patch literal 300 zcmYk1F;2uV5Jf*`VOaqU1rj%)0A#d@fDW|V0tKW*(QG^fOIbUz9SW{MOT`K3IRsaL zLvROXlZMLU_pJHfM{B^ivy$I{D7wuAfv7!3=wjO!YQa;PrK#siu1JU8Y%n=Yn$p-uL9 jL0V_0bS7%jwMN>Qk`i8Dir;HlHW?cB?C0z4dByMtStw6= literal 0 HcmV?d00001 diff --git a/playbooks/roles/learninglocker/templates/backup/learninglocker/site.metadata.json b/playbooks/roles/learninglocker/templates/backup/learninglocker/site.metadata.json new file mode 100644 index 00000000..e2c1015d --- /dev/null +++ b/playbooks/roles/learninglocker/templates/backup/learninglocker/site.metadata.json @@ -0,0 +1 @@ +{"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"learninglocker.site"}]} \ No newline at end of file diff --git a/playbooks/roles/learninglocker/templates/backup/learninglocker/statements.bson b/playbooks/roles/learninglocker/templates/backup/learninglocker/statements.bson new file mode 100644 index 00000000..e69de29b diff --git a/playbooks/roles/learninglocker/templates/backup/learninglocker/statements.metadata.json b/playbooks/roles/learninglocker/templates/backup/learninglocker/statements.metadata.json new file mode 100644 index 00000000..3ece4480 --- /dev/null +++ b/playbooks/roles/learninglocker/templates/backup/learninglocker/statements.metadata.json @@ -0,0 +1 @@ +{"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"learninglocker.statements"}]} \ No newline at end of file diff --git a/playbooks/roles/learninglocker/templates/backup/learninglocker/system.indexes.bson b/playbooks/roles/learninglocker/templates/backup/learninglocker/system.indexes.bson new file mode 100644 index 0000000000000000000000000000000000000000..a82073c0ee332a25154c81d32e2b1e2d6420d6ff GIT binary patch literal 1729 zcmb_dOH0E*5FQmT9zqiP7yE6SE@?Kg zS@4vd&CEC7Jhw|kI}=*NXJaVdY1_z5_GdS=p72=EChl;>AZBz3Ard@IWHN|UI236R z%R$PuRQO8|#@+{S-^B|fDH2U|=Zm%LVr5bbqFZ02wu=;{2=Cq(XwL;2XTm@|`a&JK zP<<7SW8{jDBvIEFu%eWi=2{p;5PUA-nM$>gg}}B4F7g)H!U?~aX_HP}pA^BTFevuP zHDm|8Wi0~LdljJ$7L5t*-18Yu)-$sPY;Mq)&o^L-d^(W-;xiFxuY%1<4I880n9EOz z%gqWdJk$zP*i&!wsfBu;oO7J2k~6bl#-drZK7doq&IM#QJ6gs91&Bvw8nYQ+bO*C) z&3vnp?^EO3);Y)!yU5oS{^WtTak4t-3Zv7^-4`s2pDcVPuA!TlQAqB)xgD$`226Ics8Tsu-A@nT)Dh z7F7~GG~sa+#kfCS+#Zz+E@tCU`u6Jbyu0pdWVW9(wvxsL!xn>J#9!`v{qw!fjcnDu LVu8)Xt=Iv-rmji^ literal 0 HcmV?d00001 diff --git a/playbooks/roles/learninglocker/templates/backup/learninglocker/users.metadata.json b/playbooks/roles/learninglocker/templates/backup/learninglocker/users.metadata.json new file mode 100644 index 00000000..a01c2107 --- /dev/null +++ b/playbooks/roles/learninglocker/templates/backup/learninglocker/users.metadata.json @@ -0,0 +1 @@ +{"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"learninglocker.users"}]} \ No newline at end of file diff --git a/playbooks/roles/learninglocker/templates/restore.js b/playbooks/roles/learninglocker/templates/restore.js new file mode 100644 index 00000000..f3946e11 --- /dev/null +++ b/playbooks/roles/learninglocker/templates/restore.js @@ -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 }); \ No newline at end of file diff --git a/scripts/update_ll_fields.js b/scripts/update_ll_fields.js new file mode 100755 index 00000000..c69e4ed2 --- /dev/null +++ b/scripts/update_ll_fields.js @@ -0,0 +1,24 @@ +var db = db.getSiblingDB('learninglocker'); + +var updateAdmin = { + email: 'vagrant@swag.testing.tunapanda.org', + 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 }); \ No newline at end of file