diff --git a/poetry.lock b/poetry.lock index 8bb145b..318f704 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3,7 +3,7 @@ name = "ansible-core" version = "2.11.10" description = "Radically simple IT automation" category = "main" -optional = false +optional = true python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*" [package.dependencies] @@ -100,7 +100,6 @@ python-versions = ">=3.6.2" [package.dependencies] click = ">=7.1.2" -dataclasses = {version = ">=0.6", markers = "python_version < \"3.7\""} mypy-extensions = ">=0.4.3" pathspec = ">=0.9.0,<1" platformdirs = ">=2" @@ -287,14 +286,6 @@ sdist = ["setuptools_rust (>=0.11.4)"] ssh = ["bcrypt (>=3.1.5)"] test = ["pytest (>=6.2.0)", "pytest-cov", "pytest-subtests", "pytest-xdist", "pretend", "iso8601", "pytz", "hypothesis (>=1.11.4,!=3.79.2)"] -[[package]] -name = "dataclasses" -version = "0.8" -description = "A backport of the dataclasses module for Python 3.6" -category = "dev" -optional = false -python-versions = ">=3.6, <3.7" - [[package]] name = "decorator" version = "5.1.1" @@ -515,7 +506,7 @@ name = "jinja2" version = "3.0.3" description = "A very fast and expressive template engine." category = "main" -optional = false +optional = true python-versions = ">=3.6" [package.dependencies] @@ -582,7 +573,7 @@ name = "markupsafe" version = "2.0.1" description = "Safely add untrusted strings to HTML/XML markup." category = "main" -optional = false +optional = true python-versions = ">=3.6" [[package]] @@ -1050,7 +1041,7 @@ name = "resolvelib" version = "0.5.5" description = "Resolve abstract dependencies into concrete ones" category = "main" -optional = false +optional = true python-versions = "*" [package.extras] @@ -1311,10 +1302,13 @@ python-versions = ">=3.6" docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"] testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy"] +[extras] +ansible = ["ansible-core"] + [metadata] lock-version = "1.1" python-versions = "^3.6.1" -content-hash = "26a32824ee45942149c4ed1ec478f8a7fc20dff8d810cfbfeeeb483f140b79b4" +content-hash = "bc881be2658a33012a14c8a965709cd8ddbd2a794c5c96c8d037e85db2faccc1" [metadata.files] ansible-core = [ @@ -1523,10 +1517,6 @@ cryptography = [ {file = "cryptography-36.0.2-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:e167b6b710c7f7bc54e67ef593f8731e1f45aa35f8a8a7b72d6e42ec76afd4b3"}, {file = "cryptography-36.0.2.tar.gz", hash = "sha256:70f8f4f7bb2ac9f340655cbac89d68c527af5bb4387522a8413e841e3e6628c9"}, ] -dataclasses = [ - {file = "dataclasses-0.8-py3-none-any.whl", hash = "sha256:0201d89fa866f68c8ebd9d08ee6ff50c0b255f8ec63a71c16fda7af82bb887bf"}, - {file = "dataclasses-0.8.tar.gz", hash = "sha256:8479067f342acf957dc82ec415d355ab5edb7e7646b90dc6e2fd1d96ad084c97"}, -] decorator = [ {file = "decorator-5.1.1-py3-none-any.whl", hash = "sha256:b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186"}, {file = "decorator-5.1.1.tar.gz", hash = "sha256:637996211036b6385ef91435e4fae22989472f9d571faba8927ba8253acbc330"}, diff --git a/pyproject.toml b/pyproject.toml index 2d09c0b..14dc2f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,10 +33,13 @@ classifiers = [ [tool.poetry.scripts] vault2vault = "vault2vault:main" +[tool.poetry.extras] +ansible = ["ansible-core"] + [tool.poetry.dependencies] python = "^3.6.1" "ruamel.yaml" = "^0.17.16" -ansible-core = "^2.11.5" +ansible-core = {version = "^2.11.5", optional = true} [tool.poetry.dev-dependencies] bandit = "^1.6.2" diff --git a/tox.ini b/tox.ini index 669c64c..2a7a6cc 100644 --- a/tox.ini +++ b/tox.ini @@ -7,6 +7,8 @@ skip_missing_interpreters = true description = Run the tests require_locked_deps = true require_poetry = true +extras = + ansible locked_deps = pytest pytest-cov diff --git a/vault2vault.py b/vault2vault.py index 5b528c4..7d914ff 100644 --- a/vault2vault.py +++ b/vault2vault.py @@ -12,10 +12,17 @@ from typing import List from typing import Tuple from typing import Union -import ansible.constants -import ansible.parsing.vault import ruamel.yaml +try: + import ansible.constants + import ansible.parsing.vault +except ImportError: + print( + "FATAL: No supported version of Ansible could be imported under the current python interpreter" + ) + sys.exit(1) + __title__ = "vault2vault" __summary__ = "Recursively rekey ansible-vault encrypted files and in-line variables"