From 6938066531f1eef629012b7f1717ba098b96f30a Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Sun, 27 Oct 2019 09:56:08 +0000 Subject: [PATCH] Moved openstack driver to molecule-openstack (#2413) The driver has its own repository now: https://github.com/pycontribs/molecule-openstack Fixes: #2316 Signed-off-by: Sorin Sbarnea --- Dockerfile | 4 +- docs/ci.rst | 3 - docs/conf.py | 4 +- docs/configuration.rst | 5 - .../molecule.yml | 4 - .../driver/openstack/cookiecutter.json | 5 - .../INSTALL.rst | 22 -- .../{{cookiecutter.scenario_name}}/create.yml | 132 ---------- .../destroy.yml | 38 --- .../playbook.yml | 7 - .../prepare.yml | 11 - molecule/driver/openstack.py | 142 ----------- molecule/test/functional/conftest.py | 16 -- molecule/test/functional/test_command.py | 49 +--- .../resources/playbooks/delegated/create.yml | 1 - .../playbooks/delegated/create/openstack.yml | 53 ----- .../resources/playbooks/delegated/destroy.yml | 1 - .../playbooks/delegated/destroy/openstack.yml | 14 -- .../inventory/group_vars/all/all.yml | 10 - .../resources/playbooks/openstack/create.yml | 130 ---------- .../resources/playbooks/openstack/destroy.yml | 36 --- .../openstack/molecule/default/molecule.yml | 29 --- .../openstack/molecule/default/playbook.yml | 7 - .../openstack/molecule/default/prepare.yml | 9 - .../molecule/default/tests/test_default.py | 29 --- .../molecule/multi-node/molecule.yml | 36 --- .../molecule/multi-node/playbook.yml | 28 --- .../openstack/molecule/multi-node/prepare.yml | 9 - .../molecule/multi-node/tests/__init__.py | 0 .../molecule/multi-node/tests/test_default.py | 31 --- .../test/unit/cookiecutter/test_molecule.py | 2 +- molecule/test/unit/driver/test_openstack.py | 225 ------------------ .../test/unit/model/v2/test_driver_section.py | 6 - molecule/test/unit/test_config.py | 5 - setup.cfg | 5 - tox.ini | 1 - 36 files changed, 6 insertions(+), 1103 deletions(-) delete mode 100644 molecule/cookiecutter/scenario/driver/openstack/cookiecutter.json delete mode 100644 molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/INSTALL.rst delete mode 100644 molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml delete mode 100644 molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml delete mode 100644 molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/playbook.yml delete mode 100644 molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/prepare.yml delete mode 100644 molecule/driver/openstack.py delete mode 100644 molecule/test/resources/playbooks/delegated/create/openstack.yml delete mode 100644 molecule/test/resources/playbooks/delegated/destroy/openstack.yml delete mode 100644 molecule/test/resources/playbooks/openstack/create.yml delete mode 100644 molecule/test/resources/playbooks/openstack/destroy.yml delete mode 100644 molecule/test/scenarios/driver/openstack/molecule/default/molecule.yml delete mode 100644 molecule/test/scenarios/driver/openstack/molecule/default/playbook.yml delete mode 100644 molecule/test/scenarios/driver/openstack/molecule/default/prepare.yml delete mode 100644 molecule/test/scenarios/driver/openstack/molecule/default/tests/test_default.py delete mode 100644 molecule/test/scenarios/driver/openstack/molecule/multi-node/molecule.yml delete mode 100644 molecule/test/scenarios/driver/openstack/molecule/multi-node/playbook.yml delete mode 100644 molecule/test/scenarios/driver/openstack/molecule/multi-node/prepare.yml delete mode 100644 molecule/test/scenarios/driver/openstack/molecule/multi-node/tests/__init__.py delete mode 100644 molecule/test/scenarios/driver/openstack/molecule/multi-node/tests/test_default.py delete mode 100644 molecule/test/unit/driver/test_openstack.py diff --git a/Dockerfile b/Dockerfile index 77fd7083de..a4ed358dd8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,7 +51,7 @@ ENV PACKAGES="\ " RUN apk add --update --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ ${PACKAGES} -ENV MOLECULE_EXTRAS="azure,docker,docs,openstack,vagrant,windows" +ENV MOLECULE_EXTRAS="azure,docker,docs,vagrant,windows" # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=917006 RUN pip3 install -U wheel @@ -132,7 +132,7 @@ ENV GEM_PACKAGES="\ etc \ " -ENV MOLECULE_EXTRAS="azure,docker,docs,lxc,openstack,vagrant,windows" +ENV MOLECULE_EXTRAS="azure,docker,docs,lxc,vagrant,windows" RUN \ apk add --update --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ ${BUILD_DEPS} ${PACKAGES} \ diff --git a/docs/ci.rst b/docs/ci.rst index ec5aa172a3..ccd2066b88 100644 --- a/docs/ci.rst +++ b/docs/ci.rst @@ -286,9 +286,6 @@ we export a ``TOX_ENVNAME`` environment variable, it's the name of our tox env. TOX_ENVNAME={envname} MOLECULE_EPHEMERAL_DIRECTORY=/tmp/{envname} -If you are utilizing the Openstack driver you will have to make sure that your -``envname`` variable does not contain any invalid characters, particularly -``-``. You also must include the ``TOX_ENVNAME`` variable in name of each platform in ``molecule.yml`` configuration file. This way, ther names won't create any diff --git a/docs/conf.py b/docs/conf.py index b70906526c..04051efc12 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -151,9 +151,7 @@ # further. For a list of options available for each theme, see the # documentation. # html_theme_options = {} -html_theme_options = { - 'analytics_id': 'UA-128382387-1', -} +html_theme_options = {'analytics_id': 'UA-128382387-1'} # Add any paths that contain custom themes here, relative to this directory. # html_theme_path = [] diff --git a/docs/configuration.rst b/docs/configuration.rst index aa4004e48d..0ac836cc14 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -75,11 +75,6 @@ Docker .. autoclass:: molecule.driver.docker.Docker() :undoc-members: -Openstack -^^^^^^^^^ - -.. autoclass:: molecule.driver.openstack.Openstack() - :undoc-members: Podman ^^^^^^ diff --git a/molecule/cookiecutter/molecule/{{cookiecutter.role_name}}/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/molecule.yml b/molecule/cookiecutter/molecule/{{cookiecutter.role_name}}/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/molecule.yml index 387a05adff..c0804e2b8c 100644 --- a/molecule/cookiecutter/molecule/{{cookiecutter.role_name}}/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/molecule.yml +++ b/molecule/cookiecutter/molecule/{{cookiecutter.role_name}}/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/molecule.yml @@ -13,10 +13,6 @@ platforms: {%- if cookiecutter.driver_name == 'docker' %} - name: instance image: docker.io/centos:7 -{%- elif cookiecutter.driver_name == 'openstack' %} - - name: instance - image: Ubuntu-16.04 - flavor: NO-Nano {%- elif cookiecutter.driver_name == 'podman' %} - name: instance image: docker.io/centos:7 diff --git a/molecule/cookiecutter/scenario/driver/openstack/cookiecutter.json b/molecule/cookiecutter/scenario/driver/openstack/cookiecutter.json deleted file mode 100644 index 2ec6fb298f..0000000000 --- a/molecule/cookiecutter/scenario/driver/openstack/cookiecutter.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "molecule_directory": "molecule", - "role_name": "OVERRIDDEN", - "scenario_name": "OVERRIDDEN" -} diff --git a/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/INSTALL.rst b/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/INSTALL.rst deleted file mode 100644 index ec4b20cd17..0000000000 --- a/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/INSTALL.rst +++ /dev/null @@ -1,22 +0,0 @@ -******* -Openstack driver installation guide -******* - -Requirements -============ - -* An OpenStack openrc file - -Install -======= - -Please refer to the `Virtual environment`_ documentation for installation best -practices. If not using a virtual environment, please consider passing the -widely recommended `'--user' flag`_ when invoking ``pip``. - -.. _Virtual environment: https://virtualenv.pypa.io/en/latest/ -.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site - -.. code-block:: bash - - $ pip install 'molecule[openstack]' diff --git a/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml b/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml deleted file mode 100644 index 015d14f927..0000000000 --- a/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml +++ /dev/null @@ -1,132 +0,0 @@ ---- -{% raw -%} -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ molecule_no_log }}" - vars: - ssh_user: cloud-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: "Security group for testing Molecule" - security_group_rules: - - proto: tcp - port: "{{ ssh_port }}" - cidr: '0.0.0.0/0' - - proto: icmp - port: -1 - cidr: '0.0.0.0/0' - - ethertype: IPv4 - group: "{{ security_group.id }}" - - ethertype: IPv6 - group: "{{ security_group.id }}" - - neutron_network_name: molecule - - keypair_name: "keypair-{{ molecule_yml['platforms'][0]['name'] }}" - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - - nova_image: Ubuntu-16.04 - nova_flavor: NO-Nano - tasks: - - name: Create security group - os_security_group: - name: "{{ security_group_name }}" - description: "{{ security_group_description }}" - register: security_group - - - name: Create security group rules - os_security_group_rule: - security_group: "{{ security_group_name }}" - protocol: "{{ item.proto | default(omit) }}" - port_range_min: "{{ item.port | default(omit) }}" - port_range_max: "{{ item.port | default(omit) }}" - remote_ip_prefix: "{{ item.cidr | default(omit) }}" - remote_group: "{{ item.group | default(omit) }}" - ethertype: "{{ item.ethertype | default(omit) }}" - with_items: "{{ security_group_rules }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - os_keypair: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - os_keypair: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Gather facts about network for use with instance creation - os_networks_facts: - name: "{{ neutron_network_name }}" - - - name: Create molecule instance(s) - os_server: - name: "{{ item.name }}" - image: "{{ item.image }}" - flavor: "{{ item.flavor }}" - security_groups: "{{ security_group_name }}" - key_name: "{{ keypair_name }}" - nics: - - net-id: "{{ openstack_networks[0]['id'] }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: os_jobs - until: os_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.openstack.name }}", - 'address': "{{ item.openstack.accessIPv4 }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", } - with_items: "{{ os_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" -{%- endraw %} diff --git a/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml b/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml deleted file mode 100644 index 1646af588b..0000000000 --- a/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -{% raw -%} -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ molecule_no_log }}" - tasks: - - name: Destroy molecule instance(s) - os_server: - name: "{{ item.name }}" - state: absent - delete_fip: true - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: os_jobs - until: os_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool -{%- endraw %} diff --git a/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/playbook.yml b/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/playbook.yml deleted file mode 100644 index fecf1c843b..0000000000 --- a/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/playbook.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: Converge - hosts: all - tasks: - - name: "Include {{ cookiecutter.role_name }}" - include_role: - name: "{{ cookiecutter.role_name }}" diff --git a/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/prepare.yml b/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/prepare.yml deleted file mode 100644 index babe225095..0000000000 --- a/molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/prepare.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -{% raw -%} -- name: Prepare - hosts: all - gather_facts: false - tasks: - - name: Install python for Ansible - raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal python-zipstream) - become: true - changed_when: false -{%- endraw %} diff --git a/molecule/driver/openstack.py b/molecule/driver/openstack.py deleted file mode 100644 index 44c8d33e1b..0000000000 --- a/molecule/driver/openstack.py +++ /dev/null @@ -1,142 +0,0 @@ -# Copyright (c) 2015-2018 Cisco Systems, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. - -from molecule import logger -from molecule.api import Driver - -from molecule import util - -LOG = logger.get_logger(__name__) - - -class Openstack(Driver): - """ - The class responsible for managing `OpenStack`_ instances. `OpenStack`_ - is `not` the default driver used in Molecule. - - Molecule leverages Ansible's `openstack_module`_, by mapping variables - from ``molecule.yml`` into ``create.yml`` and ``destroy.yml``. - - .. _`openstack_module`: https://docs.ansible.com/ansible/latest/os_server_module.html - - .. code-block:: yaml - - driver: - name: openstack - platforms: - - name: instance - - .. code-block:: bash - - $ pip install molecule[openstack] - - Change the options passed to the ssh client. - - .. code-block:: yaml - - driver: - name: openstack - ssh_connection_options: - - '-o ControlPath=~/.ansible/cp/%r@%h-%p' - - .. important:: - - Molecule does not merge lists, when overriding the developer must - provide all options. - - Provide a list of files Molecule will preserve, relative to the scenario - ephemeral directory, after any ``destroy`` subcommand execution. - - .. code-block:: yaml - - driver: - name: openstack - safe_files: - - foo - - .. _`OpenStack`: https://www.openstack.org - """ # noqa - - def __init__(self, config=None): - super(Openstack, self).__init__(config) - self._name = 'openstack' - - @property - def name(self): - return self._name - - @name.setter - def name(self, value): - self._name = value - - @property - def login_cmd_template(self): - connection_options = ' '.join(self.ssh_connection_options) - - return ( - 'ssh {{address}} ' - '-l {{user}} ' - '-p {{port}} ' - '-i {{identity_file}} ' - '{}' - ).format(connection_options) - - @property - def default_safe_files(self): - return [self.instance_config] - - @property - def default_ssh_connection_options(self): - return self._get_ssh_connection_options() - - def login_options(self, instance_name): - d = {'instance': instance_name} - - return util.merge_dicts(d, self._get_instance_config(instance_name)) - - def ansible_connection_options(self, instance_name): - try: - d = self._get_instance_config(instance_name) - - return { - 'ansible_user': d['user'], - 'ansible_host': d['address'], - 'ansible_port': d['port'], - 'ansible_private_key_file': d['identity_file'], - 'connection': 'ssh', - 'ansible_ssh_common_args': ' '.join(self.ssh_connection_options), - } - except StopIteration: - return {} - except IOError: - # Instance has yet to be provisioned , therefore the - # instance_config is not on disk. - return {} - - def _get_instance_config(self, instance_name): - instance_config_dict = util.safe_load_file(self._config.driver.instance_config) - - return next( - item for item in instance_config_dict if item['instance'] == instance_name - ) - - def sanity_checks(self): - # FIXME(decentral1se): Implement sanity checks - pass diff --git a/molecule/test/functional/conftest.py b/molecule/test/functional/conftest.py index 5c8b5722fe..d034767cdc 100644 --- a/molecule/test/functional/conftest.py +++ b/molecule/test/functional/conftest.py @@ -75,7 +75,6 @@ def skip_test(request, driver_name): support_checks_map = { 'docker': supports_docker, 'podman': lambda: min_ansible("2.8.6"), - 'openstack': supports_openstack, 'vagrant': supports_vagrant_virtualbox, 'delegated': demands_delegated, } @@ -279,18 +278,3 @@ def supports_vagrant_virtualbox(): @pytest.helpers.register def demands_delegated(): return pytest.config.getoption('--delegated') - - -@pytest.helpers.register -def supports_openstack(): - pytest.importorskip('shade') # Ansible provides no import - - env_vars = ( - 'OS_AUTH_URL', - 'OS_PASSWORD', - 'OS_REGION_NAME', - 'OS_USERNAME', - 'OS_TENANT_NAME', - ) - - return _env_vars_exposed(env_vars) diff --git a/molecule/test/functional/test_command.py b/molecule/test/functional/test_command.py index f66b1b29e4..fcb8724ff2 100644 --- a/molecule/test/functional/test_command.py +++ b/molecule/test/functional/test_command.py @@ -47,7 +47,6 @@ def driver_name(request): 'scenario_to_test, driver_name, scenario_name', [ ('driver/docker', 'docker', 'default'), - ('driver/openstack', 'openstack', 'default'), ('driver/delegated', 'delegated', 'docker'), ('driver/vagrant', 'vagrant', 'default'), ('driver/podman', 'podman', 'default'), @@ -64,7 +63,6 @@ def test_command_check(scenario_to_test, with_scenario, scenario_name): 'scenario_to_test, driver_name, scenario_name', [ ('driver/docker', 'docker', 'default'), - ('driver/openstack', 'openstack', 'default'), ('driver/delegated', 'delegated', 'docker'), ('driver/vagrant', 'vagrant', 'default'), ('driver/podman', 'podman', 'default'), @@ -81,7 +79,6 @@ def test_command_cleanup(scenario_to_test, with_scenario, scenario_name): 'scenario_to_test, driver_name, scenario_name', [ ('driver/docker', 'docker', 'default'), - ('driver/openstack', 'openstack', 'default'), ('driver/delegated', 'delegated', 'docker'), ('driver/vagrant', 'vagrant', 'default'), ('driver/podman', 'podman', 'default'), @@ -98,7 +95,6 @@ def test_command_converge(scenario_to_test, with_scenario, scenario_name): 'scenario_to_test, driver_name, scenario_name', [ ('driver/docker', 'docker', 'default'), - ('driver/openstack', 'openstack', 'default'), ('driver/delegated', 'delegated', 'docker'), ('driver/vagrant', 'vagrant', 'default'), ('driver/podman', 'podman', 'default'), @@ -118,7 +114,6 @@ def test_command_create(scenario_to_test, with_scenario, scenario_name): 'scenario_to_test, driver_name, scenario_name', [ ('dependency', 'docker', 'ansible-galaxy'), - ('dependency', 'openstack', 'ansible-galaxy'), ('dependency', 'vagrant', 'ansible-galaxy'), ('dependency', 'podman', 'ansible-galaxy'), ], @@ -145,7 +140,6 @@ def test_command_dependency_ansible_galaxy( 'scenario_to_test, driver_name, scenario_name', [ ('dependency', 'docker', 'gilt'), - ('dependency', 'openstack', 'gilt'), ('dependency', 'vagrant', 'gilt'), ('dependency', 'podman', 'gilt'), ], @@ -168,7 +162,6 @@ def test_command_dependency_gilt( 'scenario_to_test, driver_name, scenario_name', [ ('dependency', 'docker', 'shell'), - ('dependency', 'openstack', 'shell'), ('dependency', 'vagrant', 'shell'), ('dependency', 'podman', 'shell'), ], @@ -191,7 +184,6 @@ def test_command_dependency_shell( 'scenario_to_test, driver_name, scenario_name', [ ('driver/docker', 'docker', 'default'), - ('driver/openstack', 'openstack', 'default'), ('driver/delegated', 'delegated', 'docker'), ('driver/vagrant', 'vagrant', 'default'), ('driver/podman', 'podman', 'default'), @@ -208,7 +200,6 @@ def test_command_destroy(scenario_to_test, with_scenario, scenario_name): 'scenario_to_test, driver_name, scenario_name', [ ('driver/docker', 'docker', 'default'), - ('driver/openstack', 'openstack', 'default'), ('driver/delegated', 'delegated', 'docker'), ('driver/vagrant', 'vagrant', 'default'), ('driver/podman', 'podman', 'default'), @@ -220,18 +211,14 @@ def test_command_idempotence(scenario_to_test, with_scenario, scenario_name): @pytest.mark.parametrize( - 'driver_name', - [('docker'), ('openstack'), ('vagrant'), ('podman')], - indirect=['driver_name'], + 'driver_name', [('docker'), ('vagrant'), ('podman')], indirect=['driver_name'] ) def test_command_init_role(temp_dir, driver_name, skip_test): pytest.helpers.init_role(temp_dir, driver_name) @pytest.mark.parametrize( - 'driver_name', - [('docker'), ('openstack'), ('vagrant'), ('podman')], - indirect=['driver_name'], + 'driver_name', [('docker'), ('vagrant'), ('podman')], indirect=['driver_name'] ) def test_command_init_scenario(temp_dir, driver_name, skip_test): pytest.helpers.init_scenario(temp_dir, driver_name) @@ -241,7 +228,6 @@ def test_command_init_scenario(temp_dir, driver_name, skip_test): 'scenario_to_test, driver_name, scenario_name', [ ('driver/docker', 'docker', 'default'), - ('driver/openstack', 'openstack', 'default'), ('driver/delegated', 'delegated', 'docker'), ('driver/vagrant', 'vagrant', 'default'), ('driver/podman', 'podman', 'default'), @@ -267,17 +253,6 @@ def test_command_lint(scenario_to_test, with_scenario, scenario_name): instance docker ansible default false false instance-1 docker ansible multi-node false false instance-2 docker ansible multi-node false false -""".strip(), - ), # noqa - ( - 'driver/openstack', - 'openstack', - """ -Instance Name Driver Name Provisioner Name Scenario Name Created Converged ---------------- ------------- ------------------ --------------- --------- ----------- -instance openstack ansible default false false -instance-1 openstack ansible multi-node false false -instance-2 openstack ansible multi-node false false """.strip(), ), # noqa ( @@ -330,15 +305,6 @@ def test_command_list(scenario_to_test, with_scenario, expected): instance docker ansible default false false instance-1 docker ansible multi-node false false instance-2 docker ansible multi-node false false -""".strip(), - ), - ( - 'driver/openstack', - 'openstack', - """ -instance openstack ansible default false false -instance-1 openstack ansible multi-node false false -instance-2 openstack ansible multi-node false false """.strip(), ), ( @@ -384,12 +350,6 @@ def test_command_list_with_format_plain(scenario_to_test, with_scenario, expecte [['instance-1', '.*instance-1.*'], ['instance-2', '.*instance-2.*']], 'multi-node', ), - ( - 'driver/openstack', - 'openstack', - [['instance-1', '.*instance-1.*'], ['instance-2', '.*instance-2.*']], - 'multi-node', - ), ( 'driver/delegated', 'delegated', @@ -419,7 +379,6 @@ def test_command_login(scenario_to_test, with_scenario, login_args, scenario_nam 'scenario_to_test, driver_name, scenario_name', [ ('driver/docker', 'docker', 'default'), - ('driver/openstack', 'openstack', 'default'), ('driver/delegated', 'delegated', 'docker'), ('driver/vagrant', 'vagrant', 'default'), ('driver/podman', 'podman', 'default'), @@ -440,7 +399,6 @@ def test_command_prepare(scenario_to_test, with_scenario, scenario_name): 'scenario_to_test, driver_name, scenario_name', [ ('driver/docker', 'docker', 'default'), - ('driver/openstack', 'openstack', 'default'), ('driver/delegated', 'delegated', 'docker'), ('driver/vagrant', 'vagrant', 'default'), ('driver/podman', 'podman', 'default'), @@ -457,7 +415,6 @@ def test_command_side_effect(scenario_to_test, with_scenario, scenario_name): 'scenario_to_test, driver_name, scenario_name', [ ('driver/docker', 'docker', 'default'), - ('driver/openstack', 'openstack', 'default'), ('driver/delegated', 'delegated', 'docker'), ('driver/vagrant', 'vagrant', 'default'), ('driver/podman', 'podman', 'default'), @@ -476,7 +433,6 @@ def test_command_syntax(scenario_to_test, with_scenario, scenario_name): ('driver/docker', 'docker', 'default'), ('driver/docker', 'docker', 'ansible-verifier'), ('driver/docker', 'docker', 'multi-node'), - ('driver/openstack', 'openstack', None), ('driver/delegated', 'delegated', 'docker'), ('driver/vagrant', 'vagrant', None), ('driver/podman', 'podman', 'default'), @@ -491,7 +447,6 @@ def test_command_test(scenario_to_test, with_scenario, scenario_name, driver_nam 'scenario_to_test, driver_name, scenario_name', [ ('driver/docker', 'docker', 'default'), - ('driver/openstack', 'openstack', 'default'), ('driver/delegated', 'delegated', 'docker'), ('driver/vagrant', 'vagrant', 'default'), ('driver/podman', 'podman', 'default'), diff --git a/molecule/test/resources/playbooks/delegated/create.yml b/molecule/test/resources/playbooks/delegated/create.yml index 8ec356b902..376893f2fb 100644 --- a/molecule/test/resources/playbooks/delegated/create.yml +++ b/molecule/test/resources/playbooks/delegated/create.yml @@ -5,5 +5,4 @@ gather_facts: false tasks: - include: create/docker.yml - - include: create/openstack.yml # - include: create/vagrant.yml diff --git a/molecule/test/resources/playbooks/delegated/create/openstack.yml b/molecule/test/resources/playbooks/delegated/create/openstack.yml deleted file mode 100644 index bd7981fbe2..0000000000 --- a/molecule/test/resources/playbooks/delegated/create/openstack.yml +++ /dev/null @@ -1,53 +0,0 @@ ---- -- name: Test for presence of local keypair - stat: - path: "{{ openstack.key_path }}" - register: keypair_local - -- name: Delete remote keypair - os_keypair: - name: "{{ openstack.key_name }}" - state: absent - when: not keypair_local.stat.exists - -- name: Create keypair - os_keypair: - name: "{{ openstack.key_name }}" - register: keypair - -- name: Persist the keypair - copy: - dest: "{{ openstack.key_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - -- name: Gather facts about network for use with instance creation - os_networks_facts: - name: molecule - -- name: Create molecule instance(s) - os_server: - name: "{{ openstack.name }}" - image: Ubuntu-16.04 - flavor: NO-Nano - security_groups: - - molecule - key_name: "{{ openstack.key_name }}" - nics: - - net-id: "{{ openstack_networks[0]['id'] }}" - register: server - -- name: Persist ssh config - copy: - dest: "{{ openstack.ssh_config_path }}" - content: | - Host "{{ openstack.name }}" - HostName "{{ server.openstack.accessIPv4 }}" - User "{{ openstack.ssh_user }}" - IdentityFile "{{ openstack.key_path }}" - UserKnownHostsFile=/dev/null - IdentitiesOnly=yes - StrictHostKeyChecking=no - CheckHostIP=no - when: server.changed diff --git a/molecule/test/resources/playbooks/delegated/destroy.yml b/molecule/test/resources/playbooks/delegated/destroy.yml index 07998d7657..2af509cbba 100644 --- a/molecule/test/resources/playbooks/delegated/destroy.yml +++ b/molecule/test/resources/playbooks/delegated/destroy.yml @@ -5,5 +5,4 @@ gather_facts: false tasks: - include: destroy/docker.yml - - include: destroy/openstack.yml # - include: create/vagrant.yml diff --git a/molecule/test/resources/playbooks/delegated/destroy/openstack.yml b/molecule/test/resources/playbooks/delegated/destroy/openstack.yml deleted file mode 100644 index 1bcbdde76c..0000000000 --- a/molecule/test/resources/playbooks/delegated/destroy/openstack.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- name: Destroy molecule instance(s) - os_server: - name: delegated-instance-openstack - state: absent - delete_fip: true - -- name: Cleanup temporary files file - file: - path: "{{ item }}" - state: absent - with_items: - - "{{ openstack.key_path }}" - - "{{ openstack.ssh_config_path }}" diff --git a/molecule/test/resources/playbooks/delegated/inventory/group_vars/all/all.yml b/molecule/test/resources/playbooks/delegated/inventory/group_vars/all/all.yml index f1801cdbc0..7d4178f6bb 100644 --- a/molecule/test/resources/playbooks/delegated/inventory/group_vars/all/all.yml +++ b/molecule/test/resources/playbooks/delegated/inventory/group_vars/all/all.yml @@ -1,12 +1,2 @@ --- base_dir: /tmp - -openstack: - name: delegated-instance-openstack - key_name: molecule - key_path: "{{ base_dir }}/ssh-key-openstack" - ssh_config_path: "{{ base_dir }}/ssh-config-openstack" - ssh_user: cloud-user - -openstack_key_path: "{{ base_dir }}/ssh-key-openstack" -openstack_ssh_config_path: "{{ base_dir }}/ssh-config-openstack" diff --git a/molecule/test/resources/playbooks/openstack/create.yml b/molecule/test/resources/playbooks/openstack/create.yml deleted file mode 100644 index 4329739707..0000000000 --- a/molecule/test/resources/playbooks/openstack/create.yml +++ /dev/null @@ -1,130 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ molecule_no_log }}" - vars: - ssh_user: cloud-user - ssh_port: 22 - - security_group_name: molecule - security_group_description: "Security group for testing Molecule" - security_group_rules: - - proto: tcp - port: "{{ ssh_port }}" - cidr: '0.0.0.0/0' - - proto: icmp - port: -1 - cidr: '0.0.0.0/0' - - ethertype: IPv4 - group: "{{ security_group.id }}" - - ethertype: IPv6 - group: "{{ security_group.id }}" - - neutron_network_name: molecule - - keypair_name: molecule_key - keypair_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key" - - nova_image: Ubuntu-16.04 - nova_flavor: NO-Nano - tasks: - - name: Create security group - os_security_group: - name: "{{ security_group_name }}" - description: "{{ security_group_description }}" - register: security_group - - - name: Create security group rules - os_security_group_rule: - security_group: "{{ security_group_name }}" - protocol: "{{ item.proto | default(omit) }}" - port_range_min: "{{ item.port | default(omit) }}" - port_range_max: "{{ item.port | default(omit) }}" - remote_ip_prefix: "{{ item.cidr | default(omit) }}" - remote_group: "{{ item.group | default(omit) }}" - ethertype: "{{ item.ethertype | default(omit) }}" - with_items: "{{ security_group_rules }}" - - - name: Test for presence of local keypair - stat: - path: "{{ keypair_path }}" - register: keypair_local - - - name: Delete remote keypair - os_keypair: - name: "{{ keypair_name }}" - state: absent - when: not keypair_local.stat.exists - - - name: Create keypair - os_keypair: - name: "{{ keypair_name }}" - register: keypair - - - name: Persist the keypair - copy: - dest: "{{ keypair_path }}" - content: "{{ keypair.key.private_key }}" - mode: 0600 - when: keypair.changed - - - name: Gather facts about network for use with instance creation - os_networks_facts: - name: "{{ neutron_network_name }}" - - - name: Create molecule instance(s) - os_server: - name: "{{ item.name }}" - image: "{{ item.image }}" - flavor: "{{ item.flavor }}" - security_groups: "{{ security_group_name }}" - key_name: "{{ keypair_name }}" - nics: - - net-id: "{{ openstack_networks[0]['id'] }}" - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) creation to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: os_jobs - until: os_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config dict - set_fact: - instance_conf_dict: { - 'instance': "{{ item.openstack.name }}", - 'address': "{{ item.openstack.accessIPv4 }}", - 'user': "{{ ssh_user }}", - 'port': "{{ ssh_port }}", - 'identity_file': "{{ keypair_path }}", } - with_items: "{{ os_jobs.results }}" - register: instance_config_dict - when: server.changed | bool - - - name: Convert instance config dict to a list - set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - when: server.changed | bool - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool - - - name: Wait for SSH - wait_for: - port: "{{ ssh_port }}" - host: "{{ item.address }}" - search_regex: SSH - delay: 10 - with_items: "{{ lookup('file', molecule_instance_config) | molecule_from_yaml }}" diff --git a/molecule/test/resources/playbooks/openstack/destroy.yml b/molecule/test/resources/playbooks/openstack/destroy.yml deleted file mode 100644 index 4799425cf2..0000000000 --- a/molecule/test/resources/playbooks/openstack/destroy.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ molecule_no_log }}" - tasks: - - name: Destroy molecule instance(s) - os_server: - name: "{{ item.name }}" - state: absent - delete_fip: true - register: server - with_items: "{{ molecule_yml.platforms }}" - async: 7200 - poll: 0 - - - name: Wait for instance(s) deletion to complete - async_status: - jid: "{{ item.ansible_job_id }}" - register: os_jobs - until: os_jobs.finished - retries: 300 - with_items: "{{ server.results }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - set_fact: - instance_conf: {} - - - name: Dump instance config - copy: - content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}" - dest: "{{ molecule_instance_config }}" - when: server.changed | bool diff --git a/molecule/test/scenarios/driver/openstack/molecule/default/molecule.yml b/molecule/test/scenarios/driver/openstack/molecule/default/molecule.yml deleted file mode 100644 index 54a8df5701..0000000000 --- a/molecule/test/scenarios/driver/openstack/molecule/default/molecule.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -dependency: - name: galaxy -driver: - name: openstack -lint: - name: yamllint - options: - config-file: ../../../resources/.yamllint -platforms: - - name: instance -provisioner: - name: ansible - config_options: - defaults: - callback_whitelist: profile_roles,profile_tasks,timer - playbooks: - create: ../../../../../resources/playbooks/openstack/create.yml - destroy: ../../../../../resources/playbooks/openstack/destroy.yml - env: - ANSIBLE_ROLES_PATH: ../../../../../resources/roles/ - lint: - name: ansible-lint -scenario: - name: default -verifier: - name: testinfra - lint: - name: flake8 diff --git a/molecule/test/scenarios/driver/openstack/molecule/default/playbook.yml b/molecule/test/scenarios/driver/openstack/molecule/default/playbook.yml deleted file mode 100644 index 2d0e971e3e..0000000000 --- a/molecule/test/scenarios/driver/openstack/molecule/default/playbook.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: Converge - hosts: all - gather_facts: false - become: true - roles: - - molecule diff --git a/molecule/test/scenarios/driver/openstack/molecule/default/prepare.yml b/molecule/test/scenarios/driver/openstack/molecule/default/prepare.yml deleted file mode 100644 index ddb01fbf96..0000000000 --- a/molecule/test/scenarios/driver/openstack/molecule/default/prepare.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- name: Prepare - hosts: all - gather_facts: false - tasks: - - name: Install python for Ansible - raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal python-zipstream) - become: true - changed_when: false diff --git a/molecule/test/scenarios/driver/openstack/molecule/default/tests/test_default.py b/molecule/test/scenarios/driver/openstack/molecule/default/tests/test_default.py deleted file mode 100644 index c5a065648b..0000000000 --- a/molecule/test/scenarios/driver/openstack/molecule/default/tests/test_default.py +++ /dev/null @@ -1,29 +0,0 @@ -import os - -import testinfra.utils.ansible_runner - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ['MOLECULE_INVENTORY_FILE'] -).get_hosts('all') - - -def test_hostname(host): - assert 'instance' == host.check_output('hostname -s') - - -def test_etc_molecule_directory(host): - f = host.file('/etc/molecule') - - assert f.is_directory - assert f.user == 'root' - assert f.group == 'root' - assert f.mode == 0o755 - - -def test_etc_molecule_ansible_hostname_file(host): - f = host.file('/etc/molecule/instance') - - assert f.is_file - assert f.user == 'root' - assert f.group == 'root' - assert f.mode == 0o644 diff --git a/molecule/test/scenarios/driver/openstack/molecule/multi-node/molecule.yml b/molecule/test/scenarios/driver/openstack/molecule/multi-node/molecule.yml deleted file mode 100644 index cd8fcc01e8..0000000000 --- a/molecule/test/scenarios/driver/openstack/molecule/multi-node/molecule.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- -dependency: - name: galaxy -driver: - name: openstack -lint: - name: yamllint - options: - config-file: ../../../resources/.yamllint -platforms: - - name: instance-1 - groups: - - foo - - bar - - name: instance-2 - groups: - - foo - - baz -provisioner: - name: ansible - config_options: - defaults: - callback_whitelist: profile_roles,profile_tasks,timer - playbooks: - create: ../../../../../resources/playbooks/openstack/create.yml - destroy: ../../../../../resources/playbooks/openstack/destroy.yml - env: - ANSIBLE_ROLES_PATH: ../../../../../resources/roles/ - lint: - name: ansible-lint -scenario: - name: multi-node -verifier: - name: testinfra - lint: - name: flake8 diff --git a/molecule/test/scenarios/driver/openstack/molecule/multi-node/playbook.yml b/molecule/test/scenarios/driver/openstack/molecule/multi-node/playbook.yml deleted file mode 100644 index 8fe4807ffd..0000000000 --- a/molecule/test/scenarios/driver/openstack/molecule/multi-node/playbook.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -- name: Converge - hosts: all - gather_facts: false - become: true - roles: - - molecule - -- name: Converge - hosts: bar - gather_facts: false - become: true - roles: - - molecule - -- name: Converge - hosts: foo - gather_facts: false - become: true - roles: - - molecule - -- name: Converge - hosts: baz - gather_facts: false - become: true - roles: - - molecule diff --git a/molecule/test/scenarios/driver/openstack/molecule/multi-node/prepare.yml b/molecule/test/scenarios/driver/openstack/molecule/multi-node/prepare.yml deleted file mode 100644 index ddb01fbf96..0000000000 --- a/molecule/test/scenarios/driver/openstack/molecule/multi-node/prepare.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- name: Prepare - hosts: all - gather_facts: false - tasks: - - name: Install python for Ansible - raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal python-zipstream) - become: true - changed_when: false diff --git a/molecule/test/scenarios/driver/openstack/molecule/multi-node/tests/__init__.py b/molecule/test/scenarios/driver/openstack/molecule/multi-node/tests/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/molecule/test/scenarios/driver/openstack/molecule/multi-node/tests/test_default.py b/molecule/test/scenarios/driver/openstack/molecule/multi-node/tests/test_default.py deleted file mode 100644 index f4239f0b65..0000000000 --- a/molecule/test/scenarios/driver/openstack/molecule/multi-node/tests/test_default.py +++ /dev/null @@ -1,31 +0,0 @@ -import os -import re - -import testinfra.utils.ansible_runner - -testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( - os.environ['MOLECULE_INVENTORY_FILE'] -).get_hosts('all') - - -def test_hostname(host): - assert re.search(r'instance-[12]', host.check_output('hostname -s')) - - -def test_etc_molecule_directory(host): - f = host.file('/etc/molecule') - - assert f.is_directory - assert f.user == 'root' - assert f.group == 'root' - assert f.mode == 0o755 - - -def test_etc_molecule_ansible_hostname_file(host): - filename = '/etc/molecule/{}'.format(host.check_output('hostname -s')) - f = host.file(filename) - - assert f.is_file - assert f.user == 'root' - assert f.group == 'root' - assert f.mode == 0o644 diff --git a/molecule/test/unit/cookiecutter/test_molecule.py b/molecule/test/unit/cookiecutter/test_molecule.py index 4566ad7147..2b7cd6deec 100644 --- a/molecule/test/unit/cookiecutter/test_molecule.py +++ b/molecule/test/unit/cookiecutter/test_molecule.py @@ -92,7 +92,7 @@ def test_vagrant_driver( pytest.helpers.run_command(cmd) -@pytest.mark.parametrize('driver', [('docker'), ('openstack'), ('vagrant')]) +@pytest.mark.parametrize('driver', [('docker'), ('vagrant')]) def test_drivers( driver, temp_dir, _molecule_file, _role_directory, _command_args, _instance ): diff --git a/molecule/test/unit/driver/test_openstack.py b/molecule/test/unit/driver/test_openstack.py deleted file mode 100644 index 35e5a70e9b..0000000000 --- a/molecule/test/unit/driver/test_openstack.py +++ /dev/null @@ -1,225 +0,0 @@ -# Copyright (c) 2015-2018 Cisco Systems, Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. - -import os - -import pytest - -from molecule import config -from molecule.driver import openstack - - -# NOTE(retr0h): The use of the `patched_config_validate` fixture, disables -# config.Config._validate from executing. Thus preventing odd side-effects -# throughout patched.assert_called unit tests. -@pytest.fixture -def _instance(patched_config_validate, config_instance): - return openstack.Openstack(config_instance) - - -def test_config_private_member(_instance): - assert isinstance(_instance._config, config.Config) - - -def test_testinfra_options_property(_instance): - assert { - 'connection': 'ansible', - 'ansible-inventory': _instance._config.provisioner.inventory_file, - } == _instance.testinfra_options - - -def test_name_property(_instance): - assert 'openstack' == _instance.name - - -def test_options_property(_instance): - x = {'managed': True} - - assert x == _instance.options - - -def test_login_cmd_template_property(_instance): - x = ( - 'ssh {address} -l {user} -p {port} -i {identity_file} ' - '-o UserKnownHostsFile=/dev/null ' - '-o ControlMaster=auto ' - '-o ControlPersist=60s ' - '-o IdentitiesOnly=yes ' - '-o StrictHostKeyChecking=no' - ) - - assert x == _instance.login_cmd_template - - -def test_safe_files_property(_instance): - x = [ - os.path.join( - _instance._config.scenario.ephemeral_directory, 'instance_config.yml' - ) - ] - - assert x == _instance.safe_files - - -def test_default_safe_files_property(_instance): - x = [ - os.path.join( - _instance._config.scenario.ephemeral_directory, 'instance_config.yml' - ) - ] - - assert x == _instance.default_safe_files - - -def test_delegated_property(_instance): - assert not _instance.delegated - - -def test_managed_property(_instance): - assert _instance.managed - - -def test_default_ssh_connection_options_property(_instance): - x = [ - '-o UserKnownHostsFile=/dev/null', - '-o ControlMaster=auto', - '-o ControlPersist=60s', - '-o IdentitiesOnly=yes', - '-o StrictHostKeyChecking=no', - ] - - assert x == _instance.default_ssh_connection_options - - -def test_login_options(mocker, _instance): - m = mocker.patch('molecule.driver.openstack.Openstack._get_instance_config') - m.return_value = { - 'instance': 'foo', - 'address': '172.16.0.2', - 'user': 'cloud-user', - 'port': 22, - 'identity_file': '/foo/bar', - } - - x = { - 'instance': 'foo', - 'address': '172.16.0.2', - 'user': 'cloud-user', - 'port': 22, - 'identity_file': '/foo/bar', - } - assert x == _instance.login_options('foo') - - -def test_ansible_connection_options(mocker, _instance): - m = mocker.patch('molecule.driver.openstack.Openstack._get_instance_config') - m.return_value = { - 'instance': 'foo', - 'address': '172.16.0.2', - 'user': 'cloud-user', - 'port': 22, - 'identity_file': '/foo/bar', - } - - x = { - 'ansible_host': '172.16.0.2', - 'ansible_port': 22, - 'ansible_user': 'cloud-user', - 'ansible_private_key_file': '/foo/bar', - 'connection': 'ssh', - 'ansible_ssh_common_args': ( - '-o UserKnownHostsFile=/dev/null ' - '-o ControlMaster=auto ' - '-o ControlPersist=60s ' - '-o IdentitiesOnly=yes ' - '-o StrictHostKeyChecking=no' - ), - } - assert x == _instance.ansible_connection_options('foo') - - -def test_ansible_connection_options_handles_missing_instance_config(mocker, _instance): - m = mocker.patch('molecule.util.safe_load_file') - m.side_effect = IOError - - assert {} == _instance.ansible_connection_options('foo') - - -def test_ansible_connection_options_handles_missing_results_key(mocker, _instance): - m = mocker.patch('molecule.util.safe_load_file') - m.side_effect = StopIteration - - assert {} == _instance.ansible_connection_options('foo') - - -def test_instance_config_property(_instance): - x = os.path.join( - _instance._config.scenario.ephemeral_directory, 'instance_config.yml' - ) - - assert x == _instance.instance_config - - -def test_ssh_connection_options_property(_instance): - x = [ - '-o UserKnownHostsFile=/dev/null', - '-o ControlMaster=auto', - '-o ControlPersist=60s', - '-o IdentitiesOnly=yes', - '-o StrictHostKeyChecking=no', - ] - - assert x == _instance.ssh_connection_options - - -def test_status(mocker, _instance): - result = _instance.status() - - assert 2 == len(result) - - assert result[0].instance_name == 'instance-1' - assert result[0].driver_name == 'openstack' - assert result[0].provisioner_name == 'ansible' - assert result[0].scenario_name == 'default' - assert result[0].created == 'false' - assert result[0].converged == 'false' - - assert result[1].instance_name == 'instance-2' - assert result[1].driver_name == 'openstack' - assert result[1].provisioner_name == 'ansible' - assert result[1].scenario_name == 'default' - assert result[1].created == 'false' - assert result[1].converged == 'false' - - -def test_get_instance_config(mocker, _instance): - m = mocker.patch('molecule.util.safe_load_file') - m.return_value = [{'instance': 'foo'}, {'instance': 'bar'}] - - x = {'instance': 'foo'} - assert x == _instance._get_instance_config('foo') - - -def test_created(_instance): - assert 'false' == _instance._created() - - -def test_converged(_instance): - assert 'false' == _instance._converged() diff --git a/molecule/test/unit/model/v2/test_driver_section.py b/molecule/test/unit/model/v2/test_driver_section.py index f283c89384..fa38af77dd 100644 --- a/molecule/test/unit/model/v2/test_driver_section.py +++ b/molecule/test/unit/model/v2/test_driver_section.py @@ -171,11 +171,6 @@ def _model_driver_allows_docker_section_data(): return {'driver': {'name': 'docker'}} -@pytest.fixture -def _model_driver_allows_openstack_section_data(): - return {'driver': {'name': 'openstack'}} - - @pytest.fixture def _model_driver_allows_vagrant_section_data(): return {'driver': {'name': 'vagrant'}} @@ -187,7 +182,6 @@ def _model_driver_allows_vagrant_section_data(): [ ('_model_driver_allows_delegated_section_data'), ('_model_driver_allows_docker_section_data'), - ('_model_driver_allows_openstack_section_data'), ('_model_driver_allows_vagrant_section_data'), ], indirect=True, diff --git a/molecule/test/unit/test_config.py b/molecule/test/unit/test_config.py index ce13f95fc4..21d1193482 100644 --- a/molecule/test/unit/test_config.py +++ b/molecule/test/unit/test_config.py @@ -122,11 +122,6 @@ def _config_driver_delegated_section_data(): return {'driver': {'name': 'delegated', 'options': {'managed': False}}} -@pytest.fixture -def _config_driver_openstack_section_data(): - return {'driver': {'name': 'openstack'}} - - @pytest.fixture def _config_driver_vagrant_section_data(): return {'driver': {'name': 'vagrant', 'provider': {'name': 'virtualbox'}}} diff --git a/setup.cfg b/setup.cfg index 59f7c04da7..7ae79060f4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -97,8 +97,6 @@ install_requires = docs = Sphinx sphinx_rtd_theme -azure = - molecule-azure docker = docker>=2.0.0 # selinux python module is needed by ansible-docker modules and allows use @@ -106,8 +104,6 @@ docker = # system selinux libraries but it will provide a clear message when user # has to do that. selinux; sys_platform=="linux2" -openstack = - shade vagrant = python-vagrant windows = @@ -130,7 +126,6 @@ console_scripts = molecule.driver = docker = molecule.driver.docker:Docker delegated = molecule.driver.delegated:Delegated - openstack = molecule.driver.openstack:Openstack podman = molecule.driver.podman:Podman vagrant = molecule.driver.vagrant:Vagrant molecule.verifier = diff --git a/tox.ini b/tox.ini index 827001951c..8221bcae5c 100644 --- a/tox.ini +++ b/tox.ini @@ -34,7 +34,6 @@ deps = extras = docker podman - openstack vagrant windows test