1Configuration
2=============
3
4.. autoclass:: molecule.config.Config()
5   :undoc-members:
6
7.. _variable substitution:
8
9Variable Substitution
10---------------------
11
12.. autoclass:: molecule.interpolation.Interpolator()
13   :undoc-members:
14
15.. _dependency:
16
17Dependency
18----------
19
20Testing roles may rely upon additional dependencies.  Molecule handles managing
21these dependencies by invoking configurable dependency managers.
22
23Ansible Galaxy
24^^^^^^^^^^^^^^
25
26.. autoclass:: molecule.dependency.ansible_galaxy.AnsibleGalaxy()
27   :undoc-members:
28
29Gilt
30^^^^
31
32.. autoclass:: molecule.dependency.gilt.Gilt()
33   :undoc-members:
34
35Shell
36^^^^^
37
38.. autoclass:: molecule.dependency.shell.Shell()
39   :undoc-members:
40
41.. _driver:
42
43Driver
44------
45
46Molecule uses `Ansible`_ to manage instances to operate on.  Molecule supports
47any provider `Ansible`_ supports.  This work is offloaded to the `provisioner`.
48
49The driver's name is specified in `molecule.yml`, and can be overriden on the
50command line.  Molecule will remember the last successful driver used, and
51
52continue to use the driver for all subsequent subcommands, or until the
53instances are destroyed by Molecule.
54
55.. important::
56
57    The verifier must support the Ansible provider for proper Molecule
58    integration.
59
60    The driver's python package requires installation.
61
62.. _`Ansible`: https://docs.ansible.com
63
64
65.. _azure-driver:
66
67Azure
68^^^^^
69
70.. autoclass:: molecule.driver.azure.Azure()
71   :undoc-members:
72
73Delegated
74^^^^^^^^^
75
76.. autoclass:: molecule.driver.delegated.Delegated()
77   :undoc-members:
78
79
80DigitalOcean
81^^^^^^^^^^^^
82
83.. autoclass:: molecule.driver.digitalocean.DigitalOcean()
84   :undoc-members:
85
86
87Docker
88^^^^^^
89
90.. autoclass:: molecule.driver.docker.Docker()
91   :undoc-members:
92
93.. _ec2-driver:
94
95EC2
96^^^
97
98.. autoclass:: molecule.driver.ec2.EC2()
99   :undoc-members:
100
101.. _gce-driver:
102
103GCE
104^^^
105
106.. autoclass:: molecule.driver.gce.GCE()
107   :undoc-members:
108
109.. _hetzner-cloud-driver:
110
111Hetzner Cloud
112^^^^^^^^^^^^^
113
114.. autoclass:: molecule.driver.hetznercloud.HetznerCloud()
115   :undoc-members:
116
117.. _linode-driver:
118
119Linode
120^^^^^^
121
122.. autoclass:: molecule.driver.linode.Linode()
123   :undoc-members:
124
125LXC
126^^^
127
128.. autoclass:: molecule.driver.lxc.LXC()
129   :undoc-members:
130
131LXD
132^^^
133
134.. autoclass:: molecule.driver.lxd.LXD()
135   :undoc-members:
136
137Openstack
138^^^^^^^^^
139
140.. autoclass:: molecule.driver.openstack.Openstack()
141   :undoc-members:
142
143Podman
144^^^^^^
145
146.. autoclass:: molecule.driver.podman.Podman()
147    :undoc-members:
148
149Vagrant
150^^^^^^^
151
152.. autoclass:: molecule.driver.vagrant.Vagrant()
153   :undoc-members:
154
155.. _molecule_vagrant_module:
156
157Molecule Vagrant Module
158^^^^^^^^^^^^^^^^^^^^^^^
159
160Molecule manages Vagrant via an internal Ansible module.  The following belongs
161in the appropriate create or destroy playbooks, and uses the default provider.
162
163Supported Providers:
164
165* VirtualBox (default)
166* VMware (vmware_fusion, vmware_workstation and vmware_desktop)
167* Parallels
168* Libvirt (requires vagrant-libvirt plugin)
169
170Create instances.
171
172.. code-block:: yaml
173
174    - hosts: localhost
175      connection: local
176      tasks:
177        - name: Create instances
178          molecule_vagrant:
179            instance_name: "{{ item }}"
180            platform_box: ubuntu/trusty64
181            state: up
182          with_items:
183            - instance-1
184            - instance-2
185
186Destroy instances.
187
188.. code-block:: yaml
189
190    - hosts: localhost
191      connection: local
192      tasks:
193        - name: Destroy instances
194          molecule_vagrant:
195            instance_name: "{{ item }}"
196            platform_box: ubuntu/trusty64
197            state: destroy
198          with_items:
199            - instance-1
200            - instance-2
201
202Halt instances (shutdown without destroy).
203
204.. code-block:: yaml
205
206    - hosts: localhost
207      connection: local
208      tasks:
209        - name: Halt instances
210          molecule_vagrant:
211            instance_name: "{{ item }}"
212            platform_box: ubuntu/trusty64
213            state: halt
214          with_items:
215            - instance-1
216            - instance-2
217
218Create instances with interfaces.
219
220.. code-block:: yaml
221
222    - hosts: localhost
223      connection: local
224      tasks:
225        - name: Create instance with interfaces
226          molecule_vagrant:
227            instance_name: instance-1
228            instance_interfaces:
229              - auto_config: true
230                network_name: private_network
231                type: dhcp
232              - auto_config: false
233                network_name: private_network
234                type: dhcp
235              - auto_config: true
236                ip: 192.168.11.3
237                network_name: private_network
238                type: static
239            platform_box: ubuntu/trusty64
240            state: up
241
242Create instances with additional provider options.
243
244.. code-block:: yaml
245
246    - hosts: localhost
247      connection: local
248      tasks:
249        - name: Create instances
250          molecule_vagrant:
251            instance_name: "{{ item }}"
252            platform_box: ubuntu/trusty64
253            provider_name: virtualbox
254            provider_memory: 1024
255            provider_cpus: 4
256            provider_raw_config_args:
257              - "customize ['modifyvm', :id, '--cpuexecutioncap', '50']"
258            provider_options:
259              gui: true
260            provision: true
261            state: up
262          with_items:
263            - instance-1
264            - instance-2
265
266Create instances with additional instance options.
267
268.. code-block:: yaml
269
270    - hosts: localhost
271      connection: local
272      tasks:
273        - name: Create instances
274          molecule_vagrant:
275            instance_name: "{{ item }}"
276            platform_box: ubuntu/trusty64
277            instance_raw_config_args:
278              - "vm.network 'forwarded_port', guest: 80, host: 8080"
279            state: up
280          with_items:
281            - instance-1
282            - instance-2
283
284Create instances on a remote Libvirt node using default create/destroy
285templates.
286
287.. code-block:: yaml
288
289    - hosts: localhost
290      connection: local
291      tasks:
292        - name: Create instances
293          molecule_vagrant:
294            instance_name: "{{ item }}"
295            platform_box: ubuntu/trusty64
296            provider_raw_config_args:
297              - 'host = "remote-node.example.com"'
298              - 'connect_via_ssh = "True"'
299              - 'username = "sshuser"'
300              - 'driver = "kvm"'
301              - 'cpu_mode = "host-passthrough"'
302            state: up
303          with_items:
304            - instance-1
305            - instance-2
306
307.. _linters:
308
309Lint
310----
311
312Molecule handles project linting by invoking configurable linters.
313
314Yaml Lint
315^^^^^^^^^
316
317.. autoclass:: molecule.lint.yamllint.Yamllint()
318   :undoc-members:
319
320.. _platforms:
321
322Platforms
323---------
324
325.. autoclass:: molecule.platforms.Platforms()
326   :undoc-members:
327
328.. _provisioner:
329
330Provisioner
331-----------
332
333Molecule handles provisioning and converging the role.
334
335Ansible
336^^^^^^^
337
338.. autoclass:: molecule.provisioner.ansible.Ansible()
339   :undoc-members:
340
341Lint
342....
343
344Molecule handles provisioner linting by invoking configurable linters.
345
346.. autoclass:: molecule.provisioner.lint.ansible_lint.AnsibleLint()
347   :undoc-members:
348
349.. _root_scenario:
350
351Scenario
352--------
353
354Molecule treats scenarios as a first-class citizens, with a top-level
355configuration syntax.
356
357.. autoclass:: molecule.scenario.Scenario()
358   :undoc-members:
359
360State
361-----
362
363An internal bookkeeping mechanism.
364
365.. autoclass:: molecule.state.State()
366  :undoc-members:
367
368.. _verifier:
369
370Verifier
371--------
372
373Molecule handles role testing by invoking configurable verifiers.
374
375Ansible
376^^^^^^^
377
378.. autoclass:: molecule.verifier.ansible.Ansible()
379   :undoc-members:
380
381Lint
382....
383
384.. autoclass:: molecule.verifier.lint.ansible_lint.AnsibleLint()
385   :undoc-members:
386
387Goss
388^^^^
389
390.. autoclass:: molecule.verifier.goss.Goss()
391   :undoc-members:
392
393Lint
394....
395
396The Goss verifier does not utilize a linter.
397
398Inspec
399^^^^^^
400
401.. autoclass:: molecule.verifier.inspec.Inspec()
402   :undoc-members:
403
404Lint
405....
406
407.. autoclass:: molecule.verifier.lint.rubocop.RuboCop()
408   :undoc-members:
409
410Testinfra
411^^^^^^^^^
412
413.. autoclass:: molecule.verifier.testinfra.Testinfra()
414   :undoc-members:
415
416.. _root_lint:
417
418Lint
419....
420
421.. autoclass:: molecule.verifier.lint.flake8.Flake8()
422   :undoc-members:
423
424.. autoclass:: molecule.verifier.lint.precommit.PreCommit()
425   :undoc-members:
426