Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Goal

## Changes
-

## Testing

## Checklist
- [ ] Title is a clear sentence (<= 70 chars)
- [ ] Commits are signed (`git log --show-signature`)
- [ ] `submissions/lab1.md` updated
Binary file added ansible/files/quicknotes
Binary file not shown.
2 changes: 2 additions & 0 deletions ansible/inventory.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[quicknotes]
quicknotes-vm ansible_host=127.0.0.1 ansible_port=2222 ansible_user=vagrant ansible_private_key_file=.vagrant/machines/default/virtualbox/private_key ansible_ssh_common_args='-o StrictHostKeyChecking=no'
69 changes: 69 additions & 0 deletions ansible/playbook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
- name: Deploy QuickNotes
hosts: quicknotes
become: true
gather_facts: false

vars:
quicknotes_user: quicknotes
quicknotes_bin: /usr/local/bin/quicknotes
quicknotes_data_dir: /var/lib/quicknotes
listen_addr: ":8080"
data_path: "/var/lib/quicknotes/notes.json"
seed_path: "/var/lib/quicknotes/seed.json"

tasks:
- name: Create quicknotes system user
ansible.builtin.user:
name: "{{ quicknotes_user }}"
system: true
shell: /usr/sbin/nologin
create_home: false

- name: Ensure data directory
ansible.builtin.file:
path: "{{ quicknotes_data_dir }}"
state: directory
owner: "{{ quicknotes_user }}"
group: "{{ quicknotes_user }}"
mode: "0750"

- name: Copy seed file
ansible.builtin.copy:
src: ../../app/seed.json
dest: "{{ seed_path }}"
owner: "{{ quicknotes_user }}"
group: "{{ quicknotes_user }}"
mode: "0644"

- name: Copy QuickNotes binary
ansible.builtin.copy:
src: files/quicknotes
dest: "{{ quicknotes_bin }}"
owner: root
group: root
mode: "0755"
notify: Restart quicknotes

- name: Render systemd unit
ansible.builtin.template:
src: templates/quicknotes.service.j2
dest: /etc/systemd/system/quicknotes.service
owner: root
group: root
mode: "0644"
notify: Restart quicknotes

- name: Enable and start quicknotes
ansible.builtin.systemd:
name: quicknotes
enabled: true
state: started
daemon_reload: true

handlers:
- name: Restart quicknotes
ansible.builtin.systemd:
name: quicknotes
state: restarted
daemon_reload: true
19 changes: 19 additions & 0 deletions ansible/templates/quicknotes.service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Unit]
Description=QuickNotes API
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User={{ quicknotes_user }}
Group={{ quicknotes_user }}
WorkingDirectory={{ quicknotes_data_dir }}
ExecStart={{ quicknotes_bin }}
Environment=ADDR={{ listen_addr }}
Environment=DATA_PATH={{ data_path }}
Environment=SEED_PATH={{ seed_path }}
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
Loading