From cd9a97f288a0740dea83635bbf53b645e55a3ab8 Mon Sep 17 00:00:00 2001 From: MichaelS Date: Tue, 4 Jun 2024 22:48:20 +0400 Subject: [PATCH] update --- ansible/provider/README.md | 10 +++ ansible/provider/inventory/group_vars/all.yml | 2 +- ansible/provider/main.yml | 6 +- .../provider/roles/prepare/defaults/main.yml | 0 ansible/provider/roles/prepare/meta/main.yml | 21 ++++++ ansible/provider/roles/prepare/tasks/main.yml | 64 +++++++++++++++++++ ansible/provider/roles/prepare/vars/main.yml | 7 ++ 7 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 ansible/provider/roles/prepare/defaults/main.yml create mode 100644 ansible/provider/roles/prepare/meta/main.yml create mode 100644 ansible/provider/roles/prepare/tasks/main.yml create mode 100644 ansible/provider/roles/prepare/vars/main.yml diff --git a/ansible/provider/README.md b/ansible/provider/README.md index 7fb9ca777e..a402d9bb13 100644 --- a/ansible/provider/README.md +++ b/ansible/provider/README.md @@ -66,6 +66,14 @@ Adjust role-specific variables in `group_vars/all.yml` and `host_vars/*.yml` to ## Deployment The deployment process involves setting directly configuring Docker networks, generating necessary configuration claims, and managing Docker containers through Docker Compose. +### Prepare VM on clean system + +If you plan to deploy on a clean Debian or Ubuntu system without an installed Docker engine, use the `prepare` tag to install additional software: +```bash +ansible-playbook main.yml --tags prepare +``` +![lava_prepare_gifsicle.gif](https://github.com/svetek/lava-ansible-deployment/blob/main/guides/lava_prepare_gifsicle.gif) + ### Deploy the Service To deploy the RPC Provider Service: @@ -75,6 +83,8 @@ ansible-playbook main.yml --tags deploy > Note that by default ```anisble-playbook main.yml``` command deploys and runs the service. +![lava_cache_provider_gifsicle.gif](https://github.com/svetek/lava-ansible-deployment/blob/main/guides/lava_cache_provider_gifsicle.gif) + ## Managing Start the Service: Ensure the service is up and running: diff --git a/ansible/provider/inventory/group_vars/all.yml b/ansible/provider/inventory/group_vars/all.yml index 1592fc64a9..47be87c4a9 100644 --- a/ansible/provider/inventory/group_vars/all.yml +++ b/ansible/provider/inventory/group_vars/all.yml @@ -4,7 +4,7 @@ ansible_user: root ansible_port: 22 project_name: lava project_type: provider -project_unique_name: "{{ project_name }}-{{ provider_name }}-{{ project_type }}" +project_unique_name: "{{ project_name }}-{{ project_type }}" service_path: /opt/services # The docker-compose.yml and a variables file are located at this path. project_path: "{{ service_path }}/{{ project_unique_name }}" # Configuration files and a wallet are located at this path. volume_path: "{{ container.volume_path }}" diff --git a/ansible/provider/main.yml b/ansible/provider/main.yml index cf10eb0eda..ad58c1fd6d 100644 --- a/ansible/provider/main.yml +++ b/ansible/provider/main.yml @@ -3,8 +3,12 @@ - name: Deploying and managing the RPC Provider Service hosts: all become: true - gather_facts: false + gather_facts: true roles: + - role: prepare + tags: + - never + - prepare - role: deploy tags: - deploy diff --git a/ansible/provider/roles/prepare/defaults/main.yml b/ansible/provider/roles/prepare/defaults/main.yml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ansible/provider/roles/prepare/meta/main.yml b/ansible/provider/roles/prepare/meta/main.yml new file mode 100644 index 0000000000..655edb8be1 --- /dev/null +++ b/ansible/provider/roles/prepare/meta/main.yml @@ -0,0 +1,21 @@ +# roles/prepare/meta/main.yml +--- +dependencies: [] +galaxy_info: + author: Michael + description: The role for deploying the lava cache service + company: Impulse Expert | https://impulse.expert + license: GPL + min_ansible_version: "2.9" + platforms: + - name: Ubuntu + versions: + - xenial + - bionic + - focal + - name: Debian + versions: + - buster + - bullseye + - bookworm + diff --git a/ansible/provider/roles/prepare/tasks/main.yml b/ansible/provider/roles/prepare/tasks/main.yml new file mode 100644 index 0000000000..7a9afc6900 --- /dev/null +++ b/ansible/provider/roles/prepare/tasks/main.yml @@ -0,0 +1,64 @@ +# roles/prepare/tasks/main.yml +--- +- name: Update the apt cache + ansible.builtin.apt: + update_cache: true + cache_valid_time: 3600 + +# Turn off: need other role process for update runtime systems +#- name: Upgrade all apt packages +# ansible.builtin.apt: +# upgrade: dist + +- name: Install necessary packages + ansible.builtin.apt: + name: + - software-properties-common + - apt-transport-https + - ca-certificates + - sudo + - aria2 + - curl + - htop + - wget + - jq + - lz4 + - rsync + state: present + +- name: Add Docker Repository for Debian + when: ansible_facts['distribution'] == "Debian" + ansible.builtin.shell: | + install -m 0755 -d /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc + chmod a+r /etc/apt/keyrings/docker.asc + + # Add the repository to Apt sources: + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + +- name: Add Docker Repository for Ubuntu + when: ansible_facts['distribution'] == "Ubuntu" + ansible.builtin.shell: | + install -m 0755 -d /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc + chmod a+r /etc/apt/keyrings/docker.asc + + # Add the repository to Apt sources: + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + +- name: Update apt and install docker-ce + ansible.builtin.apt: + name: + - docker-ce + - docker-ce-cli + - containerd.io + - docker-buildx-plugin + - docker-compose-plugin + state: present + update_cache: true \ No newline at end of file diff --git a/ansible/provider/roles/prepare/vars/main.yml b/ansible/provider/roles/prepare/vars/main.yml new file mode 100644 index 0000000000..b92e9e161f --- /dev/null +++ b/ansible/provider/roles/prepare/vars/main.yml @@ -0,0 +1,7 @@ +# roles/prepare/vars/main.yml + +# In Ansible, the priority of variable values is determined by +# the order in which they are defined, known as variable precedence. +# Variables defined in roles/deploy/vars/main.yml can override the values set in the inventory +# if they are specified later in the precedence order. +