Skip to content

Commit

Permalink
F #109 #72: Replace poetry with hatch/uv
Browse files Browse the repository at this point in the history
  • Loading branch information
sk4zuzu committed Jan 29, 2025
1 parent 7f0e441 commit 43273f3
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 30 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ __pycache__/
!/inventory/federation-slave2.yml
!/inventory/evpn-ha.yml
/.env.yml
/poetry.lock
.vscode
45 changes: 35 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
SHELL := $(shell which bash)
SELF := $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST)))))

POETRY_BIN ?= $(shell command -v poetry)
POETRY_RUN := $(if $(POETRY_BIN),$(POETRY_BIN) run,)
HATCH_BIN ?= $(shell command -v hatch)

ifneq ($(strip $(HATCH_BIN)),)
ENV_RUN = $(HATCH_BIN) env run -e $(1) --
ENV_DEFAULT := $(shell $(HATCH_BIN) env find default)
ENV_CEPH := $(shell $(HATCH_BIN) env find ceph)
endif

I ?= $(SELF)/inventory/example.yml
INVENTORY ?= $(I)
Expand Down Expand Up @@ -30,18 +35,38 @@ all: main
infra pre ceph site main: _TAGS := $(if $(TAGS),-t $(TAGS),)
infra pre ceph site main: _SKIP_TAGS := $(if $(SKIP_TAGS),--skip-tags $(SKIP_TAGS),)
infra pre ceph site main: _VERBOSE := $(if $(VERBOSE),-$(VERBOSE),)
infra pre ceph site main:
cd $(SELF)/ && $(POETRY_RUN) ansible-playbook $(_VERBOSE) -i $(INVENTORY) $(_TAGS) $(_SKIP_TAGS) opennebula.deploy.$@

.PHONY: requirements requirements-poetry requirements-python requirements-galaxy
ifdef ENV_DEFAULT
$(ENV_DEFAULT):
$(HATCH_BIN) env create default
endif

infra pre site main: $(ENV_DEFAULT)
cd $(SELF)/ && \
$(call ENV_RUN,default) ansible-playbook $(_VERBOSE) -i $(INVENTORY) $(_TAGS) $(_SKIP_TAGS) opennebula.deploy.$@

ifdef ENV_CEPH
$(ENV_CEPH):
$(HATCH_BIN) env create ceph
endif

requirements: requirements-$(if $(POETRY_RUN),poetry,python) requirements-galaxy
ceph: $(ENV_CEPH)
cd $(SELF)/ && \
$(call ENV_RUN,ceph) ansible-playbook $(_VERBOSE) -i $(INVENTORY) $(_TAGS) $(_SKIP_TAGS) opennebula.deploy.$@

requirements-poetry: $(SELF)/pyproject.toml
poetry update --directory $(dir $<)
.PHONY: requirements requirements-hatch requirements-python requirements-galaxy clean-requirements

requirements: requirements-$(if $(ENV_RUN),hatch,python) requirements-galaxy

requirements-hatch: $(SELF)/pyproject.toml $(ENV_DEFAULT)

requirements-python: $(SELF)/requirements.txt
pip3 install --requirement $<

requirements-galaxy: $(SELF)/requirements.yml
$(POETRY_RUN) ansible-galaxy collection install --requirements-file $<
requirements-galaxy: $(SELF)/requirements.yml $(ENV_DEFAULT)
$(call ENV_RUN,default) ansible-galaxy collection install --requirements-file $<

clean-requirements:
find $(SELF)/ansible_collections/ -mindepth 1 -maxdepth 1 -type d ! -name opennebula -exec rm -rf {} +
$(if $(ENV_DEFAULT),$(HATCH_BIN) env remove default,)
$(if $(ENV_CEPH),$(HATCH_BIN) env remove ceph,)
13 changes: 7 additions & 6 deletions galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ version: 0.0.0

readme: README.md

authors:
- OpenNebula <contact@opennebula.io>
authors: ["OpenNebula <contact@opennebula.io>"]
description: HA DEPLOYMENT FOR OPENNEBULA (ANSIBLE)

license: []
Expand All @@ -18,13 +17,15 @@ dependencies:
"ansible.posix": "*"
"ansible.utils": "*"
"community.crypto": "*"
"community.general": "*"
"community.libvirt": "*"

repository: https://github.com/OpenNebula/one-deploy
documentation: https://github.com/OpenNebula/one-deploy/wiki
issues: https://github.com/OpenNebula/one-deploy/issues

build_ignore:
- .gitignore
- .env.yml
- inventory
- ansible_collections
- .gitignore
- .env.yml
- inventory
- ansible_collections
34 changes: 22 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
[tool.poetry]
[project]
name = "one-deploy"
version = "0.0.0"
description = ""
description = "OpenNebula Ansible Playbooks"
authors = ["OpenNebula <contact@opennebula.io>"]

license = "Apache-2.0"
readme = "README.md"
requires-python = ">=3.9"

[tool.poetry.dependencies]
ansible-core = "<2.16"
molecule = "*"
netaddr = "*"
pyone = "*"
python = "^3.9"
[tool.hatch.envs.default]
skip-install = true
installer = "uv"
dependencies = [
"ansible-core",
"molecule",
"netaddr",
"pyone",
]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.hatch.envs.ceph]
skip-install = true
installer = "uv"
dependencies = [
"ansible-core<2.16",
"molecule",
"netaddr",
"pyone",
"setuptools",
]
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
netaddr
molecule
netaddr
pyone>=6.8.0
setuptools

0 comments on commit 43273f3

Please # to comment.