Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
Automate installation and compilation of Lotus
Browse files Browse the repository at this point in the history
An inventory file listing the IP addresses of the machines
is NOT part of the repository. It must be created separately
and passed to ansible-playbook as an argument.
  • Loading branch information
matejpavlovic committed Nov 4, 2022
1 parent e3f30f8 commit a887cb2
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 0 deletions.
10 changes: 10 additions & 0 deletions deployment/custom-script.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Run custom script
hosts: all
gather_facts: False
become: False
tasks:
- name: "Run custom script"
ansible.builtin.script:
cmd: scripts/custom.sh
...
15 changes: 15 additions & 0 deletions deployment/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SSH key for ansible to use when logging in the remote machines.
ansible_ssh_private_key_file: ~/.ssh/spacenet-ec2-key # Meaningless example value. Set to your own ssh key location.

# Git repository to obtain the Lotus code from.
git_repo: https://github.com/consensus-shipyard/lotus.git

# Version of the code to check out from the Mir repository at setup. This can be a branch name, a commit hash, etc...
git_version: "adlrocha/mir-sync" # Meaningless example value. Set to desired code version to check out from Git.

# Username to use when logging in the remote machines.
ansible_user: ubuntu # Example value (default on EC2 Ubuntu virtual machines)

# Other variables Ansible might use, probably no need to touch those...
ansible_ssh_common_args: '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'
host_count: "{{ groups['all'] | length }}"
3 changes: 3 additions & 0 deletions deployment/scripts/custom.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

# Write any ad-hoc script here and run it using the custom-script.yaml playbook
70 changes: 70 additions & 0 deletions deployment/setup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
- name: Initialize Mir benchmark VM
hosts: all
gather_facts: False
become: False
environment:
PATH: "{{ ansible_env.PATH }}:/home/{{ ansible_user }}/go/bin"
tasks:
- name: "Install Go"
become: True
community.general.snap:
name:
- go
classic: True
channel: 1.18/stable
state: present
- name: "Install snaps"
become: True
community.general.snap:
name:
- tmux
classic: True
state: present
- name: "Run apt update"
become: True
ansible.builtin.apt:
update_cache: True
- name: "Install apt packages"
become: True
ansible.builtin.apt:
name:
- mesa-opencl-icd
- ocl-icd-opencl-dev
- gcc
- git
- bzr
- jq
- pkg-config
- curl
- clang
- build-essential
- hwloc
- libhwloc-dev
- wget
- make
state: present
- name: "Run apt upgrade"
become: True
ansible.builtin.apt:
upgrade: yes
- name: Clone Lotus repo from GitHub
ansible.builtin.git:
repo: "{{ git_repo }}"
dest: ~/lotus
- name: "Check out the selected code version: {{ git_version }}"
ansible.builtin.git:
repo: "{{ git_repo }}"
dest: ~/lotus
single_branch: True
version: "{{ git_version }}"
force: True
- name: compile spacenet code
make:
chdir: ~/lotus
target: spacenet
- name: "Run setup script"
ansible.builtin.script:
# Single quotes are important here (https://github.com/ansible/ansible/issues/44897)
cmd: scripts/setup.sh
...
9 changes: 9 additions & 0 deletions deployment/stop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Stop all nodes
hosts: all
gather_facts: False
become: False
tasks:
- name: "Kill tmux servers"
ansible.builtin.shell: "tmux kill-server"
...

0 comments on commit a887cb2

Please sign in to comment.