...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
---
- 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
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
--- # tasks file for workhorse - name: update apt cache and install commonprerequisite packages apt: update_cache: yes name: - python3 become: yes - name: Download and build MercuryDPM block: - name: Install MercuryDPM dependencies apt: update_cache: yes name: - build-essential - g++ - gfortran - subversion - cmake - graphviz state: present become: yes - name: Copy MercuryDPM build script copy: src=build_mdpm.sh dest=/opt mode=0755 - name: Download and build MDPM command: bash /opt/build_mdpm.sh register: build_output - name: Print info debug: msg="{{build_output.stdout}}" - name: Print errors debug: msg="{{build_output.stderr}}" - name: Prepare script that builds and runs driver template: src: build_and_run_driver.sh.j2 dest: /opt/MercuryDPM/build_and_run_driver.sh mode: 0755 - name: Run that script # TODO https://stackoverflow.com/questions/39347379/ansible-run-command-on-remote-host-in-background shell: (nohup /opt/MercuryDPM/build_and_run_driver.sh </dev/null >/dev/null 2>&1 &) # command: bash /opt/MercuryDPM/build_and_run_driver.sh async: 10 poll: 0 |
...