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

Commit 78582f9

Browse files
committed
Reinstated Vagrant driver
- Added Zuul-CI config - Code to install vagrant - Made prepare playbook embedded - Made box optional (defaults to Alpine for size) - Added min-requirement molecule>=3.0.2 Related: hashicorp/vagrant#11070
1 parent 5e6d51b commit 78582f9

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.

0 commit comments

Comments
 (0)