Commit 4446f0b3 authored by Antonis Kalou's avatar Antonis Kalou

Add a basic playbook for creating elixir releases

parent 942c3503
# MoodleNet Deployment
Ansible playbooks for deploying MoodleNet to Eummena servers.
## Quickstart
Below, we run the ansible playbook on a local vagrant machine. This can be set up by using
`vagrant up` in the local directory, check the `Vagrantfile` for more details.
*Note:* Currently only the backend is working.
```bash
$ ansible-playbook -i inventory/vagrant playbook/backend.yml
```
## Contributing
Only one note here, **never ever commit secrets to git!!1!**, use Ansible vault (or similar) instead.
[Unit]
Description=MoodleNet Backend
After=network.target
[Service]
Type=simple
User=moodle
WorkingDirectory=/home/moodle
ExecStart=/opt/moodle_net/bin/moodle_net start
ExecStop=/opt/moodle_net/bin/moodle_net stop
ExecReload=/opt/moodle_net/bin/moodle_net restart
Restart=on-failure
[Install]
WantedBy=default.target
\ No newline at end of file
[backend]
vagrant ansible_host=192.168.33.10 ansible_user=vagrant ansible_ssh_private_key_file=.vagrant/machines/default/virtualbox/private_key
\ No newline at end of file
---
- hosts: backend
tasks:
- name: update packages
apt:
update_cache: yes
upgrade: safe
become: yes
- name: install essential build tools
apt:
name: build-essential
state: latest
become: yes
- name: create moodle user
user:
name: moodle
createhome: yes
become: yes
# FIXME: better if we download releases from CI rather than building it here!
############################################################
# This section is temporary
############################################################
- name: install erlang solutions repo
apt:
deb: https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
- name: install erlang and elixir
apt:
name: ['git', 'esl-erlang', 'elixir']
state: latest
become: yes
- name: clone git repo
git:
repo: https://gitlab.com/moodlenet/servers/federated
dest: "{{ ansible_user_dir }}/moodle_net/backend"
clone: yes
- name: build elixir release
shell: mix do local.hex --force, local.rebar --force, deps.get, deps.compile, release --overwrite
args:
chdir: "{{ ansible_user_dir }}/moodle_net/backend"
environment:
- MIX_ENV: prod
############################################################
- name: deploy release
copy:
src: "{{ ansible_user_dir }}/moodle_net/backend/_build/prod/rel/moodle_net"
dest: "/opt/"
owner: moodle
remote_src: yes
become: yes
- name: create moodle net systemd service
copy:
src: "../files/moodle_net.service"
dest: "/etc/systemd/system/moodle_net.service"
mode: "0644"
remote_src: no
become: yes
- name: start moodle net service
systemd:
name: moodle_net
state: started
enabled: yes
daemon_reload: yes
become: yes
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment