Add Ansible playbooks to setup Docker and stack orchestrator #6
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
## 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-bridge-setup](./nitro-bridge-setup/README.md)
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
wait_for:
|
wait_for:
|
||||||
path: "{{ nitro_directory }}/bridge-deployment/data/nitro_deployment/nitro-addresses.json"
|
path: "{{ nitro_directory }}/bridge-deployment/data/nitro_deployment/nitro-addresses.json"
|
||||||
state: present
|
state: present
|
||||||
timeout: 60
|
timeout: 180
|
||||||
|
|
||||||
- name: Print BRIDGE_ADDRESS
|
- 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"
|
shell: laconic-so deployment --dir bridge-deployment exec nitro-bridge "jq -r '.\"{{ optimism_chain_id }}\"[0].contracts.Bridge.address' /app/deployment/nitro-addresses.json"
|
||||||
|
@ -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:
|
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
|
```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
|
- Edit [`contract-vars.yml`](./contract-vars.yml) and fill in the following values
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
- name: Wait for the contracts to be deployed
|
- name: Wait for the contracts to be deployed
|
||||||
wait_for:
|
wait_for:
|
||||||
path: "{{ nitro_directory }}/nitro-contracts-deployment/data/nitro_deployment/nitro-addresses.json"
|
path: "{{ nitro_directory }}/nitro-contracts-deployment/data/nitro_deployment/nitro-addresses.json"
|
||||||
timeout: 60
|
timeout: 300
|
||||||
|
|
||||||
- name: Export NA_ADDRESS
|
- 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"
|
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"
|
||||||
|
@ -16,7 +16,7 @@ To run the playbook on a remote 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
|
||||||
|
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