From 2a30664799fa857de341a1371d1ff9ca7a63e03c Mon Sep 17 00:00:00 2001 From: ZachiNachshon Date: Fri, 11 Aug 2023 17:42:34 +0300 Subject: [PATCH] fix(remote-os-configure): Align command with recent Ansible playbooks dry_run support (reboot excluded at the playbook YAML) --- provisioner_examples_plugin/poetry.lock | 29 ++++++- .../ansible/hello_world_runner.py | 6 +- provisioner_examples_plugin/pyproject.toml | 2 +- provisioner_installers_plugin/poetry.lock | 29 ++++++- provisioner_installers_plugin/pyproject.toml | 2 +- provisioner_single_board_plugin/poetry.lock | 79 ++++++------------- .../common/remote/remote_network_configure.py | 9 +-- .../common/remote/remote_os_configure.py | 13 +-- .../pyproject.toml | 2 +- 9 files changed, 96 insertions(+), 75 deletions(-) diff --git a/provisioner_examples_plugin/poetry.lock b/provisioner_examples_plugin/poetry.lock index d1c0820..9981025 100644 --- a/provisioner_examples_plugin/poetry.lock +++ b/provisioner_examples_plugin/poetry.lock @@ -793,6 +793,33 @@ files = [ dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] +[[package]] +name = "provisioner" +version = "0.1.0" +description = "Provision Everything Anywhere" +category = "dev" +optional = false +python-versions = "^3.10" +files = [] +develop = true + +[package.dependencies] +ansible = "^7.3.0" +ansible-runner = "^2.3.2" +inquirer = "^2.10.0" +loguru = "^0.6.0" +python-hosts = "^1.0.3" +python-libnmap = "^0.7.3" +python3-nmap = "^1.5.4" +PyYAML = "^6.0" +requests = "^2.28.1" +rich = "^12.5.1" +typer = "^0.6.1" + +[package.source] +type = "directory" +url = "../../provisioner/provisioner" + [[package]] name = "provisioner-features-lib" version = "0.1.0" @@ -1354,4 +1381,4 @@ dev = ["black (>=19.3b0)", "pytest (>=4.6.2)"] [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "e38d7dad2e3692b93fb4b8c216285cf3098d652cb2edb38838a488f947e6afb5" +content-hash = "8c293a4a783978bd898bbf62b3cf0fb40e9ab5297f729f87053f20ad94b65628" diff --git a/provisioner_examples_plugin/provisioner_examples_plugin/ansible/hello_world_runner.py b/provisioner_examples_plugin/provisioner_examples_plugin/ansible/hello_world_runner.py index e041c1f..d293097 100644 --- a/provisioner_examples_plugin/provisioner_examples_plugin/ansible/hello_world_runner.py +++ b/provisioner_examples_plugin/provisioner_examples_plugin/ansible/hello_world_runner.py @@ -97,11 +97,9 @@ def _print_pre_run_instructions(self, printer: Printer, prompter: Prompter): def _prerequisites(self, ctx: Context, checks: Checks) -> None: if ctx.os_arch.is_linux(): - checks.check_tool_fn("docker") - + return elif ctx.os_arch.is_darwin(): - checks.check_tool_fn("docker") - + return elif ctx.os_arch.is_windows(): raise NotImplementedError("Windows is not supported") else: diff --git a/provisioner_examples_plugin/pyproject.toml b/provisioner_examples_plugin/pyproject.toml index d847aeb..50592e8 100644 --- a/provisioner_examples_plugin/pyproject.toml +++ b/provisioner_examples_plugin/pyproject.toml @@ -79,7 +79,7 @@ diagrams = "^0.22.0" ruff = "^0.0.265" # For debugging purposes when running "poetry run provisioner" from within the plugins folder -# provisioner = { path = "../../provisioner/provisioner", develop = true } +provisioner = { path = "../../provisioner/provisioner", develop = true } [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/provisioner_installers_plugin/poetry.lock b/provisioner_installers_plugin/poetry.lock index d1c0820..9981025 100644 --- a/provisioner_installers_plugin/poetry.lock +++ b/provisioner_installers_plugin/poetry.lock @@ -793,6 +793,33 @@ files = [ dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] +[[package]] +name = "provisioner" +version = "0.1.0" +description = "Provision Everything Anywhere" +category = "dev" +optional = false +python-versions = "^3.10" +files = [] +develop = true + +[package.dependencies] +ansible = "^7.3.0" +ansible-runner = "^2.3.2" +inquirer = "^2.10.0" +loguru = "^0.6.0" +python-hosts = "^1.0.3" +python-libnmap = "^0.7.3" +python3-nmap = "^1.5.4" +PyYAML = "^6.0" +requests = "^2.28.1" +rich = "^12.5.1" +typer = "^0.6.1" + +[package.source] +type = "directory" +url = "../../provisioner/provisioner" + [[package]] name = "provisioner-features-lib" version = "0.1.0" @@ -1354,4 +1381,4 @@ dev = ["black (>=19.3b0)", "pytest (>=4.6.2)"] [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "e38d7dad2e3692b93fb4b8c216285cf3098d652cb2edb38838a488f947e6afb5" +content-hash = "8c293a4a783978bd898bbf62b3cf0fb40e9ab5297f729f87053f20ad94b65628" diff --git a/provisioner_installers_plugin/pyproject.toml b/provisioner_installers_plugin/pyproject.toml index 014fd2d..921fcb3 100644 --- a/provisioner_installers_plugin/pyproject.toml +++ b/provisioner_installers_plugin/pyproject.toml @@ -76,7 +76,7 @@ diagrams = "^0.22.0" ruff = "^0.0.265" # For debugging purposes when running "poetry run provisioner" from within the plugins folder -# provisioner = { path = "../../provisioner/provisioner", develop = true } +provisioner = { path = "../../provisioner/provisioner", develop = true } [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/provisioner_single_board_plugin/poetry.lock b/provisioner_single_board_plugin/poetry.lock index d1c0820..924dc45 100644 --- a/provisioner_single_board_plugin/poetry.lock +++ b/provisioner_single_board_plugin/poetry.lock @@ -4,7 +4,7 @@ name = "ansible" version = "7.7.0" description = "Radically simple IT automation" -category = "main" +category = "dev" optional = false python-versions = ">=3.9" files = [ @@ -19,7 +19,7 @@ ansible-core = ">=2.14.7,<2.15.0" name = "ansible-core" version = "2.14.8" description = "Radically simple IT automation" -category = "main" +category = "dev" optional = false python-versions = ">=3.9" files = [ @@ -38,7 +38,7 @@ resolvelib = ">=0.5.3,<0.9.0" name = "ansible-runner" version = "2.3.3" description = "\"Consistent Ansible Python API and CLI with container and process isolation runtime capabilities\"" -category = "main" +category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -133,7 +133,7 @@ files = [ name = "cffi" version = "1.15.1" description = "Foreign Function Interface for Python calling C code." -category = "main" +category = "dev" optional = false python-versions = "*" files = [ @@ -400,7 +400,7 @@ toml = ["tomli"] name = "cryptography" version = "41.0.3" description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." -category = "main" +category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -462,7 +462,7 @@ jinja2 = ">=2.10,<4.0" name = "docutils" version = "0.20.1" description = "Docutils -- Python Documentation Utilities" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -547,7 +547,7 @@ readchar = ">=3.0.6" name = "jinja2" version = "3.1.2" description = "A very fast and expressive template engine." -category = "main" +category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -580,7 +580,7 @@ ansicon = {version = "*", markers = "platform_system == \"Windows\""} name = "lockfile" version = "0.12.2" description = "Platform-independent file locking module" -category = "main" +category = "dev" optional = false python-versions = "*" files = [ @@ -611,7 +611,7 @@ dev = ["Sphinx (>=4.1.1)", "black (>=19.10b0)", "colorama (>=0.3.4)", "docutils name = "markupsafe" version = "2.1.3" description = "Safely add untrusted strings to HTML/XML markup." -category = "main" +category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -726,7 +726,7 @@ files = [ name = "packaging" version = "23.1" description = "Core utilities for Python packages" -category = "main" +category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -750,7 +750,7 @@ files = [ name = "pexpect" version = "4.8.0" description = "Pexpect allows easy control of interactive console applications." -category = "main" +category = "dev" optional = false python-versions = "*" files = [ @@ -794,16 +794,18 @@ dev = ["pre-commit", "tox"] testing = ["pytest", "pytest-benchmark"] [[package]] -name = "provisioner-features-lib" +name = "provisioner" version = "0.1.0" -description = "Python Features Library" -category = "main" +description = "Provision Everything Anywhere" +category = "dev" optional = false python-versions = "^3.10" files = [] -develop = false +develop = true [package.dependencies] +ansible = "^7.3.0" +ansible-runner = "^2.3.2" inquirer = "^2.10.0" loguru = "^0.6.0" python-hosts = "^1.0.3" @@ -815,16 +817,14 @@ rich = "^12.5.1" typer = "^0.6.1" [package.source] -type = "git" -url = "git@github.com:ZachiNachshon/provisioner.git" -reference = "b42c27c" -resolved_reference = "b42c27c26e424fac0d673f0ac43911d1c26476a2" -subdirectory = "provisioner_features_lib" +type = "directory" +url = "../../provisioner/provisioner" + [[package]] name = "ptyprocess" version = "0.7.0" description = "Run a subprocess in a pseudo terminal" -category = "main" +category = "dev" optional = false python-versions = "*" files = [ @@ -836,7 +836,7 @@ files = [ name = "pycparser" version = "2.21" description = "C parser in Python" -category = "main" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" files = [ @@ -882,40 +882,11 @@ tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} [package.extras] testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] -[[package]] -name = "python-core-lib" -version = "0.1.0" -description = "Core Python Utilities Library" -category = "main" -optional = false -python-versions = "^3.10" -files = [] -develop = false - -[package.dependencies] -ansible = "^7.3.0" -ansible-runner = "^2.3.2" -inquirer = "^2.10.0" -loguru = "^0.6.0" -python-hosts = "^1.0.3" -python-libnmap = "^0.7.3" -python3-nmap = "^1.5.4" -PyYAML = "^6.0" -requests = "^2.28.1" -rich = "^12.5.1" -typer = "^0.6.1" - -[package.source] -type = "git" -url = "git@github.com:ZachiNachshon/provisioner.git" -reference = "b42c27c" -resolved_reference = "b42c27c26e424fac0d673f0ac43911d1c26476a2" -subdirectory = "python_core_lib" [[package]] name = "python-daemon" version = "3.0.1" description = "Library to implement a well-behaved Unix daemon process." -category = "main" +category = "dev" optional = false python-versions = ">=3" files = [ @@ -1077,7 +1048,7 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] name = "resolvelib" version = "0.8.1" description = "Resolve abstract dependencies into concrete ones" -category = "main" +category = "dev" optional = false python-versions = "*" files = [ @@ -1354,4 +1325,4 @@ dev = ["black (>=19.3b0)", "pytest (>=4.6.2)"] [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "e38d7dad2e3692b93fb4b8c216285cf3098d652cb2edb38838a488f947e6afb5" +content-hash = "2c20cf1e51fa3f22a12a8c0d4ee9c0a7f0aa95623fe4e3c71ce98e9d0a392844" diff --git a/provisioner_single_board_plugin/provisioner_single_board_plugin/common/remote/remote_network_configure.py b/provisioner_single_board_plugin/provisioner_single_board_plugin/common/remote/remote_network_configure.py index bc7a389..6245eab 100644 --- a/provisioner_single_board_plugin/provisioner_single_board_plugin/common/remote/remote_network_configure.py +++ b/provisioner_single_board_plugin/provisioner_single_board_plugin/common/remote/remote_network_configure.py @@ -154,8 +154,7 @@ def _run_ansible_network_configure_playbook_with_progress_bar( ansible_tags=[ "configure_rpi_network", "define_static_ip", - "reboot" if not args.remote_opts.get_remote_context().is_dry_run() else "", - ], + ] + (["reboot"] if not args.remote_opts.get_remote_context().is_dry_run() else []), ), desc_run="Running Ansible playbook (Configure Network)", desc_end="Ansible playbook finished (Configure Network).", @@ -230,11 +229,9 @@ def _bundle_network_information_from_tuple( def _prerequisites(self, ctx: Context, checks: Checks) -> None: if ctx.os_arch.is_linux(): - checks.check_tool_fn("docker") - + return elif ctx.os_arch.is_darwin(): - checks.check_tool_fn("docker") - + return elif ctx.os_arch.is_windows(): raise NotImplementedError("Windows is not supported") else: diff --git a/provisioner_single_board_plugin/provisioner_single_board_plugin/common/remote/remote_os_configure.py b/provisioner_single_board_plugin/provisioner_single_board_plugin/common/remote/remote_os_configure.py index 2d431d3..e465910 100644 --- a/provisioner_single_board_plugin/provisioner_single_board_plugin/common/remote/remote_os_configure.py +++ b/provisioner_single_board_plugin/provisioner_single_board_plugin/common/remote/remote_os_configure.py @@ -81,8 +81,11 @@ def _run_ansible_configure_os_playbook_with_progress_bar( ansible_vars=[f"host_name={ansible_host.host}"], ansible_tags=[ "configure_remote_node", - "reboot" if not args.remote_opts.get_remote_context().is_dry_run() else "", - ], + "reboot" + ] + # ansible_tags=[ + # "configure_remote_node", + # ] + (["reboot"] if not args.remote_opts.get_remote_context().is_dry_run() else []), ), desc_run="Running Ansible playbook (Configure OS)", desc_end="Ansible playbook finished (Configure OS).", @@ -118,11 +121,9 @@ def _print_post_run_instructions( def _prerequisites(self, ctx: Context, checks: Checks) -> None: if ctx.os_arch.is_linux(): - checks.check_tool_fn("docker") - + return elif ctx.os_arch.is_darwin(): - checks.check_tool_fn("docker") - + return elif ctx.os_arch.is_windows(): raise NotImplementedError("Windows is not supported") else: diff --git a/provisioner_single_board_plugin/pyproject.toml b/provisioner_single_board_plugin/pyproject.toml index 2e2859c..a8b7bf4 100644 --- a/provisioner_single_board_plugin/pyproject.toml +++ b/provisioner_single_board_plugin/pyproject.toml @@ -77,7 +77,7 @@ diagrams = "^0.22.0" ruff = "^0.0.265" # For debugging purposes when running "poetry run provisioner" from within the plugins folder -# provisioner = { path = "../../provisioner/provisioner", develop = true } +provisioner = { path = "../../provisioner/provisioner", develop = true } [build-system] requires = ["poetry-core>=1.0.0"]