Skip to content

Commit 7fe6acc

Browse files
authored
Adopt molecule-vagrant module (#67)
1 parent f82221f commit 7fe6acc

File tree

49 files changed

+2164
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2164
-1
lines changed

.ansible-lint

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ skip_list:
1010
- fqcn-builtins
1111
- yaml[line-length]
1212
- var-spacing
13+
14+
mock_modules:
15+
- vagrant # only until we publish community.vagrant collection

.github/workflows/tox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
runs-on: ubuntu-22.04
3535
needs: pre
3636
env:
37-
PYTEST_REQPASS: 5
37+
PYTEST_REQPASS: 6
3838
strategy:
3939
fail-fast: false
4040
matrix: ${{ fromJson(needs.pre.outputs.matrix) }}

bindep.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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-essential [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+
libguestfs-tools [platform:dpkg platform:rpm]
18+
libxml2-dev [platform:dpkg]
19+
libxslt-dev [platform:dpkg]
20+
make [platform:centos-7 platform:centos-8]
21+
pkg-config [platform:dpkg]
22+
python3 [test platform:dpkg platform:rpm !platform:centos-7]
23+
python3-devel [test platform:rpm !platform:centos-7]
24+
python3-dev [test platform:dpkg]
25+
python3-libselinux [test platform:rpm !platform:centos-7]
26+
python3-libvirt [test platform:rpm !platform:centos-7 platform:dpkg]
27+
python3-netifaces [test !platform:centos-7 platform:rpm]
28+
python36 [test !platform:dpkg !platform:centos-7 !platform:fedora-28]
29+
qemu-system [platform:dpkg]
30+
qemu-utils [platform:dpkg]
31+
qemu-kvm [platform:rpm]
32+
ruby-dev [platform:dpkg]
33+
ruby-devel [!platform:centos-7 !platform:centos-8 platform:rpm]
34+
ruby-libvirt [platform:dpkg]
35+
vagrant [platform:dpkg]
36+
zlib1g-dev [platform:dpkg]

doc/vagrant/README.rst

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
***********************
2+
Molecule Vagrant Plugin
3+
***********************
4+
5+
.. image:: https://badge.fury.io/py/molecule-vagrant.svg
6+
:target: https://badge.fury.io/py/molecule-vagrant
7+
:alt: PyPI Package
8+
9+
.. image:: https://zuul-ci.org/gated.svg
10+
:target: https://dashboard.zuul.ansible.com/t/ansible/builds?project=ansible-community/molecule-vagrant
11+
12+
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
13+
:target: https://github.com/python/black
14+
:alt: Python Black Code Style
15+
16+
.. image:: https://img.shields.io/badge/Code%20of%20Conduct-silver.svg
17+
:target: https://docs.ansible.com/ansible/latest/community/code_of_conduct.html
18+
:alt: Ansible Code of Conduct
19+
20+
.. image:: https://img.shields.io/badge/Mailing%20lists-silver.svg
21+
:target: https://docs.ansible.com/ansible/latest/community/communication.html#mailing-list-information
22+
:alt: Ansible mailing lists
23+
24+
.. image:: https://img.shields.io/badge/license-MIT-brightgreen.svg
25+
:target: LICENSE
26+
:alt: Repository License
27+
28+
Molecule Vagrant is designed to allow use of Vagrant for provisioning of test
29+
resources.
30+
31+
Supported Platforms
32+
===================
33+
34+
This driver relies on vagrant command line which is known to be problematic
35+
to install on several platforms. We do our best to perform CI/CD testing on
36+
multiple platforms but some are disabled due to known bugs.
37+
38+
* ✅ MacOS with VirtualBox - GitHub Actions
39+
* ✅ Fedora 32 with libvirt - Zuul
40+
* ✅ Ubuntu Bionic (18.04) with libvirt - Zuul
41+
* ❌ CentOS 8 with libvirt - Zuul DISABLED due to 1127_ and 11020_
42+
43+
Please **do not file bugs for unsupported platforms**. You are welcomed to
44+
create PRs that fix untested platform, as long they do not break existing ones.
45+
46+
.. _`1127`: https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1127
47+
.. _`11020`: https://github.com/hashicorp/vagrant/issues/11020
48+
49+
50+
Documentation
51+
=============
52+
53+
To use this plugin, you'll need to set the ``driver`` and ``platform``
54+
variables in your ``molecule.yml``. Here's a simple example using the
55+
`fedora/32-cloud-base`_ box:
56+
57+
.. code-block:: yaml
58+
59+
driver:
60+
name: vagrant
61+
62+
platforms:
63+
- name: instance
64+
box: fedora/32-cloud-base
65+
memory: 512
66+
cpus: 1
67+
68+
Here's a full example with the libvirt provider:
69+
70+
.. code-block:: yaml
71+
72+
driver:
73+
name: vagrant
74+
provider:
75+
# Can be any supported provider (virtualbox, parallels, libvirt, etc)
76+
# Defaults to virtualbox
77+
name: libvirt
78+
# Run vagrant up with --provision.
79+
# Defaults to --no-provision)
80+
provision: no
81+
# vagrant-cachier configuration
82+
# Defaults to 'machine'
83+
# Any value different from 'machine' or 'box' will disable it
84+
cachier: machine
85+
# If set to false, set VAGRANT_NO_PARALLEL to '1'
86+
# Defaults to true
87+
parallel: true
88+
# vagrant box to use by default
89+
# Defaults to 'generic/alpine316'
90+
default_box: 'generic/alpine316'
91+
92+
platforms:
93+
- name: instance
94+
# If specified, set host name to hostname, unless it's set to False and
95+
# the host name won't be set. In all other cases (including default) use
96+
# 'name' as host name.
97+
hostname: foo.bar.com
98+
# List of dictionaries mapped to `config.vm.network`
99+
interfaces:
100+
# `network_name` is the required identifier, all other keys map to
101+
# arguments.
102+
- auto_config: true
103+
network_name: private_network
104+
type: dhcp
105+
- network_name: private_network
106+
ip: 192.168.123.3
107+
- network_name: forwarded_port
108+
guest: 80
109+
host: 8080
110+
# List of raw Vagrant `config` options
111+
instance_raw_config_args:
112+
# use single quotes to avoid YAML parsing as dict due to ':'
113+
- 'vm.synced_folder ".", "/vagrant", type: "rsync"'
114+
# Run 'uname' a provisionning step **needs 'provision: true' to work**
115+
- 'vm.provision :shell, inline: "uname"'
116+
# Dictionary of `config` options. Note that string values need to be
117+
# explicitly enclosed in quotes.
118+
config_options:
119+
ssh.keep_alive: yes
120+
ssh.remote_user: 'vagrant'
121+
synced_folder: true
122+
box: fedora/32-cloud-base
123+
box_version: 32.20200422.0
124+
box_url:
125+
memory: 512
126+
cpus: 1
127+
# Dictionary of options passed to the provider
128+
provider_options:
129+
video_type: 'vga'
130+
# List of raw provider options
131+
provider_raw_config_args:
132+
- cpuset = '1-4,^3,6'
133+
134+
.. _`fedora/32-cloud-base`: https://app.vagrantup.com/fedora/boxes/32-cloud-base
135+
136+
137+
More examples may be found in the ``molecule`` `scenarios directory`_.
138+
They're the scenarios used by the CI.
139+
140+
141+
.. _get-involved:
142+
143+
Get Involved
144+
============
145+
146+
* Join us in the ``#ansible-devtools`` channel on `Libera`_.
147+
* Join the discussion in `molecule-users Forum`_.
148+
* Join the community working group by checking the `wiki`_.
149+
* Want to know about releases, subscribe to `ansible-announce list`_.
150+
* For the full list of Ansible email Lists, IRC channels see the
151+
`communication page`_.
152+
153+
.. _`Libera`: https://web.libera.chat/?channel=#ansible-devtools
154+
.. _`molecule-users Forum`: https://groups.google.com/forum/#!forum/molecule-users
155+
.. _`wiki`: https://github.com/ansible/community/wiki/Molecule
156+
.. _`ansible-announce list`: https://groups.google.com/group/ansible-announce
157+
.. _`communication page`: https://docs.ansible.com/ansible/latest/community/communication.html
158+
.. _`scenarios directory`: https://github.com/ansible-community/molecule-vagrant/tree/main/molecule_vagrant/test/scenarios/molecule
159+
.. _authors:
160+
161+
Authors
162+
=======
163+
164+
Molecule Vagrant Plugin was created by Sorin Sbarnea based on code from
165+
Molecule.
166+
167+
.. _license:
168+
169+
License
170+
=======
171+
172+
The `MIT`_ License.
173+
174+
.. _`MIT`: https://github.com/ansible-community/molecule-vagrant/blob/main/LICENSE
175+
176+
The logo is licensed under the `Creative Commons NoDerivatives 4.0 License`_.
177+
178+
If you have some other use in mind, contact us.
179+
180+
.. _`Creative Commons NoDerivatives 4.0 License`: https://creativecommons.org/licenses/by-nd/4.0/

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ azure = "molecule_plugins.azure.driver:Azure"
7474
docker = "molecule_plugins.docker.driver:Docker"
7575
ec2 = "molecule_plugins.ec2.driver:EC2"
7676
gce = "molecule_plugins.gce.driver:GCE"
77+
vagrant = "molecule_plugins.vagrant.driver:Vagrant"
7778

7879
[tool.setuptools_scm]
7980
local_scheme = "no-local-version"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""Plugin exports."""
2+
3+
__name__ = __name__.split("_")[-1]
Lines changed: 5 additions & 0 deletions
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+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
*********************************
2+
Vagrant driver installation guide
3+
*********************************
4+
5+
Requirements
6+
============
7+
8+
* Vagrant
9+
* Virtualbox, Parallels, VMware Fusion, VMware Workstation or VMware Desktop
10+
11+
Install
12+
=======
13+
14+
Please refer to the `Virtual environment`_ documentation for installation best
15+
practices. If not using a virtual environment, please consider passing the
16+
widely recommended `'--user' flag`_ when invoking ``pip``.
17+
18+
.. _Virtual environment: https://virtualenv.pypa.io/en/latest/
19+
.. _'--user' flag: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
20+
21+
.. code-block:: bash
22+
23+
$ pip install 'molecule-plugins[vagrant]'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: Converge
3+
hosts: all
4+
tasks:
5+
- name: "Include {{ cookiecutter.role_name }}"
6+
ansible.builtin.include_role:
7+
name: "{{ cookiecutter.role_name }}"

0 commit comments

Comments
 (0)