Add instructions to run Ansible playbooks on remote machines #5

Merged
nabarun merged 14 commits from deep-stack/testnet-ops:ag-run-remote into main 2024-09-09 13:37:42 +00:00
5 changed files with 273 additions and 147 deletions
Showing only changes of commit 566072ff48 - Show all commits

View File

@ -36,44 +36,6 @@
- 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>
## Setup Remote Hosts
To run the playbook on a remote machine, setup the required ansible inventory:
- Create a new `hosts.ini` file:
```bash
cp example-hosts.ini hosts.ini
```
- Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine:
```bash
[<deployment_host>]
<host_name> ansible_host=<target_ip> ansible_user=<ssh_user> ansible_ssh_common_args='-o ForwardAgent=yes'
```
- Replace `<deployment_host>` with the appropriate host group for the deployment
- 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"
# }
```
## Playbooks ## Playbooks
- [l2-setup](./l2-setup/README.md) - [l2-setup](./l2-setup/README.md)

View File

@ -4,27 +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 for Remote Host ## Setup and Run L2 on Local Host
To run the playbook on a remote host: The following commands have to be executed in the [`l2-setup`](./) directory:
- Follow steps from [setup remote hosts](../README.md#setup-remote-hosts) - Copy the `l2-vars.example.yml` vars file:
- Update / append the [`hosts.ini`](../hosts.ini) file for your remote host with `<deployment_host>` set as `l2_host`
## Setup and Run Optimism
The following commands have to be executed in [`l2-setup`](./) directory
- Copy the `l2-vars-example.yml` vars file
```bash ```bash
cp l2-vars-example.yml l2-vars.yml cp l2-vars.example.yml l2-vars.yml
``` ```
- Edit [`l2-vars.yml`](./l2-vars.yml) with the required values - Edit [`l2-vars.yml`](./l2-vars.yml) with the required values:
```bash ```yaml
# L1 chain ID # L1 chain ID
l1_chain_id: "" l1_chain_id: ""
@ -48,41 +40,95 @@ 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 one of the following commands: - To setup and run L2 locally, execute the `run-optimism.yml` Ansible playbook:
- For local deployment, specify the `"target_host": localhost` in the `--extra-vars` parameter:
```bash ```bash
LANG=en_US.utf8 ansible-playbook 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"}' -kK --user $USER
``` ```
- For remote deployment, provide an inventory and specify the `"target_host": l2_host` 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.
```bash
LANG=en_US.utf8 ansible-playbook -i ../hosts.ini run-optimism.yml --extra-vars='{ "target_host": "l2_host"}' -kK
```
NOTE: By default, deployments are created in a `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: - For skipping container build, set `"skip_container_build" : true` in the `--extra-vars` parameter:
```bash ```bash
LANG=en_US.utf8 ansible-playbook -i ../hosts.ini run-optimism.yml --extra-vars='{"target_host" : "l2_host", "skip_container_build": true}' -kK LANG=en_US.utf8 ansible-playbook run-optimism.yml --extra-vars='{"target_host" : "localhost", "skip_container_build": true}' -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 ../hosts.ini run-optimism.yml --extra-vars='{"target_host" : "l2_host", "existing_contracts_deployment": true}' -kK LANG=en_US.utf8 ansible-playbook run-optimism.yml --extra-vars='{"target_host" : "localhost", "existing_contracts_deployment": true}' -kK
```
## Setup and Run 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"
# }
```
- Copy and edit the `l2-vars.yml` file as described in the Local Setup section.
- 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"}' -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}' -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}' -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:

View File

@ -4,25 +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 for Remote Host ## Setup and Run Nitro Bridge on Local Host
To run the playbook on a remote host: The following commands have to be executed in the [`nitro-bridge-setup`](./) directory:
- Follow steps from [setup remote hosts](../README.md#setup-remote-hosts) - Copy the `bridge-vars.example.yml` vars file:
- Update / append the [`hosts.ini`](../hosts.ini) file for your remote host with `<deployment_host>` set as `nitro_host`
## Run Nitro Bridge
- Copy the `bridge-vars-example.yml` vars file
```bash ```bash
cp bridge-vars-example.yml bridge-vars.yml cp bridge-vars.example.yml bridge-vars.yml
``` ```
- Edit [`bridge-vars.yml`](./bridge-vars.yml) and fill in the following values - Edit [`bridge-vars.yml`](./bridge-vars.yml) with the required values:
```bash ```yaml
# L1 WS endpoint # L1 WS endpoint
nitro_l1_chain_url: "" nitro_l1_chain_url: ""
@ -57,26 +51,70 @@ To run the playbook on a remote host:
l1_asset_address: "" l1_asset_address: ""
``` ```
- To run the nitro bridge, execute the `run-nitro-bridge.yml` Ansible playbook by running one of the following commands: - To setup and run nitro bridge locally, execute the `run-nitro-bridge.yml` Ansible playbook:
- For local deployment, specify the `"target_host": localhost` in the `--extra-vars` parameter:
```bash ```bash
LANG=en_US.utf8 ansible-playbook run-nitro-bridge.yml --extra-vars='{ "target_host": "localhost"}' --user $USER -kK LANG=en_US.utf8 ansible-playbook run-nitro-bridge.yml --extra-vars='{ "target_host": "localhost"}' -kK --user $USER
``` ```
- For remote deployment, provide an inventory and specify the `"target_host": nitro_host` in the `--extra-vars` parameter: 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 ```bash
LANG=en_US.utf8 ansible-playbook -i ./hosts.ini run-nitro-bridge.yml --extra-vars='{ "target_host": "nitro_host"}' --user $USER -kK LANG=en_US.utf8 ansible-playbook run-nitro-bridge.yml --extra-vars='{"target_host" : "localhost", "skip_container_build": true}' -kK --user $USER
``` ```
NOTE: By default, deployments are created in the `out` directory. To change this location, update the `nitro_directory` variable in the [setup-vars.yml](./setup-vars.yml) file. ## Setup and Run Nitro Bridge 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 `bridge-vars.yml` file as described in the Local Setup section.
- 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"}' -kK
```
- For skipping container build, run with `"skip_container_build" : true` in the `--extra-vars` parameter: - For skipping container build, run with `"skip_container_build" : true` in the `--extra-vars` parameter:
```bash ```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 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 ## Check Deployment Status

View File

@ -4,17 +4,9 @@
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 for Remote Host ## Deploy Nitro Contracts on Local Host
To run the playbook on a remote host: The following commands have to be executed in the [`nitro-contracts-setup`](./) directory:
- 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`
## Deploy Nitro Contracts
The following commands have to be executed in [`nitro-contracts-setup`](./) directory
- Copy the `contract-vars-example.yml` vars file - Copy the `contract-vars-example.yml` vars file
@ -40,27 +32,70 @@ The following commands have to be executed in [`nitro-contracts-setup`](./) dire
intial_token_supply: "129600" intial_token_supply: "129600"
``` ```
- To deploy the L1 nitro contracts, execute the `deploy-contracts.yml` Ansible playbook by running one of the following commands: - To deploy nitro contracts locally, execute the `deploy-contracts.yml` Ansible playbook:
- For local deployment, specify the `"target_host": localhost` in the `--extra-vars` parameter:
```bash ```bash
LANG=en_US.utf8 ansible-playbook deploy-contracts.yml --extra-vars='{ "target_host": "localhost"}' --user $USER -kK LANG=en_US.utf8 ansible-playbook deploy-contracts.yml --extra-vars='{ "target_host": "localhost"}' -kK --user $USER
``` ```
- For remote deployment, provide an inventory and specify the `"target_host": nitro_host` in the `--extra-vars` parameter: 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 ```bash
LANG=en_US.utf8 ansible-playbook -i ./hosts.ini deploy-contracts.yml --extra-vars='{ "target_host": "nitro_host"}' --user $USER -kK LANG=en_US.utf8 ansible-playbook deploy-contracts.yml --extra-vars='{"target_host" : "localhost", "skip_container_build": true}' -kK --user $USER
``` ```
## Deploy Nitro Contracts on Remote Host
NOTE: By default, deployments are created in the `nitro-contracts-setup/out` directory. To change this location, update the `nitro_directory` variable in the [setup-vars.yml](./setup-vars.yml) file. 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 [`contract-vars.yml`](./contract-vars.yml) file as described in the Local Setup section
- 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"}' -kK
```
- For skipping container build, run with `"skip_container_build" : true` in the `--extra-vars` parameter: - For skipping container build, run with `"skip_container_build" : true` in the `--extra-vars` parameter:
```bash ```bash
LANG=en_US.utf8 ansible-playbook -i ./hosts.ini deploy-contracts.yml --extra-vars='{ "target_host": "localhost", "skip_container_build": true }' --user $USER -kK 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 ## Check Deployment Status

View File

@ -12,14 +12,14 @@ To run the playbook on a remote host:
- Update / append the [`hosts.ini`](../hosts.ini) file for your remote host with `<deployment_host>` set as `nitro_host` - Update / append the [`hosts.ini`](../hosts.ini) file for your remote host with `<deployment_host>` set as `nitro_host`
## Run a nitro node ## Run Nitro Node on Local Host
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
@ -64,28 +64,73 @@ 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 one of the following commands: - To run a nitro node, execute the `run-nitro-nodes.yml` Ansible playbook by running the following command:
- For local deployment, specify the `"target_host": localhost` in the `--extra-vars` parameter:
```bash ```bash
LANG=en_US.utf8 ansible-playbook 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"}' -kK --user $USER
``` ```
- For remote deployment, provide an inventory and specify the `"target_host": nitro_host` 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"}' -kK --user $USER
```
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. 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: - For skipping container build, run with `"skip_container_build" : true` in the `--extra-vars` parameter:
```bash ```bash
LANG=en_US.utf8 ansible-playbook -i ./hosts.ini run-nitro-nodes.yml --extra-vars='{ "target_host": "nitro_host", "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 }' -kK --user $USER
``` ```
## Run Nitro Node 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 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"}' -kK --user $USER
```
- 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