This is useful if you want to automate deployment and running of MDPM on remote environments. In this example, I'll be controlling a remote machine called 'albatross', a Raspberry Pi with username 'pi'. I'll be building a driver and running it doing all the parameterisations through Ansible.
Preparation
Setting up inventory
Create a file called hosts
and put in it the IP address of the remote machine:
[albatross] 192.168.1.108 # the IP address of the remote machine
When you have created a playbook, you have to specify using this hosts file by running ansible-playbook -i hosts playbook.yaml
.
Setting up connection credentials
On the remote system, add your SSH public key to ~/.ssh/authorized_keys
.
Playbook
In your base directory, create the file playbook.yml
:
--- - name: Mount S3 storage hosts: albatross remote_user: pi become: no gather_facts: no vars_files: - vars.yml roles: - role: mountstorage - name: Build and run MercuryDPM hosts: albatross remote_user: pi become: no # FIXME Do we have to run everything as root? gather_facts: no vars_files: - vars.yml roles: - role: workhorse
In this example, we shall give albatross
two roles. First, it should mount storage, e.g. an S3 bucket. Next, it should download MercuryDPM, build our driver, and run it.
Mounting storage
If you're storing on a local disc, nothing needs to be done here. If you want to store on a Google Drive, an S3 bucket or a remote filer, then you will need to have a role for mountstorage
.
Create a file at mountstorage/tasks/main.yml
and put the following in it:
(TODO)
Tasks for the workhorse
role
Create a file at workhorse/tasks/main.yml
(relative to your base directory) and put the following in it.:
workhorse/files/build_mdpm.sh
: Download MercuryDPM and build MercuryBase
This script downloads MercuryDPM and builds MercuryBase.
workhorse/templates/build_and_run_driver.sh.j2
: Build and run your driver
#!/bin/bash set -eux DPMDIR=/opt/MercuryDPM SIMDIR=/mnt/s3gf/{{series}}/{{simulation}} DRIVER_DIR=$DPMDIR/MercuryBuild/Drivers/{{driver_dir}} DRIVER_PATH=$DRIVER_DIR/{{driver}} cd $DRIVER_DIR make {{driver}} mkdir -p $SIMDIR cd $SIMDIR $DRIVER_PATH {{flags}}