Skip to content
Snippets Groups Projects
Commit 4fe7813c authored by geant-release-service's avatar geant-release-service
Browse files

Finished release 1.5.

parents 0e15f35e e66bf5e9
No related branches found
No related tags found
No related merge requests found
Showing
with 10 additions and 420 deletions
name: "Sphinx: render docs"
on:
push:
branches:
- develop
jobs:
docs:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install requirements
run: |
python3 -m pip install -r requirements.txt
python3 -m pip install -e .
- name: Build documentation
run: TZ=UTC sphinx-build -b html docs/source docs/build
- uses: peaceiris/actions-gh-pages@v3
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/build/
enable_jekyll: false
__pycache__
.coverage
.idea
.vscode
.tox
coverage.xml
*.egg-info
docs/build
docs/source/_static/openapi.json
docs/vale/styles/*
!docs/vale/styles/config/
venv/
.venv/
......
---
stages:
- tox
- documentation
- sonarqube
- trigger_jenkins_build
include:
- docs/.gitlab-ci.yml
#################################### tox - Testing and linting
run-tox-pipeline:
stage: tox
tags:
- docker-executor
image: python:3.11
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/topics/caching/
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
paths:
- .cache/pip
before_script:
- pip install virtualenv
- virtualenv venv
- . venv/bin/activate
- pip install tox
script:
- tox
artifacts:
paths:
- htmlcov
- docs/source/_static/openapi.json
sonarqube:
stage: sonarqube
image: sonarsource/sonar-scanner-cli
script:
- sonar-scanner -Dsonar.login=$SONAR_TOKEN -Dproject.settings=./sonar.properties
tags:
- docker-executor
trigger_jenkins_build:
stage: trigger_jenkins_build
image: alpine:latest
......
# Changelog
All notable changes to this project will be documented in this file.
## [1.5] - 2024-03-12
GAP Ansible collection version is pinned to 1.0.51
## [1.4] - 2024-02-27
GAP Ansible collection version is pinned to 1.0.49
## [1.3] - 2024-02-09
......
FROM python:3.11-alpine
ARG ARTIFACT_VERSION
# We have to pin to 3.11 due to ncclient not supporting python 3.12 as of 2024-03-11
WORKDIR /app
COPY ./requirements.txt ./requirements.txt
COPY ./ansible-galaxy-requirements.yaml ./ansible-galaxy-requirements.yaml
RUN apk add --update --no-cache gcc libc-dev libffi-dev curl vim bash openssh
RUN pip install \
--pre \
--trusted-host 150.254.211.2 \
--extra-index-url https://150.254.211.2/artifactory/api/pypi/geant-swd-pypi/simple \
goat-lso==${ARTIFACT_VERSION}
RUN pip install orchestrator-lso=="1.0.1"
RUN pip install -r requirements.txt
RUN ansible-galaxy install \
-r ansible-galaxy-requirements.yaml \
-p /app/gap/ansible
RUN ansible-galaxy collection install \
-r ansible-galaxy-requirements.yaml \
-p /app/gap/ansible
EXPOSE 8000
ENTRYPOINT []
CMD ["python", "-m", "uvicorn", "lso.app:app", "--host", "0.0.0.0", "--port", "8000"]
......@@ -3,6 +3,6 @@ collections:
- juniper.device
- junipernetworks.junos
- name: geant.gap_ansible
version: 1.0.49
version: 1.0.51
roles:
- Juniper.junos
#!/bin/sh
set -o errexit
set -o nounset
pip install -r requirements.txt
pip install -e .
rm -r ./docs/build/*
vale --config=docs/vale/.vale.ini sync
vale --config=docs/vale/.vale.ini docs/source/*.rst lso/*.py
sphinx-build -b html docs/source docs/build
---
##### Vale - Documentation linter
lint-documentation:
stage: documentation
image:
name: jdkato/vale:latest
entrypoint: [""]
tags:
- docker-executor
needs:
- job: run-tox-pipeline # Only run when tox has finished
before_script:
- cd $CI_PROJECT_DIR/docs/vale
- vale sync
script:
- vale $CI_PROJECT_DIR/docs/source/*.rst $CI_PROJECT_DIR/lso/*.py
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.wy-menu > p > span {
color: rgb(237 21 86);
}
section > dl > .sig-object {
background: #e5e8e8 !important;
color: rgb(237 21 86) !important;
border-top: 3px solid rgb(167 179 180) !important;
}
.code.literal {
color: rgb(226 67 1) !important;
}
<svg width="79" height="35" viewBox="0 0 79 35" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_101_15)">
<path d="M15.9 17.8C16.5 17.3 17 17.1 17.4 17.1C18.4 17.1 18.7 17.8 18.7 18.2C18.5 18.3 14.2 19.7 14 19.8C13.9 19.7 13.9 19.6 13.8 19.6C14 19.4 15.9 17.8 15.9 17.8Z" fill="white" fill-opacity="0.85"/>
<path d="M0 27C0 31.8 2.1 34.3 6.3 34.3C9.1 34.3 10.8 33.1 10.8 33L10.9 32.9V26.2H5.2V28.1C5.2 28.1 8.1 28.1 8.6 28.1C8.6 28.6 8.6 31.6 8.6 31.9C8.3 32.1 7.4 32.4 6.2 32.4C3.7 32.4 2.5 30.6 2.5 27C2.5 24.9 3.1 22.4 5.9 22.4C7.8 22.4 8.5 23.5 8.5 24.5V24.8H11.1V24.5C11.1 22.1 9 20.5 5.9 20.5C2.2 20.5 0 22.9 0 27Z" fill="white" fill-opacity="0.85"/>
<path d="M20.2 20.7H12.6V34.1H20.7V32.2C20.7 32.2 15.5 32.2 14.9 32.2C14.9 31.7 14.9 28.5 14.9 28C15.5 28 20.2 28 20.2 28V26.1C20.2 26.1 15.5 26.1 14.9 26.1C14.9 25.6 14.9 23 14.9 22.5C15.5 22.5 20.5 22.5 20.5 22.5V20.6H20.2V20.7Z" fill="white" fill-opacity="0.85"/>
<path d="M54.5 20.7H42.9C42.9 20.7 42.9 28.7 42.9 30.6C42 29 37.2 20.7 37.2 20.7H34.5V34.1H36.8C36.8 34.1 36.8 26.1 36.8 24.2C37.7 25.8 42.5 34.1 42.5 34.1H45.2C45.2 34.1 45.2 23.2 45.2 22.6C45.7 22.6 48.4 22.6 48.9 22.6C48.9 23.2 48.9 34.1 48.9 34.1H51.3C51.3 34.1 51.3 23.2 51.3 22.6C51.8 22.6 54.9 22.6 54.9 22.6V20.7H54.5V20.7Z" fill="white" fill-opacity="0.85"/>
<path d="M28.9 20.7H28.7H26.4L21.4 34.1H23.8C23.8 34.1 25.1 30.6 25.3 30.2C25.7 30.2 29.8 30.2 30.2 30.2C30.3 30.6 31.7 34.1 31.7 34.1H34L28.9 20.7ZM25.9 28.3C26.1 27.6 27.3 24.4 27.7 23.3C28.1 24.4 29.2 27.6 29.5 28.3C28.7 28.3 26.6 28.3 25.9 28.3Z" fill="white" fill-opacity="0.85"/>
<path d="M77 8C68.2 -2.9 32.6 12.5 23 16.5C22.3 16.8 21.4 16.7 20.9 15.7C21.3 16.7 22.1 17.1 23.1 16.7C35.8 11.6 66.5 0.600002 74.2 10.7C77.7 15.3 76.7 20.9 72.9 28.8C72.7 29.1 72.6 29.4 72.6 29.4C72.6 29.4 72.6 29.4 72.6 29.5C72.6 29.5 72.6 29.5 72.6 29.6C72.3 30.1 71.9 30.3 71.6 30.4C72 30.4 72.5 30.2 72.9 29.6C73 29.5 73.1 29.3 73.3 29C78.7 19.5 80.7 12.5 77 8Z" fill="white" fill-opacity="0.85"/>
<path d="M70.3 29.9C70.2 29.8 68.6 28.4 67 26.9C58.7 19 33.4 -5.3 22.4 1.1C19.3 2.9 18.8 8.2 20.7 15.2C20.7 15.3 20.8 15.4 20.8 15.5C21 16.2 21.5 16.7 22.2 16.7C21.7 16.6 21.3 16.2 21.1 15.7C21.1 15.6 21 15.5 21 15.5C21 15.4 20.9 15.3 20.9 15.1C20.9 15 20.9 14.9 20.8 14.9C19.8 9 21 5.1 23.4 3.5C32.3 -2.5 53.5 15.8 64.2 25C66.6 27.1 69.4 29.5 70.2 30.1C71.4 31 72.4 30 72.7 29.5C72.3 30.1 71.3 30.7 70.3 29.9Z" fill="white" fill-opacity="0.85"/>
</g>
<defs>
<clipPath id="clip0_101_15">
<rect width="78.9" height="34.3" fill="white"/>
</clipPath>
</defs>
</svg>
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
from importlib import import_module
from docutils.parsers.rst import Directive
from docutils import nodes
from sphinx import addnodes
import json
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "lso")))
class RenderAsJSON(Directive):
# cf. https://stackoverflow.com/a/59883833
required_arguments = 1
def run(self):
module_path, member_name = self.arguments[0].rsplit(".", 1)
member_data = getattr(import_module(module_path), member_name)
code = json.dumps(member_data, indent=2)
literal = nodes.literal_block(code, code)
literal["language"] = "json"
return [
addnodes.desc_name(text=member_name),
addnodes.desc_content("", literal)
]
def setup(app):
app.add_directive("asjson", RenderAsJSON)
# -- Project information -----------------------------------------------------
project = "Lightweight Service Orchestrator"
copyright = "2023, GÉANT Vereniging"
author = "GÉANT Orchestration & Automation Team"
# -- General configuration ---------------------------------------------------
extensions = [
"sphinx_rtd_theme",
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.todo"
]
templates_path = ["templates"]
exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]
html_theme_options = {"style_nav_header_background": "rgb(0 63 95)"}
html_css_files = ["custom.css"]
html_logo = "_static/geant_logo_white.svg"
# Both the class' and the ``__init__`` method's docstring are concatenated and inserted.
autoclass_content = "both"
autodoc_typehints = "none"
# Display todos by setting to True
todo_include_todos = True
Lightweight Service Orchestrator
================================
Documentation for LSO (Lightweight Service Orchestrator).
.. toctree::
:maxdepth: 1
:caption: Contents:
quickstart
modules
``lso.config``
==============
.. automodule:: lso.config
:members:
:show-inheritance:
``lso.playbook``
================
.. automodule:: lso.playbook
:members:
:private-members:
:show-inheritance:
``lso.routes.default``
======================
.. automodule:: lso.routes.default
:members:
:show-inheritance:
``lso.routes``
==============
.. automodule:: lso.routes
:members:
:show-inheritance:
Submodules
----------
.. toctree::
:maxdepth: 2
:titlesonly:
default
playbook
``lso.routes.playbook``
=======================
.. automodule:: lso.routes.playbook
:members:
:show-inheritance:
=========================
Sub-packages and -modules
=========================
This page lists references to the documentation of all sub-packages and -modules.
Subpackages
-----------
.. toctree::
:maxdepth: 2
:titlesonly:
module/routes/index
Submodules
----------
.. toctree::
:maxdepth: 2
:titlesonly:
module/config
module/playbook
==========
.. automodule:: lso
:members:
:show-inheritance:
Quick start
===========
This is a quick setup guide for running standalone on your local machine.
As a Docker container
---------------------
To run LSO as a Docker container, build an image using the ``Dockerfile`` as an example. Be sure to update
``ansible-galaxy-requirements.yaml`` accordingly, depending on your specific Ansible collection and -role needs.
An example Docker compose file is presented below:
.. code-block:: yaml
version: "3.5"
services:
lso:
image: goat-lso:$LSO_VERSION_TAG
environment:
SETTINGS_FILENAME: /app/config.json
ANSIBLE_ROLES_PATH: /app/lso/ansible_roles
volumes:
- "/home/user/config.json:/app/config.json:ro"
- "/home/user/ansible_inventory:/opt/ansible_inventory:ro"
- "~/.ssh/id_ed25519.pub:/root/.ssh/id_rsa.pub:ro"
- "~/.ssh/id_ed25519:/root/.ssh/id_rsa:ro"
restart: unless-stopped
This will expose the API on port 8080. The container requires some more files to be mounted:
* A ``config.json`` that references to the location where the Ansible playbooks are stored **inside the container**.
* An Ansible inventory for all host and group variables that are used in the playbooks
* A public/private key pair for SSH authentication on external machines that are targeted by Ansible playbooks.
* Any Ansible-specific configuration (such as ``collections_path``, ``roles_path``, etc.) should be set using
environment variables. ``ANSIBLE_ROLES_PATH`` is given as an example in the Docker compose snippet above.
Install the module
------------------
As an alternative, below are a set of instructions for installing and running LSO directly on a machine.
*One of these should be what you're looking for:*
* Install the latest module snapshot
.. code-block:: bash
python3 -m venv my-venv-directory
. my-venv-directory/bin/activate
pip install --pre --extra-index-url https://artifactory.software.geant.org/artifactory/api/pypi/geant-swd-pypi/simple goat-lso
* Install the source code
.. code-block:: bash
python3 -m venv my-venv-directory
. my-venv-directory/bin/activate
git clone https://gitlab.software.geant.org/goat/gap/lso.git
cd lso
pip install -e .
# for a full dev environment
pip install -r requirements.txt
Running the app
---------------
* Create a settings file, see ``config.json.example`` for an example.
* If necessary, set the environment variable ``ANSIBLE_HOME`` to a custom path.
* Run the app like this (``app.py`` starts the server on port 44444):
.. code-block:: bash
SETTINGS_FILENAME=/absolute/path/to/config.json python -m lso.app
Examples
* Get the version
.. code-block:: bash
curl http://localhost:44444/api/version
* View the docs by loading http://localhost:44444/docs in your browser
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment