diff --git a/README.md b/README.md index 4031661..3c7b3d7 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ ## Playbooks +- [stack-orchestrator-setup](./stack-orchestrator-setup/README.md) - [l2-setup](./l2-setup/README.md) - [nitro-node-setup](./nitro-nodes-setup/README.md) - [nitro-bridge-setup](./nitro-bridge-setup/README.md) diff --git a/nitro-bridge-setup/run-nitro-bridge.yml b/nitro-bridge-setup/run-nitro-bridge.yml index e601abc..d9d33b4 100644 --- a/nitro-bridge-setup/run-nitro-bridge.yml +++ b/nitro-bridge-setup/run-nitro-bridge.yml @@ -62,7 +62,7 @@ wait_for: path: "{{ nitro_directory }}/bridge-deployment/data/nitro_deployment/nitro-addresses.json" state: present - timeout: 60 + 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" diff --git a/nitro-contracts-setup/README.md b/nitro-contracts-setup/README.md index 6a93e05..6e3c95d 100644 --- a/nitro-contracts-setup/README.md +++ b/nitro-contracts-setup/README.md @@ -8,10 +8,10 @@ To get started, follow the [installation](../README.md#installation) guide to se The following commands have to be executed in the [`nitro-contracts-setup`](./) directory: -- Copy the `contract-vars-example.yml` vars file +- Copy the `contract-vars.example.yml` vars file ```bash - cp contract-vars-example.yml contract-vars.yml + cp contract-vars.example.yml contract-vars.yml ``` - Edit [`contract-vars.yml`](./contract-vars.yml) and fill in the following values diff --git a/nitro-contracts-setup/deploy-contracts.yml b/nitro-contracts-setup/deploy-contracts.yml index 587495e..e5c9c29 100644 --- a/nitro-contracts-setup/deploy-contracts.yml +++ b/nitro-contracts-setup/deploy-contracts.yml @@ -61,7 +61,7 @@ - name: Wait for the contracts to be deployed wait_for: path: "{{ nitro_directory }}/nitro-contracts-deployment/data/nitro_deployment/nitro-addresses.json" - timeout: 60 + 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" diff --git a/nitro-nodes-setup/README.md b/nitro-nodes-setup/README.md index 33eb5af..8d86ba9 100644 --- a/nitro-nodes-setup/README.md +++ b/nitro-nodes-setup/README.md @@ -16,7 +16,7 @@ To run the playbook on a remote host: 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 cp nitro-vars.example.yml nitro-vars.yml diff --git a/stack-orchestrator-setup/.gitignore b/stack-orchestrator-setup/.gitignore new file mode 100644 index 0000000..788482a --- /dev/null +++ b/stack-orchestrator-setup/.gitignore @@ -0,0 +1 @@ +hosts.ini diff --git a/stack-orchestrator-setup/README.md b/stack-orchestrator-setup/README.md new file mode 100644 index 0000000..7903e48 --- /dev/null +++ b/stack-orchestrator-setup/README.md @@ -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] + ansible_host= ansible_user= ansible_ssh_common_args='-o ForwardAgent=yes' + ``` + + - Replace `` with the alias of your choice + - Replace `` with the IP address or hostname of the target machine + - Replace `` 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: + + # | 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 + ``` diff --git a/stack-orchestrator-setup/setup-docker.yml b/stack-orchestrator-setup/setup-docker.yml new file mode 100644 index 0000000..c4392dc --- /dev/null +++ b/stack-orchestrator-setup/setup-docker.yml @@ -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 diff --git a/stack-orchestrator-setup/setup-laconic-so.yml b/stack-orchestrator-setup/setup-laconic-so.yml new file mode 100644 index 0000000..0696efc --- /dev/null +++ b/stack-orchestrator-setup/setup-laconic-so.yml @@ -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'