From 68cb5061e1a27ee08409d8d7c761c92e0dd94e93 Mon Sep 17 00:00:00 2001 From: Adw8 Date: Tue, 10 Sep 2024 10:51:24 +0530 Subject: [PATCH] Add instructions for running playbook to setup stack orchestrator --- stack-orchestrator-setup/README.md | 59 +++++++++++++++++++ stack-orchestrator-setup/setup-docker.yml | 8 +-- stack-orchestrator-setup/setup-laconic-so.yml | 19 +++++- 3 files changed, 80 insertions(+), 6 deletions(-) diff --git a/stack-orchestrator-setup/README.md b/stack-orchestrator-setup/README.md index b50b423..0620594 100644 --- a/stack-orchestrator-setup/README.md +++ b/stack-orchestrator-setup/README.md @@ -1 +1,60 @@ # stack-orchestrator-setup + +## Setup Ansible + +To get started, follow the [installation](../README.md#installation) guide to setup ansible on your machine + +## Setup Stack Orchestrator + +The following commands have to be executed in the [`stack-orchestrator-setup`](./) directory: + +### On Local Host + +To setup stack orchestrator 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 `deploy-contracts.yml` Ansible playbook for remote deployment: + + ```bash + LANG=en_US.utf8 ansible-playbook setup-laconic-so.yml -i hosts.ini --extra-vars='{ "target_host": "deployment_host"}' --user $USER -kK + ``` diff --git a/stack-orchestrator-setup/setup-docker.yml b/stack-orchestrator-setup/setup-docker.yml index fcd770b..2be8496 100644 --- a/stack-orchestrator-setup/setup-docker.yml +++ b/stack-orchestrator-setup/setup-docker.yml @@ -1,7 +1,9 @@ - name: Set up Docker - hosts: remote_host + 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" @@ -11,10 +13,6 @@ register: is_docker_present ignore_errors: yes - - name: Check if docker is present - debug: - var: "Output of `which docker` is {{ is_docker_present }}" - - block: - name: Exit if docker is present debug: diff --git a/stack-orchestrator-setup/setup-laconic-so.yml b/stack-orchestrator-setup/setup-laconic-so.yml index e8e8f67..5c1ca1b 100644 --- a/stack-orchestrator-setup/setup-laconic-so.yml +++ b/stack-orchestrator-setup/setup-laconic-so.yml @@ -2,10 +2,27 @@ import_playbook: setup-docker.yml - name: Set up Stack Orchestrator - hosts: remote_host + 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