Skip to content

feat!: Add ccp role and rewrite nox role to allow only one nox per host #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 1 addition & 35 deletions .github/workflows/ansible.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,40 +34,15 @@ jobs:
# reporter: github-pr-check
# fail_on_error: true

collection:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v5
with:
python-version: "3.x"
cache: pip

- name: Install python dependencies
run: python -m pip install -r requirements.txt

- name: Build collection
run: ansible-galaxy collection build .

- name: Upload collection
uses: actions/upload-artifact@v4
with:
path: fluencelabs-provider-*.tar.gz
name: collection
if-no-files-found: error

molecule:
runs-on: ubuntu-latest

needs: collection

strategy:
fail-fast: false
matrix:
scenario:
- ubuntu2204
- debian12

steps:
- uses: actions/checkout@v4
Expand All @@ -89,14 +64,5 @@ jobs:
- name: Install python dependencies
run: python -m pip install -r requirements.txt

- name: Download collection
uses: actions/download-artifact@v4
with:
name: collection

- name: Install collection
run: ansible-galaxy collection install fluencelabs-provider-*.tar.gz

- name: Run ${{ matrix.scenario }} scenario
working-directory: extensions
run: molecule test --scenario-name "${{ matrix.scenario }}"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ Fluence provider toolkit.
## Roles

- [nox](https://github.com/fluencelabs/ansible/tree/main/roles/nox)
- [ccp](https://github.com/fluencelabs/ansible/tree/main/roles/ccp)
- [prerequisites](https://github.com/fluencelabs/ansible/tree/main/roles/prerequisites)
- [ipfs_cli](https://github.com/fluencelabs/ansible/tree/main/roles/ipfs_cli)
199 changes: 8 additions & 191 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

This directory contains all necessary predefined files to setup Nox locally.

You can follow this guide by [using predefined files](#Using-predefined-files)
or by [starting from scratch](#Starting-from-scratch).

## Prerequisites

### Podman
Expand All @@ -29,10 +26,11 @@ Install using commands from the
After installation, set a specific version of FCLI compatible with this guide:

```bash
fluence update --version 0.14.0
fluence update --version 0.15.17
```

### MacOS

#### gnu-tar

Users of MacOS need to install `gnu-tar` for this collection of roles to work.
Expand All @@ -42,6 +40,7 @@ brew install gnu-tar
```

#### sshpass

Users of MacOS need to install (only for running examples) `sshpass`:

```bash
Expand All @@ -60,151 +59,13 @@ podman machine start

## Setup Nox

### Using Predefined Files

- Clone this repo and change to `example` directory
``` bash
git clone https://github.com/fluencelabs/ansible
cd example
```

- Create and activate python virtual environment

```bash
python3 -m venv ~/.virtualenvs/fluence/nox-ansible-demo
source ~/.virtualenvs/fluence/nox-ansible-demo/bin/activate
```

- Install python dependencies

```bash
pip3 install -r requirements.txt
```

- Install Ansible Provider collection

```bash
ansible-galaxy collection install fluencelabs.provider
```

- Start services and servers

```bash
podman-compose up -d --build
```

- Wait for all services to start and setup Noxes

```bash
ansible-playbook nox.yml -i inventory.yml
```

- When finished run cleanup

```bash
podman-compose down
```

### Starting from Scratch

- Clone this repo and change to `example` directory
``` bash
git clone https://github.com/fluencelabs/ansible
cd example
```

- Create project directories

```bash
# create project directory
mkdir ansible-demo && cd ansible-demo
# create necessary directories for ansible
mkdir -p files/demo
cd files/demo
```

- Initialize project

```bash
fluence provider init --no-input --env=local --noxes=3
```

- Update `provider.yaml` with nox config required for Ansible

```bash
cat <<EOF | patch provider.yaml
@@ -4,13 +4,14 @@

# Documentation: https://github.com/fluencelabs/cli/tree/main/docs/configs/provider.md

-version: 0
-
env: local

computePeers:
nox-0:
computeUnits: 32
+ nox:
+ rawConfig: |
+ local = true
nox-1:
computeUnits: 32
nox-2:
@@ -24,3 +25,39 @@
- nox-0
- nox-1
- nox-2
+
+nox:
+ # you can write config overrides with yaml syntax using camelCase
+ systemServices:
+ enable:
+ - aqua-apfs
+ - decider
+
+ # or you can write config in toml
+ # some options can be set only with rawConfig
+ # this has highest priority when merging
+ rawConfig: |
+ allowed_binaries = [
+ "/usr/bin/curl",
+ # we need to set path to ipfs binary that was downloaded by role
+ "{{ nox_dir }}/ipfs",
+ ]
+
+ local = false
+ bootstrap_nodes = [
+ "/ip4/172.30.10.10/tcp/7771"
+ ]
+
+ [system_services.aqua_ipfs]
+ ipfs_binary_path = "{{ nox_dir }}/ipfs"
+ external_api_multiaddr = "/ip4/127.0.0.1/tcp/5001"
+ local_api_multiaddr = "/ip4/172.30.10.95/tcp/5001"
+
+ [system_services.decider]
+ decider_period_sec = 10
+ worker_ipfs_multiaddr = "/ip4/172.30.10.95/tcp/5001"
+ network_api_endpoint = "http://172.30.10.85:8545"
+ network_id = 31337
+ start_block = "earliest"
+ matcher_address = "0x0e1F3B362E22B2Dc82C9E35d6e62998C7E8e2349"
+ wallet_key = "0x3cc23e0227bd17ea5d6ea9d42b5eaa53ad41b1974de4755c79fe236d361a6fd5"
EOF
```

- Regenerate nox configs

```bash
fluence provider gen
```

- Change directory back

```bash
cd ../../
```

- Create and activate python virtual environment

```bash
Expand All @@ -215,10 +76,6 @@ source ~/.virtualenvs/fluence/nox-ansible-demo/bin/activate
- Install python dependencies

```bash
cat << EOF > requirements.txt
ansible==9.2.0
podman-compose
EOF
pip3 install -r requirements.txt
```

Expand All @@ -228,49 +85,6 @@ pip3 install -r requirements.txt
ansible-galaxy collection install fluencelabs.provider
```

- Create ansible inventory file

```bash
cat << EOF > inventory.yml
all:
children:
servers:
hosts:
server-0:
ansible_port: 2200
nox_instances: [0]
server-1:
ansible_port: 2201
nox_instances: [1,2]
vars:
ansible_user: "ubuntu"
ansible_password: "ubuntu"
ansible_host: "127.0.0.1"
# fluencelabs.provider.nox variables
nox_version: "0.18.0" # hardcoded compatible with fcli 0.18.1
nox_project_dir: "demo"
# fluencelabs.provider.ipfs_cli variables
ipfs_cli_version: "0.26.0"
EOF
```

- Create playbook

```bash
cat <<EOF > nox.yml
- hosts: "all"
become: true
roles:
- "fluencelabs.provider.nox"
EOF
```

- Copy `podmad-compose.yml`

```bash
cp ../podman-compose.yml .
```

- Start services and servers

```bash
Expand All @@ -283,12 +97,15 @@ podman-compose up -d --build
ansible-playbook nox.yml -i inventory.yml
```

- When finished, run cleanup
- When finished run cleanup

```bash
podman-compose down
```

## Do some things with Nox network

TODO
TODO:

- integrate IPC
- add provider registration
35 changes: 22 additions & 13 deletions example/files/demo/.fluence/configs/nox-0_Config.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
aquavm_pool_size = 2
local = true
bootstrap_nodes = [ "/ip4/172.30.10.10/tcp/7771" ]
tcp_port = 7_771
websocket_port = 9_991
http_port = 18_080
allowed_binaries = [ "/usr/bin/curl", "{{ nox_dir }}/ipfs" ]
local = true
bootstrap_nodes = [ "/ip4/172.30.10.10/tcp/7771" ]

[system_services.aqua_ipfs]
ipfs_binary_path = "{{ nox_dir }}/ipfs"
external_api_multiaddr = "/ip4/127.0.0.1/tcp/5001"
local_api_multiaddr = "/ip4/172.30.10.95/tcp/5001"
[system_services]
enable = [ "aqua-apfs", "decider" ]

[system_services.aqua_ipfs]
external_api_multiaddr = "/ip4/127.0.0.1/tcp/5001"
local_api_multiaddr = "/ip4/172.30.10.95/tcp/5001"

[system_services.decider]
decider_period_sec = 10
worker_ipfs_multiaddr = "/ip4/172.30.10.95/tcp/5001"
network_api_endpoint = "http://172.30.10.85:8545"
network_id = 31_337
start_block = "earliest"
matcher_address = "0x3Aa5ebB10DC797CAC828524e59A333d0A371443c"
wallet_key = "0x3cc23e0227bd17ea5d6ea9d42b5eaa53ad41b1974de4755c79fe236d361a6fd5"

[system_services.decider]
decider_period_sec = 10
worker_ipfs_multiaddr = "/ip4/172.30.10.95/tcp/5001"
network_api_endpoint = "http://172.30.10.85:8545"
[chain_config]
http_endpoint = "http://172.30.10.85:8545"
core_contract_address = "0x0B306BF915C4d645ff596e518fAf3F9669b97016"
cc_contract_address = "0xc6e7DF5E7b4f2A278906862b61205850344D4e7d"
market_contract_address = "0x3Aa5ebB10DC797CAC828524e59A333d0A371443c"
network_id = 31_337
start_block = "earliest"
matcher_address = "0x0e1F3B362E22B2Dc82C9E35d6e62998C7E8e2349"
wallet_key = "0x3cc23e0227bd17ea5d6ea9d42b5eaa53ad41b1974de4755c79fe236d361a6fd5"
Loading