Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Move starkcompass to secure VPN and change users. (#396)
Browse files Browse the repository at this point in the history
* Changed host variable to stardardize name across repos.

* Changed deploy configs to change starkcompass-testing user to dev.
  • Loading branch information
samoht9277 authored Jan 11, 2024
1 parent 36d4029 commit f7a96c3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ jobs:
- name: Create ssh private key file from env var
env:
SSH_KEY: ${{ secrets.SSH_KEY }}
HOST: ${{ vars.SSH_HOST }}
TS_HOST: ${{ vars.TS_HOST }}
run: |
mkdir -p ~/.ssh/
sed -E 's/(-+(BEGIN|END) OPENSSH PRIVATE KEY-+) *| +/\1\n/g' <<< "$SSH_KEY" > ~/.ssh/id_ed25519
chmod 400 ~/.ssh/id_ed25519
ssh-keyscan $HOST >> ~/.ssh/known_hosts
ssh-keyscan $TS_HOST >> ~/.ssh/known_hosts
- name: Install ansible
run: |
Expand All @@ -58,7 +58,7 @@ jobs:
AWS_REGION: ${{ vars.AWS_REGION }}
PROVER_STORAGE: ${{ vars.PROVER_STORAGE }}
ANSIBLE_SSH_PKEY_DIR: "~/.ssh/id_ed25519"
SSH_HOST: ${{ vars.SSH_HOST }}
TS_HOST: ${{ vars.TS_HOST }}
GIT_BRANCH: ${{ github.head_ref || github.ref_name }}
ANSIBLE_STDOUT_CALLBACK: "yaml"
ENABLE_MAINNET_SYNC: "true"
Expand Down
2 changes: 1 addition & 1 deletion ansible/inventory.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
webservers:
hosts:
starknet_testing:
ansible_host: "{{ lookup('ansible.builtin.env', 'SSH_HOST') }}"
ansible_host: "{{ lookup('ansible.builtin.env', 'TS_HOST') }}"
ansible_user: starknet_explorer
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_private_key_file: "{{ lookup('ansible.builtin.env', 'ANSIBLE_SSH_PKEY_DIR') }}"
Expand Down
24 changes: 12 additions & 12 deletions ansible/playbooks/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
gather_facts: false
any_errors_fatal: true
become: true
become_user: starknet_explorer
become_user: dev

pre_tasks:

- name: Delete tmp repo
file:
state: absent
path: /home/starknet_explorer/tmp/madara_explorer
path: /home/dev/tmp/madara_explorer

- name: Clone repo in tmp dir
ansible.builtin.git:
repo: [email protected]:lambdaclass/stark_compass_explorer.git
version: "{{ lookup('ansible.builtin.env', 'GIT_BRANCH') }}"
dest: /home/starknet_explorer/tmp/madara_explorer
dest: /home/dev/tmp/stark_compass_explorer
ssh_opts: "-o StrictHostKeyChecking=no"
key_file: /home/starknet_explorer/.ssh/id_ed25519
key_file: /home/dev/.ssh/id_ed25519
register: clone_output

- name: Print clone repo output
Expand All @@ -28,7 +28,7 @@
- name: Build
ansible.builtin.shell: |
set -ex
export PATH=${PATH}:/home/starknet_explorer/.cargo/bin
export PATH=${PATH}:/home/dev/.cargo/bin
mix local.hex --force
mix local.rebar --force
mix deps.get --only $MIX_ENV
Expand All @@ -55,26 +55,26 @@
ENABLE_TESTNET_SYNC: "{{ lookup('ansible.builtin.env', 'ENABLE_TESTNET_SYNC') }}"
ENABLE_GATEWAY_DATA: "{{ lookup('ansible.builtin.env', 'ENABLE_GATEWAY_DATA') }}"
args:
chdir: /home/starknet_explorer/tmp/madara_explorer
chdir: /home/dev/tmp/stark_compass_explorer
register: build_output

- debug: msg="{{ build_output.stdout_lines + [ build_output.stderr_lines ] }}"

- name: Delete old repo
ansible.builtin.file:
state: absent
path: /home/starknet_explorer/madara_explorer
path: /home/dev/stark_compass_explorer

- name: Copy repo from tmp dir
ansible.builtin.copy:
remote_src: true
src: /home/starknet_explorer/tmp/madara_explorer
dest: /home/starknet_explorer/
src: /home/dev/tmp/stark_compass_explorer
dest: /home/dev/stark_compass_explorer

- name: Create .env file
ansible.builtin.template:
src: .env.j2
dest: /home/starknet_explorer/.env
dest: /home/dev/.env
vars:
phx_host: "{{ lookup('ansible.builtin.env', 'PHX_HOST') }}"
secret_key_base: "{{ lookup('ansible.builtin.env', 'SECRET_KEY_BASE') }}"
Expand All @@ -97,12 +97,12 @@
- name: Create user systemd directory
ansible.builtin.file:
state: directory
path: /home/starknet_explorer/.config/systemd/user
path: /home/dev/.config/systemd/user

- name: Install systemd service
ansible.builtin.template:
src: starknet_explorer.service.j2
dest: /home/starknet_explorer/.config/systemd/user/starknet_explorer.service
dest: /home/dev/.config/systemd/user/starknet_explorer.service

- name: Restart starknet_explorer service
ansible.builtin.systemd:
Expand Down
12 changes: 6 additions & 6 deletions ansible/playbooks/templates/starknet_explorer.service.j2
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[Unit]
Description=Madara Explorer
Description=StarkCompass Explorer

[Service]
WorkingDirectory=/home/starknet_explorer/madara_explorer
WorkingDirectory=/home/dev/stark_compass_explorer
Restart=on-failure
ExecStart=/home/starknet_explorer/madara_explorer/entrypoint.sh
ExecStart=/home/dev/stark_compass_explorer/entrypoint.sh
ExecReload=/bin/kill -HUP
KillSignal=SIGTERM
EnvironmentFile=/home/starknet_explorer/.env
StandardOutput=append:/home/starknet_explorer/logs/starknet_explorer.log
StandardError=append:/home/starknet_explorer/logs/starknet_explorer.log
EnvironmentFile=/home/dev/.env
StandardOutput=append:/home/dev/logs/starknet_explorer.log
StandardError=append:/home/dev/logs/starknet_explorer.log

[Install]
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

/home/starknet_explorer/madara_explorer/_build/prod/rel/starknet_explorer/bin/starknet_explorer start
/home/dev/stark_compass_explorer/_build/prod/rel/starknet_explorer/bin/starknet_explorer start

0 comments on commit f7a96c3

Please sign in to comment.