From 0701d0aafd8cc8511ab36c2dd660cc30da6d5cfb Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sat, 16 Nov 2019 09:02:27 +0700 Subject: [PATCH 1/3] Fix INSTALL to point to new package --- .../{{cookiecutter.scenario_name}}/INSTALL.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/molecule_hetznercloud/cookiecutter/scenario/driver/hetznercloud/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/INSTALL.rst b/molecule_hetznercloud/cookiecutter/scenario/driver/hetznercloud/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/INSTALL.rst index 2f29f31..b671bbf 100644 --- a/molecule_hetznercloud/cookiecutter/scenario/driver/hetznercloud/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/INSTALL.rst +++ b/molecule_hetznercloud/cookiecutter/scenario/driver/hetznercloud/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/INSTALL.rst @@ -13,4 +13,4 @@ Install .. code-block:: bash - $ pip install 'molecule[hetznercloud]' + $ pip install molecule-hetznercloud From 9ab4f23782d35c974cdb7aa5af458bfc13a3410e Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sat, 16 Nov 2019 09:02:54 +0700 Subject: [PATCH 2/3] Rename driver file to match API expectations --- .../{hetznercloud.py => driver.py} | 63 +------------------ .../test/unit/driver/test_hetznercloud.py | 5 +- 2 files changed, 5 insertions(+), 63 deletions(-) rename molecule_hetznercloud/{hetznercloud.py => driver.py} (68%) diff --git a/molecule_hetznercloud/hetznercloud.py b/molecule_hetznercloud/driver.py similarity index 68% rename from molecule_hetznercloud/hetznercloud.py rename to molecule_hetznercloud/driver.py index 730ae05..9f8d713 100644 --- a/molecule_hetznercloud/hetznercloud.py +++ b/molecule_hetznercloud/driver.py @@ -28,63 +28,6 @@ log = logger.get_logger(__name__) class HetznerCloud(Driver): - """ - The class responsible for managing `Hetzner Cloud`_ instances. - `Hetzner Cloud`_ is **not** the default driver used in Molecule. - - Molecule leverages Ansible's `hcloud_server module`_, by mapping variables - from ``molecule.yml`` into ``create.yml`` and ``destroy.yml``. - - .. important:: - - The ``hcloud_server`` module is only available in Ansible >= 2.8. - - .. _`hcloud_server module`: https://docs.ansible.com/ansible/devel/modules/hcloud_server_module.html#hcloud-server-module - - .. code-block:: yaml - - driver: - name: hetznercloud - platforms: - - name: instance - server_type: cx11 - image: debian-9 - - .. code-block:: bash - - $ pip install 'molecule[hetznercloud]' - - Change the options passed to the ssh client. - - .. code-block:: yaml - - driver: - name: hetznercloud - ssh_connection_options: - - '-o ControlPath=~/.ansible/cp/%r@%h-%p' - - .. important:: - - The Hetzner Cloud driver implementation uses the Parmiko transport - provided by Ansible to avoid issues of connection hanging and - indefinite polling as experienced with the default OpenSSh based - transport. - - .. important:: - - Molecule does not merge lists, when overriding the developer must - provide all options. - - Provide the files Molecule will preserve upon each subcommand execution. - - .. code-block:: yaml - - driver: - name: hetznercloud - safe_files: - - foo - """ # noqa - def __init__(self, config=None): super(HetznerCloud, self).__init__(config) self._name = "hetznercloud" @@ -137,8 +80,6 @@ class HetznerCloud(Driver): except StopIteration: return {} except IOError: - # Instance has yet to be provisioned , therefore the - # instance_config is not on disk. return {} def template_dir(self): @@ -165,8 +106,8 @@ class HetznerCloud(Driver): except ImportError: msg = ( "Missing Hetzner Cloud driver dependency. Please " - "install via 'molecule[hetznercloud]' or refer to " - "your INSTALL.rst driver documentation file" + "install the 'molecule-hetznercloud' package or " + "refer to your INSTALL.rst driver documentation file" ) sysexit_with_message(msg) diff --git a/molecule_hetznercloud/test/unit/driver/test_hetznercloud.py b/molecule_hetznercloud/test/unit/driver/test_hetznercloud.py index 310a971..e321a38 100644 --- a/molecule_hetznercloud/test/unit/driver/test_hetznercloud.py +++ b/molecule_hetznercloud/test/unit/driver/test_hetznercloud.py @@ -21,13 +21,14 @@ import os import pytest + from molecule import config -from molecule_hetznercloud import hetznercloud +from molecule_hetznercloud import driver @pytest.fixture def hetznercloud_instance(patched_config_validate, config_instance): - return hetznercloud.HetznerCloud(config_instance) + return driver.HetznerCloud(config_instance) def test_hetznercloud_config_gives_config_object(hetznercloud_instance): From 86b3a8f9e7c194299439e621eb104e710cc84f9b Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sat, 16 Nov 2019 09:14:01 +0700 Subject: [PATCH 3/3] Remove wrong driver and boiierplate --- .../test/functional/test_command.py | 15 ++------------- ...ecule_docker.yml => molecule_hetznercloud.yml} | 2 +- molecule_hetznercloud/test/unit/conftest.py | 13 ++++++------- .../test/unit/cookiecutter/test_molecule.py | 2 +- .../test/unit/model/v2/conftest.py | 2 +- 5 files changed, 11 insertions(+), 23 deletions(-) rename molecule_hetznercloud/test/resources/{molecule_docker.yml => molecule_hetznercloud.yml} (93%) diff --git a/molecule_hetznercloud/test/functional/test_command.py b/molecule_hetznercloud/test/functional/test_command.py index 95213e2..68624a0 100644 --- a/molecule_hetznercloud/test/functional/test_command.py +++ b/molecule_hetznercloud/test/functional/test_command.py @@ -21,6 +21,7 @@ import os import pytest + import sh from molecule.scenario import ephemeral_directory @@ -168,19 +169,7 @@ def test_command_idempotence(scenario_to_test, with_scenario, scenario_name): pytest.helpers.idempotence(scenario_name) -@pytest.mark.parametrize( - "driver_name", - [ - ("digitalocean"), - ("docker"), - ("ec2"), - ("gce"), - ("linode"), - ("openstack"), - ("vagrant"), - ], - indirect=["driver_name"], -) +@pytest.mark.parametrize("driver_name", [("hetznercloud")], indirect=["driver_name"]) def test_command_init_role(temp_dir, driver_name, skip_test): pytest.helpers.init_role(temp_dir, driver_name) diff --git a/molecule_hetznercloud/test/resources/molecule_docker.yml b/molecule_hetznercloud/test/resources/molecule_hetznercloud.yml similarity index 93% rename from molecule_hetznercloud/test/resources/molecule_docker.yml rename to molecule_hetznercloud/test/resources/molecule_hetznercloud.yml index 1976cfc..5cf254f 100644 --- a/molecule_hetznercloud/test/resources/molecule_docker.yml +++ b/molecule_hetznercloud/test/resources/molecule_hetznercloud.yml @@ -2,7 +2,7 @@ dependency: name: galaxy driver: - name: docker + name: hetznercloud lint: name: yamllint platforms: diff --git a/molecule_hetznercloud/test/unit/conftest.py b/molecule_hetznercloud/test/unit/conftest.py index 17f7d2c..a395b3c 100644 --- a/molecule_hetznercloud/test/unit/conftest.py +++ b/molecule_hetznercloud/test/unit/conftest.py @@ -18,22 +18,21 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -from uuid import uuid4 import copy import functools import os import shutil +from uuid import uuid4 + +import pytest + +from molecule import config, util try: from pathlib import Path except ImportError: from pathlib2 import Path -import pytest - -from molecule import util -from molecule import config - @pytest.helpers.register def write_molecule_file(filename, data): @@ -55,7 +54,7 @@ def _molecule_dependency_galaxy_section_data(): @pytest.fixture def _molecule_driver_section_data(): - return {"driver": {"name": "docker", "options": {"managed": True}}} + return {"driver": {"name": "hetznercloud", "options": {"managed": True}}} @pytest.fixture diff --git a/molecule_hetznercloud/test/unit/cookiecutter/test_molecule.py b/molecule_hetznercloud/test/unit/cookiecutter/test_molecule.py index 1169269..6c60e44 100644 --- a/molecule_hetznercloud/test/unit/cookiecutter/test_molecule.py +++ b/molecule_hetznercloud/test/unit/cookiecutter/test_molecule.py @@ -46,7 +46,7 @@ def _instance(_base_class): def _command_args(): return { "dependency_name": "galaxy", - "driver_name": "docker", + "driver_name": "hetznercloud", "lint_name": "yamllint", "provisioner_name": "ansible", "scenario_name": "default", diff --git a/molecule_hetznercloud/test/unit/model/v2/conftest.py b/molecule_hetznercloud/test/unit/model/v2/conftest.py index fe09bff..55cbdf7 100644 --- a/molecule_hetznercloud/test/unit/model/v2/conftest.py +++ b/molecule_hetznercloud/test/unit/model/v2/conftest.py @@ -33,7 +33,7 @@ def _molecule_file(): os.path.pardir, os.path.pardir, "resources", - "molecule_docker.yml", + "molecule_hetznercloud.yml", )