openboxes / openboxes-devops

Infrastracture as Code artifacts for OpenBoxes.
3 stars 0 forks source link

Parameterize the archive_file variable in archive_db.yml #67

Open jmiranda opened 1 year ago

jmiranda commented 1 year ago

After following the instructions written by @awalkowiak to archive and restore a remote database, we realized that we should probably parameterize the source archive used in the restore_db.yml playbook.

Here are the instructions that Artur sent to me.

  1. Run this to pull db from obnav (this will download db archive to openboxes-devops/ansible/build/archive_db/:

    ansible-playbook -e @secrets/vault_rimu -i inventories/pih_rimu.yml dba/archive_db.yml -l dbprd
  2. Run this to upload the db pulled with command above:

    ansible-playbook -e @secrets/vault_rimu -i inventories/pih_rimu.yml dba/restore_db.yml -l obdev2 -e 'force=true'

Both commands will take a couple of minutes.

Optionals: If you'd like to pull db from other server than I put in the 1st command, then change the last param to be one of: dbprd, dbstg, obdev1-5

If you changed the db that you are pulling, then you have to go to the restore_db.yml and change this line: https://github.com/openboxes/openboxes-devops/blob/master/ansible/dba/restore_db.yml#L5 to look into proper directory (you have to change the hardcoded /dbprd/ part)

[restore_db.yml](https://github.com/openboxes/openboxes-devops/blob/master/ansible/dba/restore_db.yml)
    archive_file: ../build/archive_db/dbprd/openboxes.tgz
jmiranda commented 1 year ago

Now that I'm looking at the archive_db playbook, I realized the vars are set by default but Ansible allows you to pass a variable as an environment variable similar to the force argument below.

ansible-playbook -e @secrets/vault_rimu -i inventories/pih_rimu.yml dba/restore_db.yml -l obdev2 -e 'force=true,archive_file=../build/archive_db/obdev1/openboxes.tgz'

However, I feel like there could be an easier way of overriding the variable.