- Shell 51.3%
- Jinja 40.5%
- Dockerfile 8.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
All checks were successful
opensvc.cluster / sanity (ansible-core 2.20, python 3.12) (push) Successful in 30s
opensvc.cluster / sanity (ansible-core 2.21, python 3.12) (push) Successful in 32s
opensvc.cluster / lint (ansible-core 2.16, python 3.12) (push) Successful in 34s
opensvc.cluster / lint (ansible-core 2.20, python 3.12) (push) Successful in 44s
opensvc.cluster / lint (ansible-core 2.21, python 3.12) (push) Successful in 45s
opensvc.cluster_v3 / sanity (ansible-core 2.16, python 3.12) (push) Successful in 37s
opensvc.cluster_v3 / sanity (ansible-core 2.19, python 3.12) (push) Successful in 32s
opensvc.cluster_v3 / sanity (ansible-core 2.20, python 3.12) (push) Successful in 32s
opensvc.cluster_v3 / sanity (ansible-core 2.21, python 3.12) (push) Successful in 30s
opensvc.cluster_v3 / sanity (ansible-core 2.22, python 3.13) (push) Successful in 31s
opensvc.cluster / sanity (ansible-core 2.16, python 3.12) (push) Successful in 35s
opensvc.cluster_v3 / lint (ansible-core 2.16, python 3.12) (push) Successful in 25s
opensvc.cluster_v3 / lint (ansible-core 2.19, python 3.12) (push) Successful in 29s
opensvc.cluster_v3 / lint (ansible-core 2.20, python 3.12) (push) Successful in 29s
opensvc.cluster_v3 / lint (ansible-core 2.21, python 3.12) (push) Successful in 27s
opensvc.cluster_v3 / lint (ansible-core 2.22, python 3.13) (push) Successful in 26s
|
||
| .forgejo/workflows | ||
| ansible_collections/opensvc | ||
| examples | ||
| .gitignore | ||
| build.img.sh | ||
| docker-entrypoint.sh | ||
| Dockerfile | ||
| Dockerfile.dev | ||
| README.md | ||
| requirements.dev.txt | ||
| requirements.dev.yml | ||
| requirements.template.txt | ||
Ansible Collection Development Repository
OpenSVC supports Ansible for cluster deployment and configuration. This repository includes an Ansible collection with multiple roles and example playbooks, allowing users to easilly build OpenSVC clusters. It is also organised to develop and contribute to this project. Please refer to Getting Started section of this readme.
Ansible Collections
Please refer to Ansible Collections Documentation for any questions related to this new way of delivering Ansible contents (introduced by ansible version 2.9.0)
Getting Started
There are multiple ways of using the collection, they are described below
Prerequisites
This repository requires some products to be installed:
Collection usage
- ansible-core >=
2.16.0 - docker, to use the collection images
Ansible version compatibility
The collections require ansible-core >= 2.16. They have been tested with
ansible-core 2.16, 2.19, 2.20, 2.21 and 2.22 (beta), the docker images being
built for the Ansible releases on a maintained ansible-core (see build.img.sh).
They have been tested on Ubuntu 20.04, 22.04, 24.04, 26.04 and RHEL 7, 8, 9, 10 nodes. The managed nodes python version limits the ansible-core version:
| Nodes | Python | ansible-core |
|---|---|---|
| RHEL 7, RHEL 8 | 3.6 | <= 2.16 |
| Ubuntu 20.04 | 3.8 | <= 2.19 |
| RHEL 9, 10, Ubuntu 22.04+ | >= 3.9 | all |
Option 1 : Using Ansible Galaxy and ansible-galaxy to install the collection
$ ansible-galaxy collection install opensvc.cluster
Process install dependency map
Starting collection install process
Installing 'opensvc.cluster:0.0.1' to '~/.ansible/collections/ansible_collections/opensvc/cluster'
Option 2 : Installing the collection from the git repository
You can git clone this repository, and build yourself the collection, to finally install it
Git clone the repo
user@node:~/dev$ git clone https://forge.opensvc.com/opensvc/ansible-collection.git
Install the collection
user@node:~/dev$ cd ansible-collection
user@node:~/dev/ansible-collection$ ansible-galaxy collection build --force ansible_collections/opensvc/cluster
user@node:~/dev/ansible-collection$ ansible-galaxy collection install opensvc-cluster-<VERSION>.tar.gz
Some example playbooks are available in the examples folder. After updating the inventory file to reflect your environment, you can run a playbook with the command below:
$ cd examples
$ ansible-playbook -i inventory playbook.yml
Please refer to OpenSVC Galaxy Documentation for more detailed usages of the collection.
Option 3 : Testing/Contributing to the collection
Git clone the repo
user@node:~/dev$ git clone https://forge.opensvc.com/opensvc/ansible-collection.git
You can contribute to this collection by using the development environment:
- Implement changes, patches, to the collection structure
ansible-collection/ansible_collections/*. You don't have to commit your changes for testing purposes. - Build the docker image
-
install all prerequisites
-
embedds the current collection with your changes
build.img.shwrites therequirements.<version>.txtfile of each Ansible release it supports (generated files, not tracked by git) and prints the build commands. Run it, then thedocker buildcommand of the release you want, here taggedosvccol:test:user@node:~/dev$ cd ansible-collection user@node:~/dev/ansible-collection$ ./build.img.sh user@node:~/dev/ansible-collection$ docker build --network host --build-arg PYTHON_IMAGE=<python image> --build-arg REQUIREMENTS_FILE=requirements.<version>.txt -f Dockerfile -t osvccol:test .
-
Spawn a docker container using the new image, and start testing your changes using the bind mounted
examplesdirectoryuser@node:~/dev/ansible-collection$ docker run --rm -v $HOME/dev/ansible-collection/examples:/examples -it osvccol:test /bin/sh /examples # -
Update
inventoryandssh.private.keyfiles/examples # ls -l total 40 -rw-r--r-- 1 1000 1000 140 Mar 25 16:42 ansible.cfg -rw-r--r-- 1 1000 1000 226 Mar 25 16:08 inventory -rw-r--r-- 1 1000 1000 233 Mar 25 16:36 playbook-provision-cluster.yml -rw-r--r-- 1 1000 1000 151 Mar 23 11:17 playbook-unprovision-cluster.yml -rw-r--r-- 1 1000 1000 152 Mar 23 11:23 playbook-unprovision-services.yml -rwx------ 1 1000 1000 3243 Mar 23 09:23 ssh.private.keyNote: You must create the
ssh.private.keyfile with your personal private key, to make ssh connection work fine./examples # cat inventory [clusternodes] demo1.acme.com ansible_host="1.1.1.1" ansible_ssh_private_key_file="ssh.private.key" demo2.acme.com ansible_host="2.2.2.2" ansible_ssh_private_key_file="ssh.private.key" [webservers] web1.acme.com web2.acme.com [dbservers] db1.acme.com db2.acme.com -
Run a playbook to provision a cluster using members of the
clusternodesgroup/examples # ansible-playbook -i inventory playbook-provision-cluster.yml --limit clusternodes
If your changes are ok, and you want to share them with the community, send them as patches (git format-patch) to ansible@opensvc.com, with your questions and bug reports.
If you need to rework your changes, just follow those steps :
- Exit the docker container with
exitorCTRL+d - Fix your code
- Update the docker image, with the same
docker buildcommand as above - Spawn a new docker container
user@node:~/dev/ansible-collection$ docker run --rm -v $HOME/dev/ansible-collection/examples:/examples -it osvccol:test /bin/sh - Repeat your tests
/examples # ansible-playbook -i inventory playbook-provision-cluster.yml --limit clusternodes
Note
The Dockerfile ends with a call to an entrypoint docker-entrypoint.sh which by default run a syntax check and lint every playbook found in the examples directory.
user@node:~/dev/ansible-collection$ docker run --rm -v $PWD/examples:/examples -it osvccol:test
=> Start syntax checking & linting for playbook playbook-provision-cluster-with-relay-heartbeat.yml
playbook: playbook-provision-cluster-with-relay-heartbeat.yml
Examining playbook-provision-cluster-with-relay-heartbeat.yml of type playbook
=> End of syntax checking & linting for playbook playbook-provision-cluster-with-relay-heartbeat.yml
=> Start syntax checking & linting for playbook playbook-provision-cluster.yml
playbook: playbook-provision-cluster.yml
Examining playbook-provision-cluster.yml of type playbook
=> End of syntax checking & linting for playbook playbook-provision-cluster.yml
=> Start syntax checking & linting for playbook playbook-unprovision-cluster.yml
playbook: playbook-unprovision-cluster.yml
Examining playbook-unprovision-cluster.yml of type playbook
=> End of syntax checking & linting for playbook playbook-unprovision-cluster.yml
=> Start syntax checking & linting for playbook playbook-unprovision-services.yml
playbook: playbook-unprovision-services.yml
Examining playbook-unprovision-services.yml of type playbook
=> End of syntax checking & linting for playbook playbook-unprovision-services.yml