| .. | ||
| templates | ||
| .gitignore | ||
| l2-vars-example.yml | ||
| README.md | ||
| run-optimism.yml | ||
| setup-vars.yml | ||
l2-setup
Setup Ansible
To get started, follow the installation guide to setup ansible on your machine
Setup Remote Hosts
To run the playbooks on a remote machine, follow these steps:
-
In the
l2-setupdirectory, create a new file named hosts.ini:cp ../example-hosts.ini hosts.ini -
Edit the
hosts.inifile to run the playbook on a remote machine[nitro_host] hostname ansible_host= ansible_user= ansible_ssh_common_args='-o ForwardAgent=yes'- Replace
host_namewith 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).
- Replace
-
Verify that you are able to connect to the host using the following command
ansible all -m ping -i hosts.ini
Setup and Run Optimism
The following commands have to be executed in l2-setup directory
-
Copy the
l2-vars-example.ymlvars filecp l2-vars-example.yml l2-vars.yml -
Edit
l2-vars.ymlwith the required values# L1 chain ID l1_chain_id: "" # L1 RPC endpoint l1_rpc: "" # L1 RPC endpoint host or IP address l1_host: "" # L1 RPC endpoint port number l1_port: "" # L1 Beacon endpoint l1_beacon: "" # Address of the funded account on L1 # Used for optimism contracts deployment l1_address: "" # Private key of the funded account on L1 l1_priv_key: "" -
To setup and run L2, execute the
run-optimism.ymlAnsible playbook by running one of the following commands:For local deployment:
LANG=en_US.utf8 ansible-playbook run-optimism.yml --extra-vars='{ "target_host": "localhost"}' -kK --user $USERFor remote deployment:
LANG=en_US.utf8 ansible-playbook -i ./hosts.ini run-optimism.yml --extra-vars='{ "target_host": "nitro_host"}' -kKNOTE: By default, deployments are created in a
outdirectory. To change this location, update thel2_directoryvariable in the setup-vars.yml file.-
For skipping container build, set
"skip_container_build" : truein the--extra-varsparameter:LANG=en_US.utf8 ansible-playbook -i ./hosts.ini run-optimism.yml --extra-vars='{"target_host" : "nitro_host", "skip_container_build": true}' -kK
-
-
To run using existing contracts deployment
-
Update
artifact_pathinsetup-vars.ymlfile with path to data directory of the existing deployment -
Run the ansible playbook with
"existing_contracts_deployment": truein the--extra-varsparameter:LANG=en_US.utf8 ansible-playbook -i ./hosts.ini run-optimism.yml --extra-vars='{"target_host" : "nitro_host", "existing_contracts_deployment": true}' -kK
-
Check Deployment Status
-
Run the following command in the directory where the optimism-deployment is created
-
Follow optimism contracts deployment logs:
laconic-so deployment --dir optimism-deployment logs -f fixturenet-optimism-contracts -
Check L2 logs:
laconic-so deployment --dir optimism-deployment logs -f op-geth # Ensure new blocks are getting created
-