Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit 66b5e57

Browse files
authoredFeb 25, 2020
Merge pull request #10 from ssbarnea/master
Reinstated Vagrant driver
2 parents 5e6d51b + 78582f9 commit 66b5e57

File tree

36 files changed

+1075
-349
lines changed

36 files changed

+1075
-349
lines changed
 

‎.pre-commit-config.yaml

+53-20
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
---
2+
default_language_version:
3+
python: python3
4+
minimum_pre_commit_version: "1.14.0"
25
repos:
3-
- repo: https://github.com/PyCQA/doc8.git
4-
rev: 0.8.1rc1
5-
hooks:
6-
- id: doc8
7-
- repo: https://github.com/python/black.git
8-
rev: 19.3b0
9-
hooks:
10-
- id: black
11-
language_version: python3
12-
- repo: https://github.com/pre-commit/pre-commit-hooks.git
13-
rev: v2.2.3
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
rev: v2.5.0
148
hooks:
159
- id: end-of-file-fixer
1610
- id: trailing-whitespace
@@ -19,21 +13,27 @@ repos:
1913
- id: check-executables-have-shebangs
2014
- id: check-merge-conflict
2115
- id: debug-statements
16+
- id: check-yaml
17+
files: .*\.(yaml|yml)$
18+
# https://github.com/pre-commit/pre-commit-hooks/issues/273
19+
args: ["--unsafe"]
20+
- repo: https://github.com/PyCQA/doc8.git
21+
rev: 0.8.1rc3
22+
hooks:
23+
- id: doc8
24+
- repo: https://github.com/python/black.git
25+
rev: 19.10b0
26+
hooks:
27+
- id: black
28+
language_version: python3
2229
- repo: https://gitlab.com/pycqa/flake8.git
23-
rev: 3.7.8
30+
rev: 3.7.9
2431
hooks:
2532
- id: flake8
2633
additional_dependencies:
2734
- flake8-black
28-
- repo: https://github.com/adrienverge/yamllint.git
29-
rev: v1.16.0
30-
hooks:
31-
- id: yamllint
32-
files: \.(yaml|yml)$
33-
types: [file, yaml]
34-
entry: yamllint --strict
3535
- repo: https://github.com/codespell-project/codespell.git
36-
rev: v1.15.0
36+
rev: v1.16.0
3737
hooks:
3838
- id: codespell
3939
name: codespell
@@ -44,3 +44,36 @@ repos:
4444
args: []
4545
require_serial: false
4646
additional_dependencies: []
47+
- repo: https://github.com/PyCQA/flake8.git
48+
rev: 3.7.9
49+
hooks:
50+
- id: flake8
51+
- repo: https://github.com/adrienverge/yamllint.git
52+
rev: v1.20.0
53+
hooks:
54+
- id: yamllint
55+
files: \.(yaml|yml)$
56+
types: [file, yaml]
57+
entry: yamllint --strict -f parsable
58+
- repo: https://github.com/openstack-dev/bashate.git
59+
rev: 1.0.0
60+
hooks:
61+
- id: bashate
62+
entry: bashate --error . --ignore=E006,E040
63+
# Run bashate check for all bash scripts
64+
# Ignores the following rules:
65+
# E006: Line longer than 79 columns (as many scripts use jinja
66+
# templating, this is very difficult)
67+
# E040: Syntax error determined using `bash -n` (as many scripts
68+
# use jinja templating, this will often fail and the syntax
69+
# error will be discovered in execution anyway)
70+
- repo: https://github.com/ansible/ansible-lint.git
71+
rev: v4.2.0
72+
hooks:
73+
- id: ansible-lint
74+
always_run: true
75+
pass_filenames: false
76+
# do not add file filters here as ansible-lint does not give reliable
77+
# results when called with individual files.
78+
# https://github.com/ansible/ansible-lint/issues/611
79+
entry: env ANSIBLE_LIBRARY=molecule_vagrant/modules ansible-lint --force-color -p -v

‎README.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ Molecule Vagrant Plugin
66
:target: https://badge.fury.io/py/molecule-vagrant
77
:alt: PyPI Package
88

9-
.. image:: https://img.shields.io/travis/com/pycontribs/molecule-vagrant/master.svg?label=Linux%20builds%20%40%20Travis%20CI
10-
:target: https://travis-ci.com/pycontribs/molecule-vagrant
9+
.. image:: https://zuul-ci.org/gated.svg
10+
:target: https://dashboard.zuul.ansible.com/t/ansible/builds?project=ansible-community/molecule-vagrant
1111

1212
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
1313
:target: https://github.com/python/black
1414
:alt: Python Black Code Style
1515

16-
.. image:: https://img.shields.io/badge/Code%20of%20Conduct-Ansible-silver.svg
16+
.. image:: https://img.shields.io/badge/Code%20of%20Conduct-silver.svg
1717
:target: https://docs.ansible.com/ansible/latest/community/code_of_conduct.html
1818
:alt: Ansible Code of Conduct
1919

20-
.. image:: https://img.shields.io/badge/Mailing%20lists-Ansible-orange.svg
20+
.. image:: https://img.shields.io/badge/Mailing%20lists-silver.svg
2121
:target: https://docs.ansible.com/ansible/latest/community/communication.html#mailing-list-information
2222
:alt: Ansible mailing lists
2323

‎bindep.txt

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This is a cross-platform list tracking distribution packages needed by tests;
2+
# see https://docs.openstack.org/infra/bindep/ for additional information.
3+
4+
build-dep [platform:dpkg]
5+
dnsmasq-base [platform:dpkg]
6+
ebtables [platform:dpkg]
7+
gcc [test platform:rpm]
8+
gcc-c++ [test platform:rpm]
9+
libselinux-python [platform:centos-7]
10+
libvirt [platform:rpm]
11+
libvirt-clients [platform:dpkg]
12+
libvirt-daemon [platform:dpkg]
13+
libvirt-daemon-kvm [platform:rpm]
14+
libvirt-daemon-system [platform:dpkg]
15+
libvirt-dev [platform:dpkg]
16+
libvirt-devel [platform:rpm]
17+
libxml2-dev [platform:dpkg]
18+
libxslt-dev [platform:dpkg]
19+
make [platform:centos-7]
20+
pkg-config [platform:dpkg]
21+
python3 [test platform:rpm !platform:centos-7]
22+
python3-devel [test platform:rpm !platform:centos-7]
23+
python3-libselinux [test platform:rpm !platform:centos-7]
24+
python3-libvirt [test platform:rpm !platform:centos-7 platform:dpkg]
25+
python3-netifaces [test !platform:centos-7 platform:rpm]
26+
python36 [test !platform:centos-7 !platform:fedora-28]
27+
qemu [platform:dpkg]
28+
qemu-kvm [platform:rpm]
29+
ruby-dev [platform:dpkg]
30+
ruby-devel [platform:rpm]
31+
ruby-libvirt [platform:dpkg]
32+
vagrant [platform:dpkg]
33+
zlib1g-dev [platform:dpkg]

‎molecule

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../molecule-vagrant/molecule_vagrant/test/scenarios/molecule

‎molecule_vagrant/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""Plugin exports."""
2+
3+
__name__ = __name__.split("_")[-1]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"molecule_directory": "molecule",
3+
"role_name": "OVERRIDDEN",
4+
"scenario_name": "OVERRIDDEN"
5+
}

‎molecule_vagrant/cookiecutter/scenario/driver/vagrant/cookiecutter.json

-5
This file was deleted.

‎molecule_vagrant/cookiecutter/scenario/driver/vagrant/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/prepare.yml

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
*******
1+
*********************************
22
Vagrant driver installation guide
3-
*******
3+
*********************************
44

55
Requirements
66
============
@@ -20,4 +20,4 @@ widely recommended `'--user' flag`_ when invoking ``pip``.
2020

2121
.. code-block:: bash
2222
23-
$ pip install 'molecule[vagrant]'
23+
$ pip install 'molecule_vagrant'

‎molecule_vagrant/driver.py

+28-27
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Vagrant(Driver):
3838
3939
.. important::
4040
41-
This driver is alpha quality software. Do not perform any additonal
41+
This driver is alpha quality software. Do not perform any additional
4242
tasks inside the ``create`` playbook. Molecule does not know about the
4343
Vagrant instances' configuration until the ``converge`` playbook is
4444
executed.
@@ -86,7 +86,7 @@ class Vagrant(Driver):
8686
8787
.. code-block:: bash
8888
89-
$ pip install molecule[vagrant]
89+
$ pip install molecule-vagrant
9090
9191
Change the provider passed to Vagrant.
9292
@@ -126,7 +126,7 @@ class Vagrant(Driver):
126126

127127
def __init__(self, config=None):
128128
super(Vagrant, self).__init__(config)
129-
self._name = 'vagrant'
129+
self._name = "vagrant"
130130

131131
@property
132132
def name(self):
@@ -139,20 +139,20 @@ def name(self, value):
139139
@property
140140
def testinfra_options(self):
141141
return {
142-
'connection': 'ansible',
143-
'ansible-inventory': self._config.provisioner.inventory_file,
142+
"connection": "ansible",
143+
"ansible-inventory": self._config.provisioner.inventory_file,
144144
}
145145

146146
@property
147147
def login_cmd_template(self):
148-
connection_options = ' '.join(self.ssh_connection_options)
148+
connection_options = " ".join(self.ssh_connection_options)
149149

150150
return (
151-
'ssh {{address}} '
152-
'-l {{user}} '
153-
'-p {{port}} '
154-
'-i {{identity_file}} '
155-
'{}'
151+
"ssh {{address}} "
152+
"-l {{user}} "
153+
"-p {{port}} "
154+
"-i {{identity_file}} "
155+
"{}"
156156
).format(connection_options)
157157

158158
@property
@@ -161,17 +161,17 @@ def default_safe_files(self):
161161
self.vagrantfile,
162162
self.vagrantfile_config,
163163
self.instance_config,
164-
os.path.join(self._config.scenario.ephemeral_directory, '.vagrant'),
165-
os.path.join(self._config.scenario.ephemeral_directory, 'vagrant-*.out'),
166-
os.path.join(self._config.scenario.ephemeral_directory, 'vagrant-*.err'),
164+
os.path.join(self._config.scenario.ephemeral_directory, ".vagrant"),
165+
os.path.join(self._config.scenario.ephemeral_directory, "vagrant-*.out"),
166+
os.path.join(self._config.scenario.ephemeral_directory, "vagrant-*.err"),
167167
]
168168

169169
@property
170170
def default_ssh_connection_options(self):
171171
return self._get_ssh_connection_options()
172172

173173
def login_options(self, instance_name):
174-
d = {'instance': instance_name}
174+
d = {"instance": instance_name}
175175

176176
return util.merge_dicts(d, self._get_instance_config(instance_name))
177177

@@ -180,12 +180,12 @@ def ansible_connection_options(self, instance_name):
180180
d = self._get_instance_config(instance_name)
181181

182182
return {
183-
'ansible_user': d['user'],
184-
'ansible_host': d['address'],
185-
'ansible_port': d['port'],
186-
'ansible_private_key_file': d['identity_file'],
187-
'connection': 'ssh',
188-
'ansible_ssh_common_args': ' '.join(self.ssh_connection_options),
183+
"ansible_user": d["user"],
184+
"ansible_host": d["address"],
185+
"ansible_port": d["port"],
186+
"ansible_private_key_file": d["identity_file"],
187+
"connection": "ssh",
188+
"ansible_ssh_common_args": " ".join(self.ssh_connection_options),
189189
}
190190
except StopIteration:
191191
return {}
@@ -196,17 +196,17 @@ def ansible_connection_options(self, instance_name):
196196

197197
@property
198198
def vagrantfile(self):
199-
return os.path.join(self._config.scenario.ephemeral_directory, 'Vagrantfile')
199+
return os.path.join(self._config.scenario.ephemeral_directory, "Vagrantfile")
200200

201201
@property
202202
def vagrantfile_config(self):
203-
return os.path.join(self._config.scenario.ephemeral_directory, 'vagrant.yml')
203+
return os.path.join(self._config.scenario.ephemeral_directory, "vagrant.yml")
204204

205205
def _get_instance_config(self, instance_name):
206206
instance_config_dict = util.safe_load_file(self._config.driver.instance_config)
207207

208208
return next(
209-
item for item in instance_config_dict if item['instance'] == instance_name
209+
item for item in instance_config_dict if item["instance"] == instance_name
210210
)
211211

212212
def sanity_checks(self):
@@ -217,6 +217,7 @@ def template_dir(self):
217217
""" Return path to its own cookiecutterm templates. It is used by init
218218
command in order to figure out where to load the templates from.
219219
"""
220-
return os.path.join(
221-
os.path.dirname(__file__), "cookiecutter/scenario/driver/vagrant"
222-
)
220+
return os.path.join(os.path.dirname(__file__), "cookiecutter")
221+
222+
def modules_dir(self):
223+
return os.path.join(os.path.dirname(__file__), "modules")

‎molecule_vagrant/modules/__init__.py

Whitespace-only changes.

‎molecule_vagrant/modules/vagrant.py

+626
Large diffs are not rendered by default.

‎molecule_vagrant/playbooks/create.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
- name: Create
3+
hosts: localhost
4+
connection: local
5+
gather_facts: false
6+
no_log: "{{ molecule_no_log }}"
7+
tasks:
8+
- name: Create molecule instance(s)
9+
vagrant:
10+
instance_name: "{{ item.name }}"
11+
instance_interfaces: "{{ item.interfaces | default(omit) }}"
12+
instance_raw_config_args: "{{ item.instance_raw_config_args | default(omit) }}"
13+
14+
config_options: "{{ item.config_options | default(omit) }}"
15+
16+
platform_box: "{{ item.box | default('generic/alpine310') }}"
17+
platform_box_version: "{{ item.box_version | default(omit) }}"
18+
platform_box_url: "{{ item.box_url | default(omit) }}"
19+
20+
provider_name: "{{ molecule_yml.driver.provider.name }}"
21+
provider_memory: "{{ item.memory | default(omit) }}"
22+
provider_cpus: "{{ item.cpus | default(omit) }}"
23+
provider_options: "{{ item.provider_options | default(omit) }}"
24+
provider_raw_config_args: "{{ item.provider_raw_config_args | default(omit) }}"
25+
provider_override_args: "{{ item.provider_override_args | default(omit) }}"
26+
27+
provision: "{{ item.provision | default(omit) }}"
28+
29+
state: up
30+
register: server
31+
with_items: "{{ molecule_yml.platforms }}"
32+
loop_control:
33+
label: "{{ item.name }}"
34+
no_log: false
35+
36+
# NOTE(retr0h): Vagrant/VBox sucks and parallelizing instance creation
37+
# causes issues.
38+
39+
# Mandatory configuration for Molecule to function.
40+
41+
- when: server.changed | bool
42+
block:
43+
44+
- name: Populate instance config dict
45+
set_fact:
46+
instance_conf_dict: {
47+
'instance': "{{ item.Host }}",
48+
'address': "{{ item.HostName }}",
49+
'user': "{{ item.User }}",
50+
'port': "{{ item.Port }}",
51+
'identity_file': "{{ item.IdentityFile }}", }
52+
with_items: "{{ server.results }}"
53+
register: instance_config_dict
54+
55+
- name: Convert instance config dict to a list
56+
set_fact:
57+
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"
58+
59+
- name: Dump instance config
60+
copy:
61+
content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}"
62+
dest: "{{ molecule_instance_config }}"
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
- name: Destroy
3+
hosts: localhost
4+
connection: local
5+
gather_facts: false
6+
no_log: "{{ molecule_no_log }}"
7+
tasks:
8+
- name: Destroy molecule instance(s)
9+
vagrant:
10+
instance_name: "{{ item.name }}"
11+
platform_box: "{{ item.box | default(omit) }}"
12+
provider_name: "{{ molecule_yml.driver.provider.name }}"
13+
provider_options: "{{ item.provider_options | default(omit) }}"
14+
provider_raw_config_args: "{{ item.provider_raw_config_args | default(omit) }}"
15+
force_stop: "{{ item.force_stop | default(true) }}"
16+
17+
state: destroy
18+
register: server
19+
with_items: "{{ molecule_yml.platforms }}"
20+
loop_control:
21+
label: "{{ item.name }}"
22+
no_log: false
23+
24+
# NOTE(retr0h): Vagrant/VBox sucks and parallelizing instance deletion
25+
# causes issues.
26+
27+
# Mandatory configuration for Molecule to function.
28+
29+
- name: Populate instance config
30+
set_fact:
31+
instance_conf: {}
32+
33+
- name: Dump instance config # noqa 503
34+
copy:
35+
content: "{{ instance_conf | to_json | from_json | molecule_to_yaml | molecule_header }}"
36+
dest: "{{ molecule_instance_config }}"
37+
when: server.changed | bool
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
- name: Prepare
3+
hosts: all
4+
gather_facts: false
5+
tasks:
6+
- name: Bootstrap python for Ansible
7+
raw: |
8+
command -v python3 python || (
9+
command -v apk >/dev/null && sudo apk add --no-progress --update python3 ||
10+
(test -e /usr/bin/dnf && sudo dnf install -y python3) ||
11+
(test -e /usr/bin/apt && (apt -y update && apt install -y python-minimal)) ||
12+
echo "Warning: Python not boostrapped due to unknown platform."
13+
)
14+
become: true
15+
changed_when: false

‎molecule_vagrant/test/functional/.ansible-lint

-9
This file was deleted.

‎molecule_vagrant/test/functional/test_azure.py ‎molecule_vagrant/test/functional/test_func.py

+6-12
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,27 @@
2525

2626
from molecule import logger
2727
from molecule.test.conftest import run_command, change_dir_to
28-
from molecule.test.functional.conftest import metadata_lint_update
2928

3029
# import change_dir_to, temp_dir
3130

3231
LOG = logger.get_logger(__name__)
3332

3433

35-
@pytest.mark.xfail(reason="need to fix template path")
34+
# @pytest.mark.xfail(reason="need to fix template path")
3635
def test_command_init_scenario(temp_dir):
3736
role_directory = os.path.join(temp_dir.strpath, "test-init")
38-
options = {"role_name": "test-init"}
39-
cmd = sh.molecule.bake("init", "role", **options)
37+
options = {}
38+
cmd = sh.molecule.bake("init", "role", "test-init", **options)
4039
run_command(cmd)
41-
metadata_lint_update(role_directory)
4240

4341
with change_dir_to(role_directory):
4442
molecule_directory = pytest.helpers.molecule_directory()
4543
scenario_directory = os.path.join(molecule_directory, "test-scenario")
46-
options = {
47-
"scenario_name": "test-scenario",
48-
"role_name": "test-init",
49-
"driver-name": "vagrant",
50-
}
51-
cmd = sh.molecule.bake("init", "scenario", **options)
44+
options = {"role_name": "test-init", "driver-name": "vagrant"}
45+
cmd = sh.molecule.bake("init", "scenario", "test-scenario", **options)
5246
run_command(cmd)
5347

5448
assert os.path.isdir(scenario_directory)
5549

56-
cmd = sh.molecule.bake("test", "-s", "test-scenario")
50+
cmd = sh.molecule.bake("--debug", "test", "-s", "test-scenario")
5751
run_command(cmd)

‎molecule_vagrant/test/scenarios/driver/vagrant/molecule/default/molecule.yml

-40
This file was deleted.

‎molecule_vagrant/test/scenarios/driver/vagrant/molecule/default/playbook.yml

-7
This file was deleted.

‎molecule_vagrant/test/scenarios/driver/vagrant/molecule/default/tests/test_default.py

-40
This file was deleted.

‎molecule_vagrant/test/scenarios/driver/vagrant/molecule/multi-node/playbook.yml

-28
This file was deleted.

‎molecule_vagrant/test/scenarios/driver/vagrant/molecule/multi-node/tests/test_default.py

-38
This file was deleted.

‎molecule_vagrant/test/scenarios/driver/vagrant/molecule/multi-node/tests/test_instance-1.py

-35
This file was deleted.

‎molecule_vagrant/test/scenarios/driver/vagrant/molecule/multi-node/tests/test_instance-2.py

-35
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
- name: Converge
3+
hosts: all
4+
gather_facts: false
5+
become: true
6+
tasks:
7+
- name: sample task # noqa 305
8+
shell:
9+
cmd: uname
10+
warn: false
11+
changed_when: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
dependency:
3+
name: galaxy
4+
driver:
5+
name: vagrant
6+
provider:
7+
name: virtualbox
8+
platforms:
9+
- name: instance
10+
box: generic/alpine310
11+
provision: false
12+
provisioner:
13+
name: ansible
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
- name: Converge
3+
hosts: all
4+
gather_facts: false
5+
become: true
6+
tasks:
7+
- name: sample task # noqa 305
8+
shell:
9+
cmd: uname
10+
warn: false
11+
changed_when: false
12+
13+
- name: Converge
14+
hosts: bar
15+
gather_facts: false
16+
become: true
17+
tasks:
18+
- name: sample task # noqa 305
19+
shell:
20+
cmd: uname
21+
warn: false
22+
changed_when: false
23+
24+
- name: Converge
25+
hosts: foo
26+
gather_facts: false
27+
become: true
28+
tasks:
29+
- name: sample task # noqa 305
30+
shell:
31+
cmd: uname
32+
warn: false
33+
changed_when: false
34+
35+
- name: Converge
36+
hosts: baz
37+
gather_facts: false
38+
become: true
39+
tasks:
40+
- name: sample task # noqa 305
41+
shell:
42+
cmd: uname
43+
warn: false
44+
changed_when: false

‎molecule_vagrant/test/scenarios/driver/vagrant/molecule/multi-node/molecule.yml ‎molecule_vagrant/test/scenarios/molecule/multi-node/molecule.yml

-19
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ driver:
55
name: vagrant
66
provider:
77
name: virtualbox
8-
lint:
9-
name: yamllint
10-
options:
11-
config-file: ../../../resources/.yamllint
128
platforms:
139
- name: instance-1
1410
box: debian/jessie64
@@ -45,18 +41,3 @@ provisioner:
4541
config_options:
4642
defaults:
4743
callback_whitelist: profile_roles,profile_tasks,timer
48-
playbooks:
49-
create: ../../../../../resources/playbooks/vagrant/create.yml
50-
destroy: ../../../../../resources/playbooks/vagrant/destroy.yml
51-
env:
52-
ANSIBLE_ROLES_PATH: ../../../../../resources/roles/
53-
lint:
54-
name: ansible-lint
55-
scenario:
56-
name: multi-node
57-
verifier:
58-
name: testinfra
59-
options:
60-
sudo: true
61-
lint:
62-
name: flake8

‎pytest.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[pytest]
2-
addopts = -v -rxXs --doctest-modules --durations 10 --cov=molecule_vagrant --cov-report term-missing:skip-covered --cov-report xml
2+
addopts = -v -rxXs --doctest-modules --durations 10 --no-cov-on-fail --cov=molecule_vagrant --cov-report term-missing:skip-covered
33
doctest_optionflags = ALLOW_UNICODE ELLIPSIS
44
junit_suite_name = molecule_test_suite
55
norecursedirs = dist doc build .tox .eggs test/scenarios test/resources

‎setup.cfg

+11-8
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ universal = 1
66

77
[metadata]
88
name = molecule-vagrant
9-
url = https://github.com/pycontribs/molecule-vagrant
9+
url = https://github.com/ansible-community/molecule-vagrant
1010
project_urls =
11-
Bug Tracker = https://github.com/pycontribs/molecule-vagrant/issues
12-
Release Management = https://github.com/pycontribs/molecule-vagrant/projects
13-
CI: Travis = https://travis-ci.com/pycontribs/molecule-vagrant
14-
Source Code = https://github.com/pycontribs/molecule-vagrant
11+
Bug Tracker = https://github.com/ansible-community/molecule-vagrant/issues
12+
Release Management = https://github.com/ansible-community/molecule-vagrant/releases
13+
CI: Zuul = https://dashboard.zuul.ansible.com/t/ansible/builds?project=ansible-community/molecule-vagrant
14+
Source Code = https://github.com/ansible-community/molecule-vagrant
1515
description = Vagrant Molecule Plugin :: run molecule tests using Vagrant
1616
long_description = file: README.rst
1717
long_description_content_type = text/x-rst
@@ -63,24 +63,27 @@ setup_requires =
6363

6464
# These are required in actual runtime:
6565
install_requires =
66-
ansible
67-
molecule >= 3.0a3
66+
ansible >= 2.9.5
67+
molecule >= 3.0.2
6868
pyyaml >= 5.1, < 6
6969
python-vagrant
70+
selinux
7071

7172
[options.extras_require]
7273
test =
74+
ansi2html # soft-dependency of pytest-html
75+
coverage>=4.4, < 5 # drop '<5' when we drop py27 as we cannot mix them
7376
flake8>=3.6.0, < 4
7477

7578
mock>=3.0.5, < 4
7679
pytest>=4.6.3, < 5
7780
pytest-cov>=2.7.1, < 3
7881
pytest-helpers-namespace>=2019.1.8, < 2020
82+
pytest-html
7983
pytest-mock>=1.10.4, < 2
8084
pytest-verbose-parametrize>=1.7.0, < 2
8185
pytest-xdist>=1.29.0, < 2
8286
pytest-dependency
83-
shade>=1.31.0, < 2
8487

8588
[options.entry_points]
8689
molecule.driver =

‎tools/Vagrantfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Vagrant.configure("2") do |config|
2+
config.vm.box = "generic/alpine310"
3+
end

‎tools/test-setup.sh

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
# Used by Zuul CI to perform extra bootstrapping
4+
5+
# Platforms coverage:
6+
# Fedora 30 : has vagrant-libvirt no compilation needed
7+
# CentOS 7 : install upstream vagrant rpm and compiles plugin (broken runtime)
8+
# CentOS 8 : install upstream vagrant rpm and compiles plugin (broken runtime)
9+
10+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
11+
12+
# Bumping system tox because version from CentOS 7 is too old
13+
# We are not using pip --user due to few bugs in tox role which does not allow
14+
# us to override how is called. Once these are addressed we will switch back
15+
# non-sudo
16+
command -v python3 python
17+
18+
PYTHON=$(command -v python3 python|head -n1)
19+
PKG_CMD=$(command -v dnf yum|head -n1)
20+
21+
sudo $PYTHON -m pip install -U tox "zipp<0.6.0;python_version=='2.7'"
22+
23+
# === LIBVIRT SETUP ===
24+
# https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1588004
25+
sudo rm -f /etc/systemd/libvirtd.service /etc/systemd/system/multi-user.target.wants/libvirt-bin.service || true
26+
sudo systemctl enable --now libvirtd
27+
sudo usermod --append --groups libvirt "$(whoami)"
28+
29+
# === VAGRANT SETUP ===
30+
# Install Vagrant using their questionable practices, see locked ticket:
31+
# https://github.com/hashicorp/vagrant/issues/11070
32+
33+
which vagrant || \
34+
sudo $PKG_CMD install -y vagrant-libvirt || {
35+
sudo $PKG_CMD install -y https://releases.hashicorp.com/vagrant/2.2.7/vagrant_2.2.7_x86_64.rpm
36+
}
37+
38+
vagrant plugin list | grep vagrant-libvirt || {
39+
CONFIGURE_ARGS="with-libvirt-include=/usr/include/libvirt with-libvirt-lib=/usr/lib64" vagrant plugin install vagrant-libvirt
40+
}
41+
42+
rpm -qa | grep libselinux
43+
44+
vagrant version
45+
vagrant global-status
46+
47+
vagrant plugin list | tee >(grep -q "No plugins installed." && {
48+
echo "FATAL: Vagrant is not usable without any provider plugins."
49+
exit 1
50+
})
51+
52+
# Used to test that Vagrant is usable and also to pre-download the image
53+
# we will use during testing.
54+
cd $DIR
55+
56+
vagrant up --no-provision
57+
vagrant destroy -f

‎tox.ini

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# For more information about tox, see https://tox.readthedocs.io/en/latest/
22
[tox]
3-
minversion = 3.4.0
4-
envlist = lint,dist,py27,py35,py36,py37,py38,devel,distros
3+
minversion = 3.9.0
4+
envlist = lint,packaging,py27,py35,py36,py37,py38,devel,distros
55
skipsdist = True
66
skip_missing_interpreters = True
77
isolated_build = True
@@ -30,10 +30,14 @@ setenv =
3030
# This should pass these args to molecule, no effect here as this is the default
3131
# but it validates that it accepts extra params.
3232
MOLECULE_OPTS=--destroy always
33+
MOLECULE_NO_LOG="false"
34+
_EXTRAS=-l --html={envlogdir}/reports.html --self-contained-html
35+
PYTEST_ADDOPTS={env:_EXTRAS} {env:PYTEST_ADDOPTS:}
3336
passenv =
3437
CI
3538
CURL_CA_BUNDLE
3639
DOCKER_*
40+
HOME
3741
PYTEST_OPTIONS
3842
REQUESTS_CA_BUNDLE
3943
SSH_AUTH_SOCK
@@ -42,21 +46,22 @@ passenv =
4246
TRAVIS
4347
TRAVIS_*
4448
TWINE_*
49+
VAGRANT_HOME
4550
whitelist_externals =
4651
bash
4752
twine
4853
pytest
4954
pre-commit
5055

51-
[testenv:dist]
56+
[testenv:packaging]
5257
usedevelop = false
5358
skip_install = true
5459
deps =
5560
collective.checkdocs >= 0.2
5661
pep517 >= 0.5.0
5762
twine >= 2.0.0
5863
commands =
59-
bash -c "rm -rf {toxinidir}/dist/ && mkdir -p {toxinidir}/dist/"
64+
bash -c "rm -rf {toxinidir}/dist/ {toxinidir}/build/ && mkdir -p {toxinidir}/dist/"
6065
python -m pep517.build \
6166
--source \
6267
--binary \
@@ -71,7 +76,7 @@ commands =
7176
{[testenv]commands}
7277
deps =
7378
git+https://github.com/ansible/ansible.git#egg=ansible
74-
git+https://github.com/ansible/molecule#egg=molecule
79+
git+https://github.com/ansible-community/molecule#egg=molecule
7580

7681
[testenv:lint]
7782
description = Performs linting, style checks
@@ -85,7 +90,7 @@ commands =
8590
description = Builds the packages and uploads them to https://pypi.org
8691
envdir={toxworkdir}/dist
8792
deps=
88-
{[testenv:dist]deps}
93+
{[testenv:packaging]deps}
8994
commands =
90-
{[testenv:dist]commands}
95+
{[testenv:packaging]commands}
9196
twine upload --verbose dist/*

‎zuul.d/layout.yaml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
# zuul.d/layout.yaml
3+
- job:
4+
name: molecule-tox-devel-centos-8
5+
parent: molecule-tox-py36
6+
vars:
7+
tox_envlist: devel
8+
attempts: 1
9+
10+
- job:
11+
name: molecule-tox-py27-centos-7
12+
parent: molecule-tox-py27
13+
attempts: 1
14+
15+
- job:
16+
name: molecule-tox-py36-centos-8
17+
parent: molecule-tox-py36
18+
attempts: 1
19+
20+
- job:
21+
name: molecule-tox-py37-fedora-30
22+
parent: molecule-tox-py37
23+
attempts: 1
24+
25+
- project:
26+
templates:
27+
- publish-to-pypi
28+
check:
29+
jobs: &defaults
30+
- molecule-tox-linters:
31+
vars:
32+
tox_envlist: lint
33+
- molecule-tox-packaging:
34+
vars:
35+
tox_envlist: packaging
36+
- molecule-tox-py27-centos-7:
37+
# broken vagrant-libvirt install
38+
voting: false
39+
- molecule-tox-py36-centos-8:
40+
# broken vagrant-libvirt install
41+
voting: false
42+
- molecule-tox-py37-fedora-30
43+
- molecule-tox-devel-centos-8:
44+
# broken vagrant-libvirt install
45+
voting: false
46+
gate:
47+
jobs: *defaults

0 commit comments

Comments
 (0)
This repository has been archived.