forked from cerc-io/testnet-ops
Compare commits
5 Commits
main
...
nv-update-
Author | SHA1 | Date | |
---|---|---|---|
|
0e8366c7cc | ||
bcbd175f00 | |||
cd314d2fdf | |||
23f3a4c8ed | |||
88e0b48540 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,3 +1 @@
|
|||||||
nitro-nodes-setup/out/
|
hosts.ini
|
||||||
nitro-nodes-setup/nitro-vars.yml
|
|
||||||
l2-setup/out
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
- Set Locale Encoding to `UTF-8`
|
- Set Locale Encoding to `UTF-8`
|
||||||
|
|
||||||
Ansible requires the locale encoding to be `UTF-8`. You can either use the `LANG` prefix when running Ansible commands or set the system-wide locale.
|
Ansible requires the locale encoding to be `UTF-8`. You can either use the `LANG` prefix when running Ansible commands or set the system-wide locale
|
||||||
|
|
||||||
- Option 1: Use `LANG` Prefix in Commands
|
- Option 1: Use `LANG` Prefix in Commands
|
||||||
|
|
||||||
@ -32,11 +32,14 @@
|
|||||||
LANG="en_US.UTF-8"
|
LANG="en_US.UTF-8"
|
||||||
```
|
```
|
||||||
|
|
||||||
- Reboot your system or log out and log back in to apply the changes.
|
- Reboot your system or log out and log back in to apply the changes
|
||||||
|
|
||||||
- Reference: <https://udhayakumarc.medium.com/error-ansible-requires-the-locale-encoding-to-be-utf-8-detected-iso8859-1-6da808387f7d>
|
- Reference: <https://udhayakumarc.medium.com/error-ansible-requires-the-locale-encoding-to-be-utf-8-detected-iso8859-1-6da808387f7d>
|
||||||
|
|
||||||
## Playbooks
|
## Playbooks
|
||||||
|
|
||||||
|
- [stack-orchestrator-setup](./stack-orchestrator-setup/README.md)
|
||||||
- [l2-setup](./l2-setup/README.md)
|
- [l2-setup](./l2-setup/README.md)
|
||||||
- [nitro-node-setup](./nitro-nodes-setup/README.md)
|
- [nitro-node-setup](./nitro-nodes-setup/README.md)
|
||||||
|
- [nitro-bridge-setup](./nitro-bridge-setup/README.md)
|
||||||
|
- [nitro-contracts-setup](./nitro-contracts-setup/README.md)
|
||||||
|
2
hosts.example.ini
Normal file
2
hosts.example.ini
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[deployment_host]
|
||||||
|
<host_name> ansible_host=<target_ip> ansible_user=<ssh_user> ansible_ssh_common_args='-o ForwardAgent=yes'
|
3
l2-setup/.gitignore
vendored
Normal file
3
l2-setup/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
out
|
||||||
|
l2-vars.yml
|
||||||
|
hosts.ini
|
@ -4,13 +4,19 @@
|
|||||||
|
|
||||||
To get started, follow the [installation](../README.md#installation) guide to setup ansible on your machine
|
To get started, follow the [installation](../README.md#installation) guide to setup ansible on your machine
|
||||||
|
|
||||||
## Setup and Run Optimism
|
## Setup
|
||||||
|
|
||||||
The following commands have to be executed in [`l2-setup`](./) directory
|
The following commands have to be executed in the [`l2-setup`](./) directory:
|
||||||
|
|
||||||
- Edit [`l2-vars.yml`](./l2-vars.yml) with the required values
|
- Copy the `l2-vars.example.yml` vars file:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
cp l2-vars.example.yml l2-vars.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
- Edit [`l2-vars.yml`](./l2-vars.yml) with the required values:
|
||||||
|
|
||||||
|
```yaml
|
||||||
# L1 chain ID
|
# L1 chain ID
|
||||||
l1_chain_id: ""
|
l1_chain_id: ""
|
||||||
|
|
||||||
@ -34,41 +40,105 @@ The following commands have to be executed in [`l2-setup`](./) directory
|
|||||||
l1_priv_key: ""
|
l1_priv_key: ""
|
||||||
```
|
```
|
||||||
|
|
||||||
- To setup and run L2, execute the `run-optimism.yml` Ansible playbook by running the following command.
|
## Run L2
|
||||||
|
|
||||||
NOTE: By default, deployments are created in the `l2-setup/out` directory. To change this location, update the `l2_directory` variable in the [setup-vars.yml](./setup-vars.yml) file.
|
### On Local Host
|
||||||
|
|
||||||
|
- To setup and run L2 locally, execute the `run-optimism.yml` Ansible playbook:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
LANG=en_US.utf8 ansible-playbook -i localhost, --connection=local run-optimism.yml --extra-vars='{ "target_host": "localhost"}' -kK --user $USER
|
LANG=en_US.utf8 ansible-playbook run-optimism.yml --extra-vars='{ "target_host": "localhost"}' --user $USER -kK
|
||||||
```
|
```
|
||||||
|
|
||||||
- For skipping container build, set `"skip_container_build" : true` in the `--extra-vars` parameter:
|
NOTE: By default, deployments are created in an `out` directory. To change this location, update the `l2_directory` variable in the [setup-vars.yml](./setup-vars.yml) file
|
||||||
|
|
||||||
|
- For skipping container build, set `"skip_container_build" : true` in the `--extra-vars` parameter:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
LANG=en_US.utf8 ansible-playbook -i localhost, --connection=local run-optimism.yml --extra-vars='{"target_host" : "localhost", "skip_container_build": true}' -kK --user $USER
|
LANG=en_US.utf8 ansible-playbook run-optimism.yml --extra-vars='{"target_host" : "localhost", "skip_container_build": true}' --user $USER -kK
|
||||||
```
|
```
|
||||||
|
|
||||||
- To run using existing contracts deployment
|
- To run using existing contracts deployment:
|
||||||
|
|
||||||
- Update `artifact_path` in [`setup-vars.yml`](./setup-vars.yml) file with path to data directory of the existing deployment
|
- Update `artifact_path` in [`setup-vars.yml`](./setup-vars.yml) file with path to data directory of the existing deployment
|
||||||
|
|
||||||
- Run the ansible playbook with `"existing_contracts_deployment": true` in the `--extra-vars` parameter:
|
- Run the ansible playbook with `"existing_contracts_deployment": true` in the `--extra-vars` parameter:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
LANG=en_US.utf8 ansible-playbook -i localhost, --connection=local run-optimism.yml --extra-vars='{"target_host" : "localhost", "existing_contracts_deployment": true}' -kK --user $USER
|
LANG=en_US.utf8 ansible-playbook run-optimism.yml --extra-vars='{"target_host" : "localhost", "existing_contracts_deployment": true}' --user $USER -kK
|
||||||
|
```
|
||||||
|
|
||||||
|
### On Remote Host
|
||||||
|
|
||||||
|
To run the playbook on a remote host:
|
||||||
|
|
||||||
|
- Create a new `hosts.ini` file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp ../hosts.example.ini hosts.ini
|
||||||
|
```
|
||||||
|
|
||||||
|
- Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[<deployment_host>]
|
||||||
|
<host_name> ansible_host=<target_ip> ansible_user=<ssh_user> ansible_ssh_common_args='-o ForwardAgent=yes'
|
||||||
|
```
|
||||||
|
|
||||||
|
- Replace `<deployment_host>` with `l2_host`
|
||||||
|
- Replace `<host_name>` with the alias of your choice
|
||||||
|
- Replace `<target_ip>` with the IP address or hostname of the target machine
|
||||||
|
- Replace `<ssh_user>` with the SSH username (e.g., dev, ubuntu)
|
||||||
|
|
||||||
|
- Verify that you are able to connect to the host using the following command
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ansible all -m ping -i hosts.ini -k
|
||||||
|
|
||||||
|
# Expected output:
|
||||||
|
|
||||||
|
# <host_name> | SUCCESS => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "discovered_interpreter_python": "/usr/bin/python3.10"
|
||||||
|
# },
|
||||||
|
# "changed": false,
|
||||||
|
# "ping": "pong"
|
||||||
|
# }
|
||||||
|
```
|
||||||
|
|
||||||
|
- Execute the `run-optimism.yml` Ansible playbook for remote deployment:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
LANG=en_US.utf8 ansible-playbook -i hosts.ini run-optimism.yml --extra-vars='{ "target_host": "l2_host"}' --user $USER -kK
|
||||||
|
```
|
||||||
|
|
||||||
|
- For skipping container build, set `"skip_container_build" : true` in the `--extra-vars` parameter:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
LANG=en_US.utf8 ansible-playbook -i hosts.ini run-optimism.yml --extra-vars='{"target_host" : "l2_host", "skip_container_build": true}' --user $USER -kK
|
||||||
|
```
|
||||||
|
|
||||||
|
- To run using existing contracts deployment:
|
||||||
|
|
||||||
|
- Update `artifact_path` in [`setup-vars.yml`](./setup-vars.yml) file with path to data directory of the existing deployment
|
||||||
|
|
||||||
|
- Run the ansible playbook with `"existing_contracts_deployment": true` in the `--extra-vars` parameter:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
LANG=en_US.utf8 ansible-playbook -i hosts.ini run-optimism.yml --extra-vars='{"target_host" : "l2_host", "existing_contracts_deployment": true}' --user $USER -kK
|
||||||
```
|
```
|
||||||
|
|
||||||
## Check Deployment Status
|
## Check Deployment Status
|
||||||
|
|
||||||
- Run the following command in the directory where the optimism-deployment is created
|
Run the following commands in the directory where the optimism-deployment is created:
|
||||||
|
|
||||||
- Follow optimism contracts deployment logs:
|
- Follow optimism contracts deployment logs:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
laconic-so deployment --dir optimism-deployment logs -f fixturenet-optimism-contracts
|
laconic-so deployment --dir optimism-deployment logs -f fixturenet-optimism-contracts
|
||||||
```
|
```
|
||||||
|
|
||||||
- Check L2 logs:
|
- Check L2 logs:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
laconic-so deployment --dir optimism-deployment logs -f op-geth
|
laconic-so deployment --dir optimism-deployment logs -f op-geth
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
skip_container_build: false
|
skip_container_build: false
|
||||||
l2_directory: "./out"
|
l2_directory: "out"
|
||||||
existing_contracts_deployment: false
|
existing_contracts_deployment: false
|
||||||
artifact_path: ""
|
artifact_path: ""
|
||||||
|
3
nitro-bridge-setup/.gitignore
vendored
Normal file
3
nitro-bridge-setup/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
out
|
||||||
|
bridge-vars.yml
|
||||||
|
hosts.ini
|
140
nitro-bridge-setup/README.md
Normal file
140
nitro-bridge-setup/README.md
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
# nitro-bridge-setup
|
||||||
|
|
||||||
|
## Setup Ansible
|
||||||
|
|
||||||
|
To get started, follow the [installation](../README.md#installation) guide to setup ansible on your machine
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
The following commands have to be executed in the [`nitro-bridge-setup`](./) directory:
|
||||||
|
|
||||||
|
- Copy the `bridge-vars.example.yml` vars file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp bridge-vars.example.yml bridge-vars.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
- Edit [`bridge-vars.yml`](./bridge-vars.yml) with the required values:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# L1 WS endpoint
|
||||||
|
nitro_l1_chain_url: ""
|
||||||
|
|
||||||
|
# L2 WS endpoint
|
||||||
|
nitro_l2_chain_url: ""
|
||||||
|
|
||||||
|
# Private key for the bridge's nitro address
|
||||||
|
nitro_sc_pk: ""
|
||||||
|
|
||||||
|
# Private key for a funded account on L1
|
||||||
|
# This account should have tokens for funding Nitro channels
|
||||||
|
nitro_chain_pk: ""
|
||||||
|
|
||||||
|
# L2 chain ID
|
||||||
|
optimism_chain_id: ""
|
||||||
|
|
||||||
|
# L2 RPC endpoint
|
||||||
|
optimism_url: ""
|
||||||
|
|
||||||
|
# Custom L2 token to be deployed
|
||||||
|
token_name: "LaconicNetworkToken"
|
||||||
|
token_symbol: "LNT"
|
||||||
|
initial_token_supply: "129600"
|
||||||
|
|
||||||
|
# Addresses of the deployed nitro contracts
|
||||||
|
na_address: ""
|
||||||
|
vpa_address: ""
|
||||||
|
ca_address: ""
|
||||||
|
|
||||||
|
# Address of deployed custom L1 token
|
||||||
|
l1_asset_address: ""
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run Nitro Bridge
|
||||||
|
|
||||||
|
### On Local Host
|
||||||
|
|
||||||
|
- To setup and run nitro bridge locally, execute the `run-nitro-bridge.yml` Ansible playbook:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
LANG=en_US.utf8 ansible-playbook run-nitro-bridge.yml --extra-vars='{ "target_host": "localhost"}' --user $USER -kK
|
||||||
|
```
|
||||||
|
|
||||||
|
NOTE: By default, deployments are created in an `out` directory. To change this location, update the `nitro_directory` variable in the [setup-vars.yml](./setup-vars.yml) file
|
||||||
|
|
||||||
|
- For skipping container build, set `"skip_container_build" : true` in the `--extra-vars` parameter:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
LANG=en_US.utf8 ansible-playbook run-nitro-bridge.yml --extra-vars='{"target_host" : "localhost", "skip_container_build": true}' --user $USER -kK
|
||||||
|
```
|
||||||
|
|
||||||
|
### On Remote Host
|
||||||
|
|
||||||
|
To run the playbook on a remote host:
|
||||||
|
|
||||||
|
- Create a new `hosts.ini` file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp ../hosts.example.ini hosts.ini
|
||||||
|
```
|
||||||
|
|
||||||
|
- Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[<deployment_host>]
|
||||||
|
<host_name> ansible_host=<target_ip> ansible_user=<ssh_user> ansible_ssh_common_args='-o ForwardAgent=yes'
|
||||||
|
```
|
||||||
|
|
||||||
|
- Replace `<deployment_host>` with `nitro_host`
|
||||||
|
- Replace `<host_name>` with the alias of your choice
|
||||||
|
- Replace `<target_ip>` with the IP address or hostname of the target machine
|
||||||
|
- Replace `<ssh_user>` with the SSH username (e.g., dev, ubuntu)
|
||||||
|
|
||||||
|
- Verify that you are able to connect to the host using the following command
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ansible all -m ping -i hosts.ini -k
|
||||||
|
|
||||||
|
# Expected output:
|
||||||
|
|
||||||
|
# <host_name> | SUCCESS => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "discovered_interpreter_python": "/usr/bin/python3.10"
|
||||||
|
# },
|
||||||
|
# "changed": false,
|
||||||
|
# "ping": "pong"
|
||||||
|
# }
|
||||||
|
```
|
||||||
|
|
||||||
|
- Execute the `run-nitro-bridge.yml` Ansible playbook for remote deployment:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
LANG=en_US.utf8 ansible-playbook -i hosts.ini run-nitro-bridge.yml --extra-vars='{ "target_host": "nitro_host"}' --user $USER -kK
|
||||||
|
```
|
||||||
|
|
||||||
|
- For skipping container build, run with `"skip_container_build" : true` in the `--extra-vars` parameter:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
LANG=en_US.utf8 ansible-playbook -i hosts.ini run-nitro-bridge.yml --extra-vars='{ "target_host": "nitro_host", "skip_container_build": true }' --user $USER -kK
|
||||||
|
```
|
||||||
|
|
||||||
|
## Check Deployment Status
|
||||||
|
|
||||||
|
- Run the following command in the directory where the bridge-deployment is created:
|
||||||
|
|
||||||
|
- Check logs for deployments:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Check the bridge deployment logs, ensure that the node is running
|
||||||
|
laconic-so deployment --dir bridge-deployment logs nitro-bridge -f
|
||||||
|
```
|
||||||
|
|
||||||
|
## Get Contract Addresses
|
||||||
|
|
||||||
|
- Run the following commands in the directory where the deployments are created:
|
||||||
|
|
||||||
|
- Get addresses of L2 nitro contracts:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
laconic-so deployment --dir bridge-deployment exec nitro-bridge "cat /app/deployment/nitro-addresses.json"
|
||||||
|
```
|
13
nitro-bridge-setup/bridge-vars.example.yml
Normal file
13
nitro-bridge-setup/bridge-vars.example.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
nitro_l1_chain_url: ""
|
||||||
|
nitro_l2_chain_url: ""
|
||||||
|
nitro_chain_pk: ""
|
||||||
|
nitro_sc_pk: ""
|
||||||
|
optimism_chain_id: ""
|
||||||
|
optimism_url: ""
|
||||||
|
token_name: "LaconicNetworkToken"
|
||||||
|
token_symbol: "LNT"
|
||||||
|
initial_token_supply: "129600"
|
||||||
|
na_address: ""
|
||||||
|
vpa_address: ""
|
||||||
|
ca_address: ""
|
||||||
|
l1_asset_address: ""
|
73
nitro-bridge-setup/run-nitro-bridge.yml
Normal file
73
nitro-bridge-setup/run-nitro-bridge.yml
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
- name: Setup go-nitro on host
|
||||||
|
hosts: "{{ target_host }}"
|
||||||
|
|
||||||
|
vars_files:
|
||||||
|
- setup-vars.yml
|
||||||
|
- bridge-vars.yml
|
||||||
|
|
||||||
|
environment:
|
||||||
|
PATH: "{{ ansible_env.PATH }}:/home/{{ansible_user}}/bin"
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Create directory for nitro bridge deployment
|
||||||
|
file:
|
||||||
|
path: "{{ nitro_directory }}"
|
||||||
|
state: directory
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- name: Clone go-nitro stack repo
|
||||||
|
command: laconic-so fetch-stack git.vdb.to/cerc-io/nitro-stack --git-ssh --pull
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Change owner of nitro-directory
|
||||||
|
file:
|
||||||
|
path: "{{ nitro_directory }}"
|
||||||
|
owner: "{{ansible_user}}"
|
||||||
|
group: "{{ansible_user}}"
|
||||||
|
state: directory
|
||||||
|
recurse: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- name: Clone repositories required for nitro-stack
|
||||||
|
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge setup-repositories --git-ssh --pull
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Build containers
|
||||||
|
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge build-containers --force-rebuild
|
||||||
|
when: not skip_container_build
|
||||||
|
|
||||||
|
- name: Check if deployment exists for bridge node
|
||||||
|
stat:
|
||||||
|
path: "{{ nitro_directory }}/bridge-deployment"
|
||||||
|
register: bridge_deployment
|
||||||
|
|
||||||
|
- name: Generate spec file for bridge deployment
|
||||||
|
template:
|
||||||
|
src: "./templates/specs/bridge-nitro-spec.yml.j2"
|
||||||
|
dest: "{{ nitro_directory }}/bridge-nitro-spec.yml"
|
||||||
|
when: not bridge_deployment.stat.exists
|
||||||
|
|
||||||
|
- name: Create a deployment for the bridge node
|
||||||
|
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge deploy create --spec-file bridge-nitro-spec.yml --deployment-dir bridge-deployment
|
||||||
|
args:
|
||||||
|
chdir: "{{ nitro_directory }}"
|
||||||
|
when: not bridge_deployment.stat.exists
|
||||||
|
|
||||||
|
- name: Start the nitro bridge
|
||||||
|
command: laconic-so deployment --dir bridge-deployment start
|
||||||
|
args:
|
||||||
|
chdir: "{{ nitro_directory }}"
|
||||||
|
|
||||||
|
- name: Wait for nitro-addresses.json to be created
|
||||||
|
wait_for:
|
||||||
|
path: "{{ nitro_directory }}/bridge-deployment/data/nitro_deployment/nitro-addresses.json"
|
||||||
|
state: present
|
||||||
|
timeout: 180
|
||||||
|
|
||||||
|
- name: Print BRIDGE_ADDRESS
|
||||||
|
shell: laconic-so deployment --dir bridge-deployment exec nitro-bridge "jq -r '.\"{{ optimism_chain_id }}\"[0].contracts.Bridge.address' /app/deployment/nitro-addresses.json"
|
||||||
|
args:
|
||||||
|
chdir: "{{ nitro_directory }}"
|
||||||
|
register: bridge_address
|
||||||
|
- debug:
|
||||||
|
msg: "BRIDGE_ADDRESS: {{ bridge_address.stdout }}"
|
3
nitro-bridge-setup/setup-vars.yml
Normal file
3
nitro-bridge-setup/setup-vars.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
target_host: "localhost"
|
||||||
|
nitro_directory: out
|
||||||
|
skip_container_build: false
|
28
nitro-bridge-setup/templates/specs/bridge-nitro-spec.yml.j2
Normal file
28
nitro-bridge-setup/templates/specs/bridge-nitro-spec.yml.j2
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
stack: /home/{{ ansible_user }}/cerc/nitro-stack/stack-orchestrator/stacks/bridge
|
||||||
|
deploy-to: compose
|
||||||
|
config:
|
||||||
|
NITRO_L1_CHAIN_URL: {{ nitro_l1_chain_url }}
|
||||||
|
NITRO_L2_CHAIN_URL: {{ nitro_l2_chain_url }}
|
||||||
|
NITRO_CHAIN_PK: {{ nitro_chain_pk }}
|
||||||
|
NITRO_SC_PK: {{ nitro_sc_pk }}
|
||||||
|
OPTIMISM_CHAIN_ID: {{ optimism_chain_id }}
|
||||||
|
OPTIMISM_URL: {{ optimism_url }}
|
||||||
|
OPTIMISM_DEPLOYER_PK: {{ nitro_chain_pk }}
|
||||||
|
TOKEN_NAME: {{ token_name }}
|
||||||
|
TOKEN_SYMBOL: {{ token_symbol }}
|
||||||
|
INITIAL_TOKEN_SUPPLY: {{ initial_token_supply }}
|
||||||
|
NA_ADDRESS: "{{ na_address }}"
|
||||||
|
VPA_ADDRESS: "{{ vpa_address }}"
|
||||||
|
CA_ADDRESS: "{{ ca_address }}"
|
||||||
|
L1_ASSET_ADDRESS: "{{ l1_asset_address }}"
|
||||||
|
network:
|
||||||
|
ports:
|
||||||
|
nitro-bridge:
|
||||||
|
- 0.0.0.0:3005:3005
|
||||||
|
- 0.0.0.0:3006:3006
|
||||||
|
- 0.0.0.0:4005:4005
|
||||||
|
volumes:
|
||||||
|
nitro_bridge_data: ./data/nitro_bridge_data
|
||||||
|
nitro_bridge_tls: ./data/nitro_bridge_tls
|
||||||
|
nitro_node_caroot: ./data/nitro_node_caroot
|
||||||
|
nitro_deployment: ./data/nitro_deployment
|
3
nitro-contracts-setup/.gitignore
vendored
Normal file
3
nitro-contracts-setup/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
out
|
||||||
|
contract-vars.yml
|
||||||
|
hosts.ini
|
122
nitro-contracts-setup/README.md
Normal file
122
nitro-contracts-setup/README.md
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
# nitro-contracts-setup
|
||||||
|
|
||||||
|
## Setup Ansible
|
||||||
|
|
||||||
|
To get started, follow the [installation](../README.md#installation) guide to setup ansible on your machine
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
The following commands have to be executed in the [`nitro-contracts-setup`](./) directory:
|
||||||
|
|
||||||
|
- Copy the `contract-vars.example.yml` vars file
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp contract-vars.example.yml contract-vars.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
- Edit [`contract-vars.yml`](./contract-vars.yml) and fill in the following values
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# L1 RPC endpoint
|
||||||
|
geth_url: ""
|
||||||
|
|
||||||
|
# L1 chain ID
|
||||||
|
geth_chain_id: ""
|
||||||
|
|
||||||
|
# Private key for a funded account on L1 to use for contracts deployment on L1
|
||||||
|
geth_deployer_pk: ""
|
||||||
|
|
||||||
|
# Custom L1 token to be deployed
|
||||||
|
token_name: "LaconicNetworkToken"
|
||||||
|
token_symbol: "LNT"
|
||||||
|
initial_token_supply: "129600"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deploy Contracts
|
||||||
|
|
||||||
|
### On Local Host
|
||||||
|
|
||||||
|
- To deploy nitro contracts locally, execute the `deploy-contracts.yml` Ansible playbook:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
LANG=en_US.utf8 ansible-playbook deploy-contracts.yml --extra-vars='{ "target_host": "localhost"}' --user $USER -kK
|
||||||
|
```
|
||||||
|
|
||||||
|
NOTE: By default, deployments are created in an `out` directory. To change this location, update the `nitro_directory` variable in the [setup-vars.yml](./setup-vars.yml) file
|
||||||
|
|
||||||
|
- For skipping container build, set `"skip_container_build" : true` in the `--extra-vars` parameter:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
LANG=en_US.utf8 ansible-playbook deploy-contracts.yml --extra-vars='{"target_host" : "localhost", "skip_container_build": true}' --user $USER -kK
|
||||||
|
```
|
||||||
|
|
||||||
|
### On Remote Host
|
||||||
|
|
||||||
|
To run the playbook on a remote host:
|
||||||
|
|
||||||
|
- Create a new `hosts.ini` file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp ../hosts.example.ini hosts.ini
|
||||||
|
```
|
||||||
|
|
||||||
|
- Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[<deployment_host>]
|
||||||
|
<host_name> ansible_host=<target_ip> ansible_user=<ssh_user> ansible_ssh_common_args='-o ForwardAgent=yes'
|
||||||
|
```
|
||||||
|
|
||||||
|
- Replace `<deployment_host>` with `nitro_host`
|
||||||
|
- Replace `<host_name>` with the alias of your choice
|
||||||
|
- Replace `<target_ip>` with the IP address or hostname of the target machine
|
||||||
|
- Replace `<ssh_user>` with the SSH username (e.g., dev, ubuntu)
|
||||||
|
|
||||||
|
- Verify that you are able to connect to the host using the following command
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ansible all -m ping -i hosts.ini -k
|
||||||
|
|
||||||
|
# Expected output:
|
||||||
|
|
||||||
|
# <host_name> | SUCCESS => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "discovered_interpreter_python": "/usr/bin/python3.10"
|
||||||
|
# },
|
||||||
|
# "changed": false,
|
||||||
|
# "ping": "pong"
|
||||||
|
# }
|
||||||
|
```
|
||||||
|
|
||||||
|
- Execute the `deploy-contracts.yml` Ansible playbook for remote deployment:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
LANG=en_US.utf8 ansible-playbook -i hosts.ini deploy-contracts.yml --extra-vars='{ "target_host": "nitro_host"}' --user $USER -kK
|
||||||
|
```
|
||||||
|
|
||||||
|
- For skipping container build, run with `"skip_container_build" : true` in the `--extra-vars` parameter:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
LANG=en_US.utf8 ansible-playbook -i hosts.ini deploy-contracts.yml --extra-vars='{ "target_host": "nitro_host", "skip_container_build": true }' --user $USER -kK
|
||||||
|
```
|
||||||
|
|
||||||
|
## Check Deployment Status
|
||||||
|
|
||||||
|
- Run the following command in the directory where the nitro-contracts-deployment is created:
|
||||||
|
|
||||||
|
- Check logs for deployments:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Check the L2 nitro contract deployment logs
|
||||||
|
laconic-so deployment --dir nitro-contracts-deployment logs l2-nitro-contracts -f
|
||||||
|
```
|
||||||
|
|
||||||
|
## Get Contract Addresses
|
||||||
|
|
||||||
|
- Run the following commands in the directory where the deployments are created:
|
||||||
|
|
||||||
|
- Get addresses of L1 nitro contracts:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "cat /app/deployment/nitro-addresses.json"
|
||||||
|
```
|
6
nitro-contracts-setup/contract-vars.example.yml
Normal file
6
nitro-contracts-setup/contract-vars.example.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
geth_url: ""
|
||||||
|
geth_chain_id: ""
|
||||||
|
geth_deployer_pk: ""
|
||||||
|
token_name: ""
|
||||||
|
token_symbol: ""
|
||||||
|
initial_token_supply: ""
|
96
nitro-contracts-setup/deploy-contracts.yml
Normal file
96
nitro-contracts-setup/deploy-contracts.yml
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
- name: Deploy nitro contracts
|
||||||
|
hosts: "{{ target_host }}"
|
||||||
|
|
||||||
|
vars_files:
|
||||||
|
- setup-vars.yml
|
||||||
|
- contract-vars.yml
|
||||||
|
|
||||||
|
environment:
|
||||||
|
PATH: "{{ ansible_env.PATH }}:/home/{{ansible_user}}/bin"
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Create directory for nitro bridge deployment
|
||||||
|
file:
|
||||||
|
path: "{{ nitro_directory }}"
|
||||||
|
state: directory
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- name: Clone go-nitro stack repo
|
||||||
|
command: laconic-so fetch-stack git.vdb.to/cerc-io/nitro-stack --git-ssh --pull
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Change owner of nitro-directory
|
||||||
|
file:
|
||||||
|
path: "{{ nitro_directory }}"
|
||||||
|
owner: "{{ansible_user}}"
|
||||||
|
group: "{{ansible_user}}"
|
||||||
|
state: directory
|
||||||
|
recurse: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- name: Clone repositories required for nitro-stack
|
||||||
|
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge setup-repositories --git-ssh --pull
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Build containers
|
||||||
|
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge build-containers --force-rebuild
|
||||||
|
when: not skip_container_build
|
||||||
|
|
||||||
|
- name: Generate spec file for nitro contracts deployment
|
||||||
|
template:
|
||||||
|
src: "./templates/specs/nitro-contracts-spec.yml.j2"
|
||||||
|
dest: "{{ nitro_directory }}/nitro-contracts-spec.yml"
|
||||||
|
|
||||||
|
- name: Check if deployment exists for nitro contracts
|
||||||
|
stat:
|
||||||
|
path: "{{ nitro_directory }}/nitro-contracts-deployment"
|
||||||
|
register: nitro_contracts_deployment
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- name: Create a deployment for nitro contracts
|
||||||
|
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-contracts deploy create --spec-file nitro-contracts-spec.yml --deployment-dir nitro-contracts-deployment
|
||||||
|
args:
|
||||||
|
chdir: "{{ nitro_directory }}"
|
||||||
|
when: not nitro_contracts_deployment.stat.exists
|
||||||
|
|
||||||
|
- name: Start deployment for nitro-contracts
|
||||||
|
command: laconic-so deployment --dir nitro-contracts-deployment start
|
||||||
|
args:
|
||||||
|
chdir: "{{ nitro_directory }}"
|
||||||
|
|
||||||
|
- name: Wait for the contracts to be deployed
|
||||||
|
wait_for:
|
||||||
|
path: "{{ nitro_directory }}/nitro-contracts-deployment/data/nitro_deployment/nitro-addresses.json"
|
||||||
|
timeout: 300
|
||||||
|
|
||||||
|
- name: Export NA_ADDRESS
|
||||||
|
shell: laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"{{ geth_chain_id }}\"[0].contracts.NitroAdjudicator.address' /app/deployment/nitro-addresses.json"
|
||||||
|
args:
|
||||||
|
chdir: "{{ nitro_directory }}"
|
||||||
|
register: na_address
|
||||||
|
- debug:
|
||||||
|
msg: "NA_ADDRESS: {{ na_address.stdout }}"
|
||||||
|
|
||||||
|
- name: Export CA_ADDRESS
|
||||||
|
shell: laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"{{ geth_chain_id }}\"[0].contracts.ConsensusApp.address' /app/deployment/nitro-addresses.json"
|
||||||
|
args:
|
||||||
|
chdir: "{{ nitro_directory }}"
|
||||||
|
register: ca_address
|
||||||
|
- debug:
|
||||||
|
msg: "CA_ADDRESS: {{ ca_address.stdout }}"
|
||||||
|
|
||||||
|
- name: Export VPA_ADDRESS
|
||||||
|
shell: laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"{{ geth_chain_id }}\"[0].contracts.VirtualPaymentApp.address' /app/deployment/nitro-addresses.json"
|
||||||
|
args:
|
||||||
|
chdir: "{{ nitro_directory }}"
|
||||||
|
register: vpa_address
|
||||||
|
- debug:
|
||||||
|
msg: "VPA_ADDRESS: {{ vpa_address.stdout }}"
|
||||||
|
|
||||||
|
- name: Export L1_ASSET_ADDRESS
|
||||||
|
shell: laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"{{ geth_chain_id }}\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json"
|
||||||
|
args:
|
||||||
|
chdir: "{{ nitro_directory }}"
|
||||||
|
register: l1_asset_address
|
||||||
|
- debug:
|
||||||
|
msg: "L1_ASSET_ADDRESS: {{ l1_asset_address.stdout }}"
|
3
nitro-contracts-setup/setup-vars.yml
Normal file
3
nitro-contracts-setup/setup-vars.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
target_host: "localhost"
|
||||||
|
nitro_directory: out
|
||||||
|
skip_container_build: false
|
@ -0,0 +1,13 @@
|
|||||||
|
stack: /home/{{ ansible_user }}/cerc/nitro-stack/stack-orchestrator/stacks/nitro-contracts
|
||||||
|
deploy-to: compose
|
||||||
|
config:
|
||||||
|
GETH_URL: {{ geth_url }}
|
||||||
|
GETH_CHAIN_ID: {{ geth_chain_id }}
|
||||||
|
GETH_DEPLOYER_PK: {{ geth_deployer_pk }}
|
||||||
|
TOKEN_NAME: {{ token_name }}
|
||||||
|
TOKEN_SYMBOL: {{ token_symbol }}
|
||||||
|
INITIAL_TOKEN_SUPPLY: {{ initial_token_supply }}
|
||||||
|
network:
|
||||||
|
ports: {}
|
||||||
|
volumes:
|
||||||
|
nitro_deployment: ./data/nitro_deployment
|
3
nitro-nodes-setup/.gitignore
vendored
Normal file
3
nitro-nodes-setup/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
out
|
||||||
|
nitro-vars.yml
|
||||||
|
hosts.ini
|
@ -4,14 +4,22 @@
|
|||||||
|
|
||||||
To get started, follow the [installation](../README.md#installation) guide to setup ansible on your machine
|
To get started, follow the [installation](../README.md#installation) guide to setup ansible on your machine
|
||||||
|
|
||||||
## Run a nitro node
|
## Setup for Remote Host
|
||||||
|
|
||||||
|
To run the playbook on a remote host:
|
||||||
|
|
||||||
|
- Follow steps from [setup remote hosts](../README.md#setup-remote-hosts)
|
||||||
|
|
||||||
|
- Update / append the [`hosts.ini`](../hosts.ini) file for your remote host with `<deployment_host>` set as `nitro_host`
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
The following commands have to be executed in [`nitro-nodes-setup`](./) directory
|
The following commands have to be executed in [`nitro-nodes-setup`](./) directory
|
||||||
|
|
||||||
- Copy the `nitro-vars-example.yml` vars file
|
- Copy the `nitro-vars.example.yml` vars file
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cp nitro-vars-example.yml nitro-vars.yml
|
cp nitro-vars.example.yml nitro-vars.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
- Edit [`nitro-vars.yml`](./nitro-vars.yml) and fill in the following values
|
- Edit [`nitro-vars.yml`](./nitro-vars.yml) and fill in the following values
|
||||||
@ -56,20 +64,77 @@ The following commands have to be executed in [`nitro-nodes-setup`](./) director
|
|||||||
nitro_l2_ext_multiaddr: ""
|
nitro_l2_ext_multiaddr: ""
|
||||||
```
|
```
|
||||||
|
|
||||||
- To run a nitro node, execute the `run-nitro-nodes.yml` Ansible playbook by running the following command.
|
## Run Nitro Node
|
||||||
|
|
||||||
NOTE: By default, deployments are created in the `nitro-nodes-setup/out` directory. To change this location, update the `nitro_directory` variable in the [setup-vars.yml](./setup-vars.yml) file.
|
### On Local Host
|
||||||
|
|
||||||
|
- To run a nitro node, execute the `run-nitro-nodes.yml` Ansible playbook by running the following command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
LANG=en_US.utf8 ansible-playbook -i localhost, --connection=local run-nitro-nodes.yml --extra-vars='{ "target_host": "localhost"}' -kK --user $USER
|
LANG=en_US.utf8 ansible-playbook run-nitro-nodes.yml --extra-vars='{ "target_host": "localhost"}' --user $USER -kK
|
||||||
```
|
```
|
||||||
|
|
||||||
- For skipping container build, run with `"skip_container_build" : true` in the `--extra-vars` parameter:
|
NOTE: By default, deployments are created in a `out` directory. To change this location, update the `nitro_directory` variable in the [setup-vars.yml](./setup-vars.yml) file
|
||||||
|
|
||||||
|
- For skipping container build, run with `"skip_container_build" : true` in the `--extra-vars` parameter:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
LANG=en_US.utf8 ansible-playbook -i localhost, --connection=local run-nitro-nodes.yml --extra-vars='{ "target_host": "localhost", "skip_container_build": true }' -kK --user $USER
|
LANG=en_US.utf8 ansible-playbook -i hosts.ini run-nitro-nodes.yml --extra-vars='{ "target_host": "nitro_host", "skip_container_build": true }' --user $USER -kK
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### On Remote Host
|
||||||
|
|
||||||
|
To run the playbook on a remote host:
|
||||||
|
|
||||||
|
- Create a new `hosts.ini` file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp ../hosts.example.ini hosts.ini
|
||||||
|
```
|
||||||
|
|
||||||
|
- Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[<deployment_host>]
|
||||||
|
<host_name> ansible_host=<target_ip> ansible_user=<ssh_user> ansible_ssh_common_args='-o ForwardAgent=yes'
|
||||||
|
```
|
||||||
|
|
||||||
|
- Replace `<deployment_host>` with `nitro_host`
|
||||||
|
- Replace `<host_name>` with the alias of your choice
|
||||||
|
- Replace `<target_ip>` with the IP address or hostname of the target machine
|
||||||
|
- Replace `<ssh_user>` with the SSH username (e.g., dev, ubuntu)
|
||||||
|
|
||||||
|
- Verify that you are able to connect to the host using the following command
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ansible all -m ping -i hosts.ini -k
|
||||||
|
|
||||||
|
# Expected output:
|
||||||
|
|
||||||
|
# <host_name> | SUCCESS => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "discovered_interpreter_python": "/usr/bin/python3.10"
|
||||||
|
# },
|
||||||
|
# "changed": false,
|
||||||
|
# "ping": "pong"
|
||||||
|
# }
|
||||||
|
```
|
||||||
|
|
||||||
|
- Copy and edit the [`nitro-vars.yml`](./nitro-vars.yml) file as described in the [local setup](./README.md#run-nitro-node-on-local-host) section
|
||||||
|
|
||||||
|
- Execute the `run-nitro-nodes.yml` Ansible playbook for remote deployment:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
LANG=en_US.utf8 ansible-playbook -i hosts.ini run-nitro-nodes.yml --extra-vars='{ "target_host": "nitro_host"}' --user $USER -kK
|
||||||
|
```
|
||||||
|
|
||||||
|
- For skipping container build, run with `"skip_container_build" : true` in the `--extra-vars` parameter:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
LANG=en_US.utf8 ansible-playbook -i hosts.ini run-nitro-nodes.yml --extra-vars='{ "target_host": "nitro_host", "skip_container_build": true }' --user $USER -kK
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Check Deployment Status
|
## Check Deployment Status
|
||||||
|
|
||||||
- Run the following command in the directory where the deployments are created
|
- Run the following command in the directory where the deployments are created
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
target_host: "localhost"
|
target_host: "localhost"
|
||||||
nitro_directory: ./out
|
nitro_directory: out
|
||||||
skip_container_build: false
|
skip_container_build: false
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
NITRO_CHAIN_URL={{ nitro_l1_chain_url }}
|
NITRO_CHAIN_URL={{ nitro_l1_chain_url }}
|
||||||
NITRO_SC_PK={{ nitro_sc_pk }}
|
NITRO_SC_PK={{ nitro_sc_pk }}
|
||||||
NITRO_CHAIN_PK={{ nitro_chain_pk }}
|
NITRO_CHAIN_PK={{ nitro_chain_pk }}
|
||||||
NA_ADDRESS={{ na_address }}
|
NA_ADDRESS="{{ na_address }}"
|
||||||
VPA_ADDRESS={{ vpa_address }}
|
VPA_ADDRESS="{{ vpa_address }}"
|
||||||
CA_ADDRESS={{ ca_address }}
|
CA_ADDRESS="{{ ca_address }}"
|
||||||
NITRO_BOOTPEERS={{ nitro_l1_bridge_multiaddr }}
|
NITRO_BOOTPEERS={{ nitro_l1_bridge_multiaddr }}
|
||||||
NITRO_EXT_MULTIADDR={{ nitro_l1_ext_multiaddr }}
|
NITRO_EXT_MULTIADDR={{ nitro_l1_ext_multiaddr }}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
NITRO_CHAIN_URL={{ nitro_l2_chain_url }}
|
NITRO_CHAIN_URL={{ nitro_l2_chain_url }}
|
||||||
NITRO_SC_PK={{ nitro_sc_pk }}
|
NITRO_SC_PK={{ nitro_sc_pk }}
|
||||||
NITRO_CHAIN_PK={{ nitro_chain_pk }}
|
NITRO_CHAIN_PK={{ nitro_chain_pk }}
|
||||||
NA_ADDRESS={{ na_address }}
|
NA_ADDRESS="{{ na_address }}"
|
||||||
VPA_ADDRESS={{ vpa_address }}
|
VPA_ADDRESS="{{ vpa_address }}"
|
||||||
CA_ADDRESS={{ ca_address }}
|
CA_ADDRESS="{{ ca_address }}"
|
||||||
BRIDGE_ADDRESS={{ bridge_contract_address }}
|
BRIDGE_ADDRESS="{{ bridge_contract_address }}"
|
||||||
NITRO_BOOTPEERS={{ nitro_l2_bridge_multiaddr }}
|
NITRO_BOOTPEERS={{ nitro_l2_bridge_multiaddr }}
|
||||||
NITRO_EXT_MULTIADDR={{ nitro_l2_ext_multiaddr }}
|
NITRO_EXT_MULTIADDR={{ nitro_l2_ext_multiaddr }}
|
||||||
NITRO_L2=true
|
NITRO_L2=true
|
||||||
|
1
stack-orchestrator-setup/.gitignore
vendored
Normal file
1
stack-orchestrator-setup/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
hosts.ini
|
100
stack-orchestrator-setup/README.md
Normal file
100
stack-orchestrator-setup/README.md
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
# stack-orchestrator-setup
|
||||||
|
|
||||||
|
## Setup Ansible
|
||||||
|
|
||||||
|
To get started, follow the [installation](../README.md#installation) guide to setup ansible on your machine.
|
||||||
|
|
||||||
|
## Setup Stack Orchestrator
|
||||||
|
|
||||||
|
This playbook will install Docker and Stack Orchestrator (laconic-so) on the machine if they aren't already present.
|
||||||
|
|
||||||
|
Run the following commands in the [`stack-orchestrator-setup`](./) directory.
|
||||||
|
|
||||||
|
### On Local Host
|
||||||
|
|
||||||
|
To setup stack orchestrator and docker locally, execute the `setup-laconic-so.yml` Ansible playbook:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
LANG=en_US.utf8 ansible-playbook setup-laconic-so.yml --user $USER -kK
|
||||||
|
```
|
||||||
|
|
||||||
|
### On Remote Host
|
||||||
|
|
||||||
|
To run the playbook on a remote host:
|
||||||
|
|
||||||
|
- Create a new `hosts.ini` file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp ../hosts.example.ini hosts.ini
|
||||||
|
```
|
||||||
|
|
||||||
|
- Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[deployment_host]
|
||||||
|
<host_name> ansible_host=<target_ip> ansible_user=<ssh_user> ansible_ssh_common_args='-o ForwardAgent=yes'
|
||||||
|
```
|
||||||
|
|
||||||
|
- Replace `<host_name>` with the alias of your choice
|
||||||
|
- Replace `<target_ip>` with the IP address or hostname of the target machine
|
||||||
|
- Replace `<ssh_user>` with the SSH username (e.g., dev, ubuntu)
|
||||||
|
|
||||||
|
- Verify that you are able to connect to the host using the following command
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ansible all -m ping -i hosts.ini -k
|
||||||
|
|
||||||
|
# Expected output:
|
||||||
|
|
||||||
|
# <host_name> | SUCCESS => {
|
||||||
|
# "ansible_facts": {
|
||||||
|
# "discovered_interpreter_python": "/usr/bin/python3.10"
|
||||||
|
# },
|
||||||
|
# "changed": false,
|
||||||
|
# "ping": "pong"
|
||||||
|
# }
|
||||||
|
```
|
||||||
|
|
||||||
|
- Execute the `setup-laconic-so.yml` Ansible playbook for setting up stack orchestrator and docker on a remote machine:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
LANG=en_US.utf8 ansible-playbook setup-laconic-so.yml -i hosts.ini --extra-vars='{ "target_host": "deployment_host"}' --user $USER -kK
|
||||||
|
```
|
||||||
|
|
||||||
|
## Verify Installation
|
||||||
|
|
||||||
|
- After the installation is complete, verify if `$HOME/bin` is already included in your PATH by running:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
echo $PATH | grep -q "$HOME/bin" && echo "$HOME/bin is already in PATH" || echo "$HOME/bin is not in PATH"
|
||||||
|
```
|
||||||
|
If the command outputs `"$HOME/bin is not in PATH"`, you'll need to add it to your `PATH`.
|
||||||
|
|
||||||
|
- To add `$HOME/bin` to your PATH, run the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export PATH="$HOME/bin:$PATH"
|
||||||
|
```
|
||||||
|
|
||||||
|
- To make this change permanent, add the following line to your shell configuration file (`~/.bashrc` or `~/.zshrc`, depending on your shell):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# For bash users
|
||||||
|
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
|
||||||
|
|
||||||
|
# For zsh users
|
||||||
|
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.zshrc
|
||||||
|
```
|
||||||
|
|
||||||
|
- Once the PATH is set, verify the installation by running the following commands:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Check version of docker
|
||||||
|
docker --version
|
||||||
|
|
||||||
|
# Check version of docker compose
|
||||||
|
docker compose version
|
||||||
|
|
||||||
|
# Check version of Stack Orchestrator
|
||||||
|
laconic-so version
|
||||||
|
```
|
91
stack-orchestrator-setup/setup-docker.yml
Normal file
91
stack-orchestrator-setup/setup-docker.yml
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
- name: Set up Docker
|
||||||
|
hosts: "{{ target_host }}"
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
vars:
|
||||||
|
target_host: "localhost"
|
||||||
|
docker_gpg_key_url: "https://download.docker.com/linux/ubuntu/gpg"
|
||||||
|
docker_gpg_key_path: "/etc/apt/keyrings/docker.asc"
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Check if Docker is installed
|
||||||
|
command: which docker
|
||||||
|
register: is_docker_present
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Exit if docker is present
|
||||||
|
debug:
|
||||||
|
msg: "Docker already on host, ending play"
|
||||||
|
- meta: end_play
|
||||||
|
when: is_docker_present.rc == 0
|
||||||
|
|
||||||
|
- name: Update apt cache
|
||||||
|
apt:
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
|
- name: Install prerequisites
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- ca-certificates
|
||||||
|
- curl
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Ensure keyrings directory exists
|
||||||
|
file:
|
||||||
|
path: "/etc/apt/keyrings"
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: Download Docker GPG key
|
||||||
|
get_url:
|
||||||
|
url: "{{ docker_gpg_key_url }}"
|
||||||
|
dest: "{{ docker_gpg_key_path }}"
|
||||||
|
mode: '0644'
|
||||||
|
|
||||||
|
- name: Get system architecture
|
||||||
|
shell: dpkg --print-architecture
|
||||||
|
register: system_arch
|
||||||
|
|
||||||
|
- name: Add Docker repository
|
||||||
|
apt_repository:
|
||||||
|
repo: "deb [arch={{ system_arch.stdout }} signed-by={{ docker_gpg_key_path }}] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable"
|
||||||
|
state: present
|
||||||
|
filename: docker
|
||||||
|
|
||||||
|
- name: Update apt cache
|
||||||
|
apt:
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
|
- name: Install Docker packages
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- docker-ce
|
||||||
|
- docker-ce-cli
|
||||||
|
- containerd.io
|
||||||
|
- docker-buildx-plugin
|
||||||
|
- docker-compose-plugin
|
||||||
|
state: latest
|
||||||
|
notify: Restart Docker
|
||||||
|
|
||||||
|
- name: Add user to docker group
|
||||||
|
user:
|
||||||
|
name: "{{ ansible_user }}"
|
||||||
|
groups: docker
|
||||||
|
append: true
|
||||||
|
|
||||||
|
- name: Verify Docker installation by running the hello world image
|
||||||
|
command: docker run hello-world
|
||||||
|
register: hello_world_output
|
||||||
|
ignore_errors: true
|
||||||
|
become: no
|
||||||
|
|
||||||
|
- name: Display hello-world output
|
||||||
|
debug:
|
||||||
|
var: hello_world_output.stdout_lines
|
||||||
|
|
||||||
|
handlers:
|
||||||
|
- name: Restart Docker
|
||||||
|
service:
|
||||||
|
name: docker
|
||||||
|
state: restarted
|
57
stack-orchestrator-setup/setup-laconic-so.yml
Normal file
57
stack-orchestrator-setup/setup-laconic-so.yml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
- name: Install Docker if it isn't present
|
||||||
|
import_playbook: setup-docker.yml
|
||||||
|
|
||||||
|
- name: Set up Stack Orchestrator
|
||||||
|
hosts: "{{ target_host }}"
|
||||||
|
|
||||||
|
vars:
|
||||||
|
target_host: "localhost"
|
||||||
|
|
||||||
|
environment:
|
||||||
|
PATH: "{{ ansible_env.PATH }}:/home/{{ansible_user}}/bin"
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Check if Stack Orchestrator is installed
|
||||||
|
shell: which laconic-so
|
||||||
|
register: is_so_present
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Exit if Stack Orchestrator is present
|
||||||
|
debug:
|
||||||
|
msg: "Stack Orchestrator already on host, ending play"
|
||||||
|
- meta: end_play
|
||||||
|
when: is_so_present.rc == 0
|
||||||
|
|
||||||
|
- name: Install jq
|
||||||
|
apt:
|
||||||
|
name: jq
|
||||||
|
state: present
|
||||||
|
update_cache: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- name: Ensure that directory ~/bin exists and is writable
|
||||||
|
file:
|
||||||
|
path: "{{ ansible_env.HOME }}/bin"
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: Download the laconic-so binary
|
||||||
|
get_url:
|
||||||
|
url: https://git.vdb.to/cerc-io/stack-orchestrator/releases/download/latest/laconic-so
|
||||||
|
dest: "{{ ansible_env.HOME }}/bin/laconic-so"
|
||||||
|
mode: '0755'
|
||||||
|
force: yes
|
||||||
|
|
||||||
|
- name: Ensure ~/.laconic-so directory exists
|
||||||
|
file:
|
||||||
|
path: "{{ ansible_env.HOME }}/.laconic-so"
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: Save the distribution url to ~/.laconic-so directory
|
||||||
|
copy:
|
||||||
|
dest: "{{ ansible_env.HOME }}/.laconic-so/config.yml"
|
||||||
|
content: |
|
||||||
|
distribution-url: https://git.vdb.to/cerc-io/stack-orchestrator/releases/download/latest/laconic-so
|
||||||
|
mode: '0644'
|
Loading…
Reference in New Issue
Block a user