Skip to content

Commit

Permalink
Update deploy process and add ansible migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
Lun4m committed Oct 7, 2024
1 parent cf1b54a commit 635cd9b
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 37 deletions.
5 changes: 0 additions & 5 deletions ansible/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@
- name: Deploy binaries
hosts: lard-a # deploy to lard-a for now, might need to define a separate VM later?
remote_user: ubuntu
vars:
ostack_cloud: lard
ostack_region: Ostack2-EXT
# become: true
# become_user: root
roles:
- role: deploy
29 changes: 29 additions & 0 deletions ansible/migrate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
- name: Perform DB migration
hosts: servers
remote_user: ubuntu
vars:
primary: lard-a

tasks:
- name: Copy the db folder to the remote
ansible.builtin.copy:
src: "{{ playbook_dir }}/../db/"
dest: /etc/postgresql/16/db/
mode: "0755"
become: true

- name: Migrate primary
when: inventory_hostname == primary
become: true
become_user: postgres
block:
- name: Create data partition tables in lard
community.postgresql.postgresql_script:
db: lard
path: /etc/postgresql/16/db/partition.sql

- name: Update public schema in lard
community.postgresql.postgresql_script:
db: lard
path: /etc/postgresql/16/db/public.sql
15 changes: 13 additions & 2 deletions ansible/roles/deploy/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
---
deploy_envars:
- LARD_CONN_STRING: ""
- STINFO_CONN_STRING: ""
- LARD_CONN_STRING:
- STINFO_CONN_STRING:

deploy_files:
- src: lard_ingestion.service
dest: /etc/systemd/system
mode: "0664"
- src: "{{ playbook_dir }}/../target/release/lard_ingestion"
dest: /usr/local/bin
mode: "0755"
- src: "{{ playbook_dir }}/../ingestion/resources"
dest: /usr/local/bin
mode: "0755"
16 changes: 4 additions & 12 deletions ansible/roles/deploy/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
# TODO: do we need separate user/groups? Can't we simply use ubuntu?
- name: Create lard group
ansible.builtin.group:
name: lard
Expand All @@ -13,25 +14,16 @@
state: present
create_home: false

# TODO: should we deploy in non root user?
- name: Copy files to server
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
mode: "{{ item.mode }}"
owner: root
group: root
loop: "{{ files }}"
vars:
files:
- src: lard_ingestion.service
dest: /etc/systemd/system
mode: preserve
- src: lard_ingestion
dest: /usr/local/bin
mode: "0755"
- src: resources
dest: /usr/local/bin
mode: "0755"
become: true
loop: "{{ deploy_files }}"

# - name: Clean logs
# ansible.builtin.command: journalctl {{ item }}
Expand Down
14 changes: 0 additions & 14 deletions ansible/roles/deploy/vars/main.yml

This file was deleted.

5 changes: 1 addition & 4 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/bin/bash

if ! cargo build --workspace --release; then
exit 1
exit 1
fi

pushd ansible || exit

cp ../target/release/lard_ingestion roles/deploy/files/.
cp -r ../ingestion/resources roles/deploy/files/.

ansible-playbook -i inventory.yml deploy.yml --ask-vault-pass

popd || exit

0 comments on commit 635cd9b

Please sign in to comment.