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
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,13 @@ bare-metal/ansible/files/restart_vm*
bare-metal/ansible/conf*

skale-nodes/ansible/group_vars/all

# proxcout

_network_files/
proxcout/ansible.cfg
proxcout/inventory/dev
proxcout/inventory/hosts
proxcout/files/ssl/*/*.pem
proxcout/files/ssl/*.pem
proxcout/files/abi.json
6 changes: 6 additions & 0 deletions proxcout/base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- name: Setup skale node
hosts: proxy,explorer
become: true
roles:
- role: base_provision
tags: base
6 changes: 6 additions & 0 deletions proxcout/explorer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- name: Setup Blockscout
hosts: explorer
become: true
roles:
- role: explorer_provision
tags: explorer
Empty file added proxcout/inventory/.keep
Empty file.
5 changes: 5 additions & 0 deletions proxcout/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- import_playbook: base.yaml
- import_playbook: repos.yaml
- import_playbook: ssl.yaml
- import_playbook: proxy.yaml
- import_playbook: explorer.yaml
6 changes: 6 additions & 0 deletions proxcout/proxy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- name: Setup Proxy
hosts: proxy
become: true
roles:
- role: proxy_provision
tags: proxy
6 changes: 6 additions & 0 deletions proxcout/repos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- name: Setup repos
hosts: proxy,explorer
become: true
roles:
- role: repos_provision
tags: repos
17 changes: 17 additions & 0 deletions proxcout/roles/base_provision/tasks/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- name: Add docker GPG apt key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
tags:
- docker

- name: Add docker repository
apt_repository:
repo: deb https://download.docker.com/linux/ubuntu bionic stable
state: present
tags:
- docker

- name: Update apt and install docker-ce
apt: update_cache=yes name=docker-ce state=latest
tags: docker
70 changes: 70 additions & 0 deletions proxcout/roles/base_provision/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
- name: Install aptitude
apt: name=aptitude state=latest update_cache=yes force_apt_get=yes

- name: Set soft ulimits
pam_limits:
domain: root
limit_type: soft
limit_item: core
value: "1000000000"
tags: ulimits

- name: Set hard ulimits
pam_limits:
domain: root
limit_type: hard
limit_item: core
value: "1000000000"
tags: ulimits

- name: Install aptitude
apt: name=aptitude state=latest update_cache=yes force_apt_get=yes

- name: Install packages
apt: name={{ item }} update_cache=yes state=latest
loop: [
"apt-transport-https",
"ca-certificates",
"curl",
"software-properties-common",
"python3-pip",
"virtualenv",
"python3-setuptools",
"python3-dev",
"iptables-persistent"
]
tags: apt

- name: Update pip
pip:
name: pip
state: latest

- import_tasks: docker.yaml
tags:
docker

- name: Install docker.py
pip:
name: docker==4.2.0
tags:
pip

- name: Install docker-compose
pip:
name: docker-compose==1.27.4
tags:
- pip
- docker-compose

- name: Enable timedatectl
shell: sudo timedatectl set-ntp on
become: true
tags: ntp

- name: Enable timesyncd service
systemd:
name: systemd-timesyncd
state: started
become: true
tags: ntp
36 changes: 36 additions & 0 deletions proxcout/roles/explorer_provision/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
- name: Clone blockscout repository
git:
repo: https://github.com/skalenetwork/blockscout.git
dest: /home/ubuntu/blockscout/
clone: yes
update: yes
recursive: yes
track_submodules: yes
force: yes

- name: Copy ABIs to explorer
copy:
src: "files/abi.json"
dest: "/home/ubuntu/blockscout/admin/data/abi.json"

- name: Copy SSL certificate file (explorer)
copy:
src: "/home/ubuntu/ssl/explorer-{{ groups['explorer'].index(inventory_hostname) }}/fullchain.pem"
dest: '/home/ubuntu/blockscout/admin/data/certs/server.crt'
remote_src: true

- name: Copy SSL private key file (explorer)
copy:
src: "/home/ubuntu/ssl/explorer-{{ groups['explorer'].index(inventory_hostname) }}/privkey.pem"
dest: '/home/ubuntu/blockscout/admin/data/certs/server.key'
remote_src: true

- name: Run explorer
command: "docker-compose up -d"
environment:
FIRST_SCHAIN_ID: "{{ groups['explorer'].index(inventory_hostname) * 10 }}"
LAST_SCHAIN_ID: "{{ ( groups['explorer'].index(inventory_hostname) + 1) * 10 }}"
SCHAIN_PROXY_DOMAIN: "{{ proxy_domain }}"
ENDPOINT: "{{ eth_endpoint }}"
args:
chdir: /home/ubuntu/blockscout/admin
45 changes: 45 additions & 0 deletions proxcout/roles/proxy_provision/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
- name: Create ABIs dir
file:
path: /home/ubuntu/skale-proxy/abi
state: directory

- name: Copy ABIs to proxy
copy:
src: "files/abi.json"
dest: "/home/ubuntu/skale-proxy/data/abi.json"

- name: Remove existent .env content
shell: "echo '' > /home/ubuntu/skale-proxy/proxy-ui/.env"

- name: Write variables to .env file for proxy-ui
lineinfile:
path: "/home/ubuntu/skale-proxy/proxy-ui/.env"
insertbefore: BOF
line: "{{ item.name }}={{ item.value }}"
with_items:
- { name: BASE_PROXY_URL, value: "{{ proxy_domain }}"}
- { name: EXPLORER_URL, value: "{{ explorer_domain }}"}
- { name: CHAIN_ID, value: "{{ chain_id }}"}
- { name: NETWORK_NAME, value: "{{ network_name }}"}
- { name: MAIN_WEBSITE_URL, value: "{{ main_website_url }}"}
- { name: DOCS_WEBSITE_URL, value: "{{ docs_website_url }}"}
- { name: NETWORKS, value: "{{ networks }}"}
- { name: ABIS_URL, value: "{{ abis_url }}"}

- name: Run proxy
command: "bash scripts/run_proxy.sh"
environment:
BASE_PROXY_URL: "{{ proxy_domain }}"
EXPLORER_URL: "{{ explorer_domain }}"
CHAIN_ID: "{{ chain_id }}"
NETWORK_NAME: "{{ network_name }}"
MAIN_WEBSITE_URL: "{{ main_website_url }}"
DOCS_WEBSITE_URL: "{{ docs_website_url }}"
FIRST_SCHAIN_ID: "{{ groups['proxy'].index(inventory_hostname) * 100 }}"
LAST_SCHAIN_ID: "{{ ( groups['proxy'].index(inventory_hostname) + 1) * 100 }}"
PROXY_FULL_HOST_NAME: "{{ proxy_domain }}"
ETH_ENDPOINT: "{{ eth_endpoint }}"
NETWORKS: {}
ABIS_URL: "{{ abis_url }}"
args:
chdir: /home/ubuntu/skale-proxy
25 changes: 25 additions & 0 deletions proxcout/roles/repos_provision/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- name: Clone proxy repository
git:
repo: https://github.com/skalenetwork/skale-proxy.git
dest: /home/ubuntu/skale-proxy/
clone: yes
update: yes
recursive: yes
track_submodules: yes
force: yes
version: feature/SKALE-4289-refactor-proxy

- name: Clone blockscout repository
git:
repo: https://github.com/skalenetwork/blockscout.git
dest: /home/ubuntu/blockscout/
clone: yes
update: yes
recursive: yes
track_submodules: yes
force: yes

- name: Copy ABIs
copy:
src: "files/abi.json"
dest: "/home/ubuntu/"
14 changes: 14 additions & 0 deletions proxcout/roles/ssl_provision/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- name: Copy SSL certs
copy: src=files/ssl/ dest=/home/ubuntu/ssl/

- name: Copy SSL certificate file (proxy)
copy:
src: '/home/ubuntu/ssl/fullchain.pem'
dest: '/home/ubuntu/skale-proxy/data/server.crt'
remote_src: true

- name: Copy SSL private key file (proxy)
copy:
src: '/home/ubuntu/ssl/privkey.pem'
dest: '/home/ubuntu/skale-proxy/data/server.key'
remote_src: true
6 changes: 6 additions & 0 deletions proxcout/ssl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- name: Setup SSL
hosts: proxy,explorer
become: true
roles:
- role: ssl_provision
tags: ssl