Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for Review Molecule v2 #817

Closed
retr0h opened this issue Apr 27, 2017 · 75 comments
Closed

Request for Review Molecule v2 #817

retr0h opened this issue Apr 27, 2017 · 75 comments

Comments

@retr0h
Copy link
Contributor

retr0h commented Apr 27, 2017

Molecule v2 is a huge rewrite and change. I am requesting review and feedback.

Important changes

  • Addition of Scenarios.
  • Uses Ansible to manage instances vs handling internally.

Breaking changes

  • Not compatible with Molecule v1 style config syntax.
  • Does not support all of the Molecule v1 functionality or flexibility, in favor of simplicity, and consistency throughout.

Caveats

  • Name change from molecule to ansible-test, which isn't getting very far.
  • Alternative name changes ansible-tests, test-ansible...

Feedback

Please provide feedback so we can better understand how you use Molecule. As an example, we currently do not support Serverspec in v2, your feedback is helpful.

@retr0h retr0h changed the title Preparing for Molecule v2 Request for Review of v2 Apr 29, 2017
@retr0h retr0h changed the title Request for Review of v2 Request for Review Molecule v2 Apr 29, 2017
@kireledan
Copy link
Contributor

I'll try and take a look at this tonight.

@conorsch
Copy link
Contributor

conorsch commented May 1, 2017

Thanks for posting this publicly, @retr0h! Happy to take a look at what you've been cooking up.

@mrtg
Copy link

mrtg commented May 2, 2017

I don't know if I get the idea behind scenarios. Is this a concept for testing a role under different conditions e.g. a single node setup or a clustered setup of a database running on n nodes? I'd love to see that 👍.

Was the serverspec support removed on purpose or will it come back?

Another name suggestion: testible (testable + ansible)

@retr0h
Copy link
Contributor Author

retr0h commented May 3, 2017

I don't know if I get the idea behind scenarios. Is this a concept for testing a role under different conditions e.g. a single node setup or a clustered setup of a database running on n nodes? I'd love to see that 👍.

Yeah, exactly...

Was the serverspec support removed on purpose or will it come back?

It was originally removed to keep scope down. We probably could and possibly should add it back. I'm not entirely sure how many people use serverspec.

Another name suggestion: testible (testable + ansible)

👍

@gzm55
Copy link
Contributor

gzm55 commented May 3, 2017

Name change from molecule to ansible-test, which isn't getting very far.

Are we collecting new names for molecule v2? Is it possible ansible imports molecule as a core part and shipped together, namely ansible-test (just like ansible-galaxy is shipped with ansible)?

Ansible community has a pure-ansible style test stratedgy, may be we should convince them molecule is a more powerful and modern test framework for ansible developing roles and playbooks, and connects ansible community and IaC tendency.

@retr0h
Copy link
Contributor Author

retr0h commented May 3, 2017

Ansible community has a pure-ansible style test stratedgy, may be we should convince them molecule is a more powerful and modern test framework for ansible developing roles and playbooks, and connects ansible community and IaC tendency.

I am open to it, but haven't had much success. Honestly, I have spent over a year trying to get many PRs into Ansible. I'm not really interested in trying to teach them why Molecule is better ;)

@gzm55
Copy link
Contributor

gzm55 commented May 4, 2017

I am open to it, but haven't had much success. Honestly, I have spent over a year trying to get many PRs into Ansible. I'm not really interested in trying to teach them why Molecule is better ;)

seems that Redhat is not very willing to collaborate with community, but prefers selling his Tower service.

@MarkusTeufelberger
Copy link
Contributor

As far as I understand it, molevule v2 still operates on the "role" level, right? Meaning one role, one molecule.yml etc.

If I want to test multiple roles in interaction (e.g. a VPN server and a VPN client role or several web servers + a load balancer in front) I might need some extra work to create a scenario? Maybe this could be a good example for the documentation.

@aroundthecode
Copy link

hi @MarkusTeufelberger
I succesfully tested several role at once initializing molecule at the same level of the roles folder instead inside a specific role and setting the roles path via environment variable before invoking molecule test.

@retr0h
Copy link
Contributor Author

retr0h commented May 6, 2017

Maybe this could be a good example for the documentation.

This is documented through our tests. I updated the documentation pointing people to this location.

1ca1a71

@retr0h
Copy link
Contributor Author

retr0h commented May 23, 2017

Release candidate 2 is now available on pypi.

pip install molecule --pre

@arkag
Copy link

arkag commented May 23, 2017

Seems like molecules inventory files aren't working.

root@molecule-dev:~/ansible-playbooks/roles/servers/wiki# molecule init scenario --role-name wiki --scenario-name default
--> Initializing new scenario default...
Initialized scenario in /root/ansible-playbooks/roles/servers/wiki/molecule/default successfully.
root@molecule-dev:~/ansible-playbooks/roles/servers/wiki# molecult test
molecult: command not found
root@molecule-dev:~/ansible-playbooks/roles/servers/wiki# molecule test
--> Scenario: [default]
--> Provisioner: [ansible]
--> Playbook: [destroy.yml]
ERROR! ERROR! /root/ansible-playbooks/roles/servers/wiki/molecule/default/.molecule/ansible_inventory.yml:6: Expected key=value host variable assignment, got: &id001

Installed via pip.

Unrelated: does this project have an IRC or something similar for support?

@retr0h
Copy link
Contributor Author

retr0h commented May 24, 2017

Seems like molecules inventory files aren't working.

@cwre you're version of ansible isn't supported. Only supports 2.2 and 2.3. See changelog.

@retr0h
Copy link
Contributor Author

retr0h commented May 24, 2017

Unrelated: does this project have an IRC or something similar for support?

There are people there, but your mileage may vary :) Check out the docs, there is good stuff in there.

@arkag
Copy link

arkag commented May 24, 2017

There are people there, but your mileage may vary :) Check out the docs, there is good stuff in there.

I've tried joining #molecule on Freenode, but it's invite only.

@arkag
Copy link

arkag commented May 24, 2017

@retr0h My apologies... I installed via apt on accident. Thanks for the patience!

@retr0h
Copy link
Contributor Author

retr0h commented May 24, 2017

I've tried joining #molecule on Freenode, but it's invite only.

#molecule-users

@retr0h
Copy link
Contributor Author

retr0h commented May 29, 2017

Will be promoting v2 branch to master on June 5th, unless a major issue is found. However, Molecule v1 will remain the default version on pypi. For those of you building off master, this is an important detail.

@MarkusTeufelberger
Copy link
Contributor

The Vagrant driver is quite light on documentation, it would be nice to know for example how to set the back-end Vagrant will actually use (VirtualBox etc) and how to manage some settings there (e.g. increase RAM to 1024 MiB).

I know that other drivers could be nicer to use (since they could be managed by Ansible itself), however in one of my use cases for example I'm trying to test a role that starts and provisions LXD containers and I much prefer to have this stuff just run in a full virtual machine to avoid potentially complex setup requirements on the machine running molecule.

@retr0h
Copy link
Contributor Author

retr0h commented Jun 10, 2017

The Vagrant driver is quite light on documentation, it would be nice to know for example how to set the back-end Vagrant will actually use (VirtualBox etc) and how to manage some settings there (e.g. increase RAM to 1024 MiB).

Added the examples to sphinx.

@butla
Copy link

butla commented Jun 11, 2017

@retr0h Is this "Molecule Vagrant Module" snippet from Sphinx just the duplicated (or alternative?) contents of create.yml and destroy.yml scenario files? If I'm using a different provider this "molecule_vagrant" stuff is ommited?

A few comments in the yml files or under the "Molecule Vagrant Module" in the docs would help to clear out my confusion.

@retr0h
Copy link
Contributor Author

retr0h commented Jun 11, 2017

@retr0h Is this "Molecule Vagrant Module" snippet from Sphinx just the duplicated (or alternative?) contents of create.yml and destroy.yml scenario files? If I'm using a different provider this "molecule_vagrant" stuff is ommited?

@butla The Sphinx docs for the vagrant driver is the example section of the ansible module.

I added more examples, which should be what you're looking for.

retr0h added a commit that referenced this issue Jun 12, 2017
* Init add of molecule v2 work

Initial work of a v2 based Molecule.  This version of Molecule
has a slightly different config, uses Ansible to boostrap the
container vs relying on Molecule glue drivers, and only supports
Docker at this time.

Implemented the following subcommands.

1. Create
2. Converge
3. Destroy
4. Verify
5. Lint

Will no longer squash into this commit, and will build ontop.

* Various fixups on way to MVP

* Reworked provider class to handle converge.
* Hid the use of AnsiblePlaybook inside the provisioner.
* Passing of os.environ to sh bake calls.
* Continue to cleanup tests.

* Improved coverage

* Added unit tests for docker driver.
* 100% ansible.py provisioner.
* 100% testinfra.py verifier.

* Added multi-node scenario

The platform name is now appended with the scenario name.

* Added basic functional testing framework

Added very basic functional testing from v1 molecule.

* Added init and enabled lint subcommand

Added a basic init subcommand and enabled the existing lint command.

* Moved config properties into respective base

Config didn't need properties for everything, since base has
properties for each top level class.  Moved the properties
into their respective class.

* Added test and converge sequences

* Only test with ansible 2.2

* Many cleanups

* Cleaned up tox.ini.
* Added a dependency sub command.
* Added gilt dependency manager.
* Removed crazy parametrized test config handling.

* Init cleanups

* Removed duplicate _process_templates calls.
* Updated docstring to match rest of project.

* Added doc strings where necessary

Did not document methods which are obvious.

* Added usage/configuration through doc strings

As part of documenting ansible-lint, implemented proper exclude
options handling.

* syntax and test tweaks (#675)

* [v2] move cookiecutter back to molecule directory (#678)

- also skip guilt tests verifying bake params, since the param ordering is not deterministic

* Implemented scenario_name filtering sub commands (#681)

Sub commands will execute all scenarios, unless the `--scenario-name`
flag is passed.

Fixes: #680

* No merging of local config onto scenario config (#685)

It no longer makes sense to merge the local config onto the scenario
config since a scenario can be anything.  In an attempt to keep things
simple, removed this functionality.

Partial-Fix: #684

* Implemented duplicate scenario name validation (#686)

Since we can target a scenario based on name, we should not allow
duplicate scenarios to be created.

Fixes: #682

* Corrected a flake8 error

* Implemented yaml inventory file (#690)

Moved the generated host inventory from the proprietary "ini" format to
Ansible's new yaml format.

Fixes: #683

* Moved vivify under provisioner class

Until we need it elsewhere lets keep it private and inside the
class.

* Add idempotence sub command (#691)

Fixes: #677

* Bumped license year (#692)

* Corrected a few rogue double quotes

* Added state module from v1

Ported over v1's state module.

* Bind a state instance onto each config instance

* Add state management to destroy, create, converge

The destroy, create, and converge sub commands are logging their state
to the state file.  We will then make decisions off of that data later.

* Idempotence errors if not already converged (#698)

Idempotence should only be run when instances have already
been converged.

Fixes: #694

* Added idempotence to test sequence

* Run dependency managers only when config present (#699)

Molecule should automatically install dependencies, when the
requirements file is present.

Fixes: #695

* Added dependency to test sequence

* Added syntax sub command (#700)

Fixes: #697

* Implemented a check command (#701)

Fixes: #696

* Documented check and converge subcommands deps

* Added full quickstart output

* Corrected skipping testinfra tests

Tests were skipped due to bad inventory path.  Also, updated
cookiecutter `molecule init` template.

* Implemented status subcommand (#706)

* Better capsys variable naming

* Implemented status subcommand

Fixes: #703

* Implemented Molecule ansible plugin paths (#708)

Implemented a directory structure to hold ansible plugins for use with
ansible-playbook.  In this commit, added a filter plugin to construct
$instance_name-$scenario_name in playbooks.

* Use safe_dump and reuse existing helper methods

* Make ansible.cfg settings configurable

Ansible.cfg is written to disk from the provisioners config options.
File is entirely customizable.

* Added string interpolation to molecule.yml (#709)

Allows the embedding of environment variables inside molecule.yml.
Originally requested in #643.

Fixes: #707

* Corrected minor flake8 issue

* Corrected molecule error in dev env (#710)

When developing molecule, any molecule command will fail when executing
from the project root, since os_walk detects the cookiecutter templates
as a scenario.

Updated with an intelligent glob to find scenarios.

Fixes: #705

* Point to v2 docs on the v2 branch

* Added warning about pip install on v2

* Corrected flake8 errors

* Implemented a login subcommand (#711)

* Cleaned up interpolation coverage

When moving code over from Docker, there was uncovered code.
Deleted the code, since I don't see a valid reason we would
encounter the raise.

* Implemented a login subcommand

Ported v1 login to v2.

Fixes: #704

* Port molecule v1 host/group vars handling (#712)

Fixes: #693

* Updated provisioner's docs

Added a couple features which needed documented.  Bad me.

* Added basic Config module documentation

* Added sysexit_with_message

Added a method for exit and error message handling.

* Throw an error if config contains wrong names

Ensure we can only configure molecule with supported configurations.

* Added Children inventory creation

In implementing this feature broke out platforms into own class.
This keeps all top level config options as classes.

* Brought in State autodocs

* doco

* Corrected doc line length

* Status reports kitchen like output

* Renamed Status to List

* Added Ansible 2.2.1 as supported

* Corrected coverage

* Use state file to track status

* Slightly improved output

* Initial py36 support

* Officially support Ansible 2.2.1

With CVE-2016-9587[1] decided to only support versions of Ansible
which were fixed.  Not supporting 2.1.4.0 at the moment, since
it does not use the docker_container module.  Will likely expand
support once v2 is feature complete.

[1] https://www.computest.nl/advisories/CT-2017-0109_Ansible.txt
[2] https://lwn.net/Articles/711357/

* Better distribute role dependency documentation

* Improved Molecule output of components

* We should not skip important tests

Removed the marker and updated the tests slightly.

* Few small fixups with verbiage

* Prefix files managed by molecule with a header

* Prune the ephemeral directory before we begin

* Added dependency functional tests

Since we are no longer testing the explicit order of the dependency
unit tests.  A functional test should verify the subcommand is working
as expected.

* dependency molecule file cleanups

Did not need multiple-instances or groups for this test.

* Added verifier functional tests

Since we are no longer testing the explicit order of the verifier
unit tests.  A functional test should verify the subcommand is working
as expected.

* Fixed up driver and host_group_vars

* Nested docker functional tests under driver.
* Implemented child tests in host_group_vars.

* No longer manually add scenario name in host_vars

The user no longer needs to manually add the scenario_name to the
host_vars section of molecule.yml.

* Correctly Prune the ephemeral directory

We should prune before each subcommand.  Previously, Molecule was
pruning on Config init.

* Moved yaml loading to functions

* Entire config handling rework

Config does not handle merging dicts any longer.  We simply should
load the molecule file which the config object is passed.

As a side-effect the tests were reworked around config handling.  Was
never happy with the way I originally did it.

* Brought base coverage back to 100%

* Added interpolation functional test

* Nested functional tests under driver name

* Init add of vagrant module (#729)

This vagrant module is baked inside Molecule, since a native Vagrant module
does not exist.  It writes two files (`Vagrantfile` and `vagrant.yml`)
into the `molecule.config.ephemeral_directory`.  These files are used
by the module to provision the instances.

Fixes: #720

* Only run functional tests when binary found

Also, bumped YAPF version.

* Able to share playbooks between scenarios

The playbooks can now reference paths built by Molecule due to
molecule exporting these as inventory vars.  This enables playbook
sharing between roles.

* Backported #732 into v2

* Don't pass an empty list to sh.bake verifier

User would receive a warning when no tests were found.  Lets hide that
silly warning.

* Back out vagrant setup/destroy playbook sharing

Need to dig into this issue further.

* update testinfra backend for docker driver (#733)

* First pass at pylint linting

* Render Vagrantfile through jinja

* Updates to run on travis

* Added a travis file
* Share the Dockerfile between scenarios

* Ran yapf

* Corrected vagrant playbook sharing

* Provisioner Verifier Dependency Lint env variables

Molecule now accepts environment variables which are sent to the
provisioner, verifier, dependency, and lint modules.

* Updated vagrant templates to use ubuntu/xenial64

The files generated by `molecule init` should use newer linux.  Also,
as part of this found a use case where a instance may not have the
dependencies to initially run ansible.

* Backported verbose flag from #736

* [v2] allow tests to run on python35

- add python35 targets to travis and tox
- update tox to run linter for all python versions
- update tests that use asssert_called_once to test against call_count
  instead (assert_called_once is only supported for python < 3 and >= 3.6)
- update tox config to not fail if a target interpreter is missing

* Backported verbose flag from #736

* Check instance state on converge

Check if instance is already created when running converge.

* Additional py 3.5 compat fixes

* Small fix from rebase

* YAPF fix

* Updated tox to run linting with travis tox

* Removed unused fixture and doc string

* Switched to logger vs prints (#740)

Logging is a more pythonic approach.  The print methods feel somewhat
gross as this project has evolved.

* Corrected coverage

* [v2]Fix lint environments in tox (#738)

* Fix lint environments in tox

* Allow setting host_vars for localhost

- Do not append scenario name to hostname when setting host_vars in
  molecule.yml
- add test coverage for localhost host_vars

* Improve vagrant tests

Vagrant tests fail from time to time.  Especially when running the
entire `tox` suite.

* Moved the vagrant tests to debian/jesse.  The box is smaller, and
  boots faster than xenial.
* Updated vagrant module to clear the instance config on destroy.

* YAPF formatting

* Bumped vagrant driver coverage

* Initial LXC driver support

The Ansible LXC modules do not support unprivileged containers.  To
properly use this driver, one must prefix every molecule command with
`sudo`.

* Updated Ubuntu, CentOS, and Mac OS INSTALL.rst

* Correct LXC functional tests

All LXC functional tests now pass.

* Added information about the Vagrant driver

This information will be rendered into the configuration rst docs.

* Added docstrings to logger

* Moved install python for Ansible to converge pb

Previously the vagrant functional test was not testing the init
command via the vagrant driver.  We cannot perform additional tasks
at the setup phase, moved this to the converge phase.  See the
vagrant driver class docstring for further details.

All tox tests now pass.

* Updated raw trailing/leading newline

Made these cleanups on the vagrant driver, ported these over to lxc
and docker as well.

* Initial LXD driver support

    test/functional/lxd/test_command.py  ...............

* Working through LXC testing

* Found a few issues with incorrect install instructions.
* Xenial LXC passes all functional tests.
* Centos 7 LXC does not boot a container yet.

    15 passed in 886.90 seconds

* LXC CentOS passing functional tests

    15 passed in 1854.07 seconds

* No need sudo pip install in LXD Vagrant testing

This was copy-pasta from LXC configuration, since LXC tests currently
require sudo to work.  Need to figure out unpriv containers in ansible.

* Backported the Goss verifier into v2

Goss is now a first class and supported Molecule verifier.  This is
not the case in v1 Molecule.

* Cleanup Dockerfile template a bit (#747)

* SSoT around driver and verifier

Provide a single source of truth for the verifier and driver.
Managing this list by hand is unwanted.

* Added converged/created state to `molecule list`

* Provisioner cleanups

* Prefixed these methods with the provisioner's name.
* Removed inventory_file hard coding from testinfra.
* Backport of #749 to v2

* Backported #770 to Molecule v2

* Corrected doc builds

* Added Python 3, 3.5, and 3.6 to setup.cfg

* Backported #784 to v2

* Backported #787 to v2

* Backported #792 to v2

* Corrected silly way of handling default dict vars

* Backported #792 to v2 for Ans 2.3

* Backported #800 to v2

* Pinned requirements to newer versions

* Updated anyconfig to current

Anyconfig introduced quite a few breaking changes from 0.7.  Took
some time to port to current.

* Revert "Backported #787 to v2"

This reverts commit 035d024.

* Bumped version of testinfra

* No longer hard code testinfra with inventory path

Now referencing a variable which points to Molecule's ansible inventory.
Allows users to better organize their test files if they choose.

* Removed OSX specific cleanup shutil.rmtree

* Added 2.3 Ansible support to README

* Removed try/except around destroy in tests

Functional tests should not throw an exception when tearing down.
Lets make sure we don't mask this.

* Initial work of static driver

This driver allows one to supply externally managed instances to
molecule.  Molecule skips the create/destroy playbooks on this driver.
It is up to the user to properly configure ansible connect to these
systems.

It should be noted, one cannot connect externally to lxc, lxd, or docker
when using their respectively named `ansible_connection`.  The
containers would need to be running ssh for this to be possible.

`molecule test` runs successfully against local statically managed
docker instances.  Static Docker functional tests are passing as well.

* Add ssh connection support to static driver

The static ssh driver assumes the configuration will be
performed in a ssh config file, and passed to ansible via the
`ansible_ssh_extra_args` and `ansible_scp_extra_args` vars.

Fixes: #778

* Added testing documentation

* Backport of #821 to Molecule v2

* Cleaned up Testing and Contributing docs

* Added scenario examples to documentation per #817

* Added a env property to config class

A "global" env property will be used to pass global environment
variables to all sh sub calls.  This allows us to pass a consistent
set of env vars throughout Molecule.

* Print Molecule and Ansible environment on `--debug`

* Set StrictHostKeyChecking to no

Cleaned up drivers on how they deal with connection options.
The vagrant driver was not working due to a machine switch.
Also, cleaned up login_args to be clearer about use.

* Reduce duplication in functional tests

Still not perfect, need to rework static driver tests.

* Corrected usage in lint docstring

* Rename scenario to scenario_name in functional

* Scenario and Provisioner rework / driver on CLI

* Implemented passing driver on command line

Ability to pass a driver on the command line to certain subcommands.
Molecule will remember the last successful driver used, and continue
to use the driver for all subsequent subcommands, until the instances
are terminated.

* Reworked scenarios and provisioner playbook configuration

Scenarios should not have knowledge about the provisioners internals.
Therefore scenarios referencing playbooks needed reworking.  Moved
existing functionality into the provisioner before further refactoring.

* Support multi driver playbooks

A role can be shipped with multi driver provisioning (setup/teardown)
playbooks.  Pairs nicely with the CLI changes mentioned above.

* Yeah, OCD

* Pass additional molecule settings to the env

* Added a `--format` flag to `list`

Part of adding this flag was to address functional tests always
running destroy when not necessary.

* Corrected a docstring note to important

* Driver name rework and additional functional test

* Rework driver name handling

Made `driver.name` a setter which config sets once the driver
has been determined.  Provides consistent use throughout
Molecule vs needing to call a method to determine driver
name.

* Added a functional tests for multi-driver

Missed adding a functional test which uses the new
`config['provisioner']['playbooks'][$driver] dict.

* Add functional test logging

Ability to turn on stdout/err logging in functional tests, by passing
`-s` to pytest.

* Restored CHANGELOG from v1 series

* Corrected AUTHORS

Took this opportunity to correct core contributors.  These are
contributors who have submitted substantial code and influence
into the direction of Molecule.

* Ported CI documentation over from v1

* Updated CHANGELOG with v2 changes

As part of updating the changelog, added a porting guide, and corrected
a bug with scenario init discovered while creating the porting guide.
Corrected functional test to test for this condition.

* Corrected remaining non-wrapped molecule calls

* Added all group to generated inventory

Added a functional test to cover this situation.

* Added OpenStack driver

This commit is much larger than it should be.  I ended up touching
things I probably should not have touched.

This commit adds the OpenStack driver, and establishes a pattern others
can follow when adding new drivers.  Will use the lessons learned here
to rework the Vagrant driver.

* Converted vagrant driver to new pattern

Using the new driver pattern in playbooks, that was hashed
out while developing the OpenStack driver.

* Move tests to new testinfra host fixture

* Default scenario now default through CLI

The only subcommands which do not default the scenario
name are `test` and `list`.  All other default to the
default scenario.

* Added _NAME to a few of the molecule env vars

* Added molecule info to --help

* Huge functional test refactor

Finally able to understand parametrize.  Reworked tests to better
utilize this knowledge.  Reduces a ton of duplication.

* Added EC2 driver along with functional test fixes (#832)

* Added EC2 driver

Added the long awaited EC2 driver.  Because of the way EC2 works, needed
to perform playbook gymnastics in the setup/teardown playbooks.
Specifically, b/c instances cannot be created or deleted by name.  This
required instance_ids to be persisted for use later.

* Using `sh` magic flag parser.
* Corrected some broken assumptions in functional tests.
* Removed unnecessary duplicate testinfra tests.
* Reworked skip_test to skip static tests (for now).
* Removed (for now) static tests boostrap.

* Uncoment and fix a functional test

I made a booboo when testing the EC2 driver.  Missed a functional
test.  Will submit a follow-up pull request to relocate the
ssh-keypairs into an ephemeral directory wiped out after each
scenario run.

* Reloacted ssh_key into an ephemeral directory

Prevents potentially valid keys from laying around the filesystem.

* Better failure message when scenario not found

Previously we would error stating molecule.yml cannot be found,
when the scenario could not be found.

* Better error when molecule.yml isn't found

* Flake8 was running w/o molecule's environment

* Reworked scenario name

The scenario name cannot be configured through`molecule.yml`.
It is determined by the directory name of the scenario.  The
config value references a `MOLECULE_SCENARIO_NAME` environment
variable, which is correctly interpolated.  However, it provided
so that the config is symmetrical.  It may be removed in the future,
if the source of much confusion.

* Added provisioner docs about provisioner playbooks

* Added a FAW

* Added information on autocomplete

* Updated docs with --pre release install info

* Revert "Reworked scenario name"

This reverts commit 0c6a033.

* Correct spacing in a couple scenarios

* Rework scenario name part deux

The scenario name cannot be configured through `molecule.yml`.  It
is determined by the directory name of the scenario.  It provided
so that the config is symmetrical.  It may be removed in the future,
if this becomes a source of confusion.

* Correct role init usage

* Chomp trailing spaces consistently

* Updated dockerfile init file

Contains molecule v1 RUN commands.

* Ability to override the test directory

* Small cookiecutter molecule.yml cleanups

Trying to pass more data through molecule.yml instead of manually
defining in create.  Still some work to do around keypairs and
security groups.

* Namespaced molecule ansible plugins

* Fixes discovered from functional tests

* Add Ansible version check

* Ported v1's development doc

* Added cleanup task to development doc

* Standardized formatting of ci doc

* Pin pytest

Running into a bug with pytest 3.1.0 and pytest-verbose-parametrize.
Pinning for now.

* Pin new version of pbr

Was not compatible with newer Sphinx.

* Define ansible ssh common args

When running under tox the path is too long, which causes SSH failures.
Defaulted to a shorter path.

* Moved rdoc to base class

* Reuse os_walk in command.base.prune()

* Remove host/group vars before rewriting them

* Corrected scenario functional tests yet again

* Added base provisioner class

This is potentially setting molecule up for future Helm provisioner.

* Added dict_at_index filter plugin

Having ansible convert a dict to a list isn't trivial inside a playbook.
Much easier to do in python, so created a filter plugin.  This also
prevents the Docker create play from unnecessarily looping over each
platform.

> Most everything one hates with Ansible can be corrected with a filter
> plugin.

  - Said None

* Ability to init a role with cookiecutter template

Users may wish to supply their own Molecule templates.  Molecule
uses cookiecutter internally, it makes sense to simply use templates
provided by a cookiecutter repo.

* Added current galaxy init meta/main.yml

* Cleanup config module methods

* Bumped testinfra deps for @tknerr

* Ported v1 trailing whitespace linter to v2

This is not currently enabled.  Not sure how I would like to approach
this.

* Switch to utility open functions

* bumped for release of 1.25

(cherry picked from commit e2a43c5)

* Test vagrant interface is created

* Don't hard code platform_box in vagrant destroy.yml (#856)

* Missed a scenario in #856

* Bumped yapf

* Ran YAPF

* Resynced goss library

7b92738 brought in a bug.

* Brought in updated sh

This version of sh corrects a py3 issues we ran into.

* A few python 3.6 fixes

Still cannot run python 3 against Ansible, due to Ansible not seeming
to fully support py3.

* Forward port idempotence stdout on error

Fixes #835

* Added attribution to test case

* Additional py3 fix

Bug was introduced at a13d5a2.

* Moved vagrant module examples into sphinx

* docs: fixed initializing new scenario (#861)

* Moved vagrant module examples into sphinx

* Added additional Vagrant Molecule Module docs

Along with documenting the molecule vagrant module, corrected
a few bugs which were found.

* Preserve special ANSIBLE_ envs with their value

ANSIBLE_ like environment variables have higher precedence over their
equivalents inside ansible.cfg.  Thus, if the envs are set on CLI, the
roles_path, library and filter_plugins inside ansible.cfg are completely
ignored.

No longer set these inside ansible.cfg, and pass them as env vars
to the provisioner and ansible-lint.  This prevents one from providing
these on the command line, since molecule.yml provides a mechanism for
setting env vars.

Fixes: #845

* Lame attempt at unit/functional targeting

Not really fond of this approach -- feels anti-tox.

* Added v1 docs to the readme

This will help clarify usage once v2 is merged to master.
@retr0h
Copy link
Contributor Author

retr0h commented Jun 12, 2017

Will be promoting v2 branch to master on June 5th, unless a major issue is found. However, Molecule v1 will remain the default version on pypi. For those of you building off master, this is an important detail.
👍 3

Promotion complete. This does not change the released version of molecule.

#863

@jamroks
Copy link

jamroks commented Jun 17, 2017

Hi,

I see in the docs that to get started, I need to do :

  • pip install ansible
  • pip install docker-py
  • pip install molecule --pre

my question is about docker-py . it's been month now since the "docker-py" library has been renamed to "docker" it's available on pypi . this move has been part of a revamp they did for version 2.0 of the library.
I mostly run test on docker driver and our version of docker in prod is very recent 17.05-ce, so to have full use of the api of docker engine we would need to switch to "docker 2.0" version of the python library .
have you considered that ? or are you waiting on ansible to make the switch too... my understanding is that they are indeed, for some module, developing on the docker 2.0 python library .

FYI the last version of "docker-py is 1.10 "
The new version of the library is "docker 2.0 "

@jamroks
Copy link

jamroks commented Jun 17, 2017

And by the way for the new naming, how about calling it :

  • Ansible-Spec or AnsibleSpec
  • Opspec
  • InfraSpec
  • spec_runner or specrunner

or even how about :

  • Spectral
  • SpecSens
  • RoleSpec
  • AnsiSpec

Yes I know the "Spec" is everywhere ;) ...may The Spec be with you

@butla
Copy link

butla commented Jul 5, 2017

@retr0h The problems that I had with v2 are gone (I tried rc11 now). I'm creating a pull request to switch to v2 in my project right now :)

The things I've struggled with:

@retr0h
Copy link
Contributor Author

retr0h commented Jul 5, 2017

@butla Thanks for the feedback. Yeah, convert.py needs some extra love. I'm mostly using it to convert our internal roles, unfortunately it doesn't do everything for everyone :( It's a ton of work.

@butla
Copy link

butla commented Jul 5, 2017

@retr0h it'd be good to note that in the migration docs. Right now they're saying that it should work for Vagrant configurations, which isn't exactly true, as you see :-)

@MarkusTeufelberger
Copy link
Contributor

I am not too happy with the default configuration of yamllint (i'd like to disable the line length check for example) and it would also be nice to have ansible-lint back in the lint: section. Maybe this could be turned into a list to be able to set additional options to the various linters (even including flake8 or other linters added in the future)?

@retr0h
Copy link
Contributor Author

retr0h commented Jul 5, 2017

I am not too happy with the default configuration of yamllint (i'd like to disable the line length check for example) and it would also be nice to have ansible-lint back in the lint: section. Maybe this could be turned into a list to be able to set additional options to the various linters (even including flake8 or other linters added in the future)?

@MarkusTeufelberger that is already disabled. Molecule init ships with a .yamllint file which turns that off. You probably have molecule files prior to yamllint getting added.

You can drop in a .yamllint file or disable yamllint all together.

@retr0h
Copy link
Contributor Author

retr0h commented Jul 5, 2017

@MarkusTeufelberger that shouldn't be the case. I have fairly significant functional tests which test this. Was just an old config on @alainchiasson's part and new functionality on mine.

This was corrected @ eac0710. Ensured functional test is testing this scenario in the future.

@aroundthecode
Copy link

HI @retr0h which is the proper path/configuration for a custom yamllint file?

I've tried the documentation configuration (by the way on the doc site the official v2 path is still on ansible-lint instead of yamllint)

options:
    config-file: foo/bar

But file seems to be ignored, is the path relative to molecule.yml file as usual?

I've spent 2 hours converting my code to match rules, but some of them (like quoting the boolean values) break ansible logic so it result in tons of warning before starting the converge.

I've also tried a fresh init with RC11 but no .yamlint file is created in the folder.
Am I missing anything?

thanks in advance.

@MarkusTeufelberger
Copy link
Contributor

Ah, I usually add molecule to existing roles and when running molecule init scenario ... the .yamllint file didn't get created.

@retr0h
Copy link
Contributor Author

retr0h commented Jul 6, 2017

@aroundthecode You can just place it at the root of the project, and yamllint will automatically find it. See an example role. Also, it is relative to the scenario dir, see other usage.

@retr0h
Copy link
Contributor Author

retr0h commented Jul 6, 2017

Ah, I usually add molecule to existing roles and when running molecule init scenario ... the .yamllint file didn't get created.

@MarkusTeufelberger Yeah, .pyyaml is a project wide thing. It is only added when molecule init role is used.

@msheiny
Copy link
Contributor

msheiny commented Jul 8, 2017

I'm liking this a lot so far ❤️ ... I really appreciate the extensibility of using ansible playbooks for the spinning up and down of instances.

I agree with comments regarding the lack of docs but I found that I was able to piece together everything after running the --init command. So I would comment that you should throw more examples in that init scaffolding. I also strongly suggest you more prominently link to example roles that utilize molecule v2 in the docs. Less documentation for you to create and more real working examples that ops people like me enjoy 👍

@Moep90
Copy link
Contributor

Moep90 commented Jul 9, 2017

Was the serverspec support removed on purpose or will it come back?
It was originally removed to keep scope down. We probably could and possibly should add it back. I'm not entirely sure how many people use serverspec.

It would be great to directly go with Inspec because it is compatible with serverspec, under steady development and it also replaced Serverspec.

@retr0h
Copy link
Contributor Author

retr0h commented Jul 10, 2017

It would be great to directly go with Inspec because it is compatible with serverspec, under steady development and it also replaced Serverspec.

At the moment I'm not really interested in adding additional verifiers. Ruby based verifiers are a pain to deal with dependency management for most mortals. Testinfra works very well, and for those that want something simpler, Goss.

@butla
Copy link

butla commented Jul 23, 2017

@retr0h It seems that the only way to set no_log to False (e.g. in destroy.yml) is to hardcode it into the file.
Setting MOLECULE_DEBUG=True/true/TRUE doesn't help.

This is because the expression setting "no_log" returns a string, which is truthy as long, as it's not empty. You should probably use "{{ no_log }} | bool" when evaluating.

I'm using molecule 2.0.0.0rc12 and Ansible 2.3.1.0.

@retr0h
Copy link
Contributor Author

retr0h commented Jul 23, 2017

@butla I thought I was doing this. Mind pointing me to where you are having this issue? Maybe I missed a spot. Best I can tell I am doing exactly this. Could it be you had an old scenario before I implemented this?

[jodewey:~/git/molecule_2] [molecule2-env-2.7.12] master+ ± grep -R MOLECULE_DEBUG  molecule
molecule/config.py:            'MOLECULE_DEBUG': str(self.debug),
molecule/cookiecutter/scenario/driver/docker/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml:  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
molecule/cookiecutter/scenario/driver/docker/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml:  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
molecule/cookiecutter/scenario/driver/ec2/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml:  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
molecule/cookiecutter/scenario/driver/ec2/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml:  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
molecule/cookiecutter/scenario/driver/gce/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml:  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
molecule/cookiecutter/scenario/driver/gce/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml:  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
molecule/cookiecutter/scenario/driver/lxc/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml:  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
molecule/cookiecutter/scenario/driver/lxc/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml:  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
molecule/cookiecutter/scenario/driver/lxd/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml:  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
molecule/cookiecutter/scenario/driver/lxd/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml:  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml:  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
molecule/cookiecutter/scenario/driver/openstack/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml:  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
molecule/cookiecutter/scenario/driver/vagrant/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml:  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
molecule/cookiecutter/scenario/driver/vagrant/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/destroy.yml:  no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"

@butla
Copy link

butla commented Jul 23, 2017

@retr0h My assumption was wrong, my version of Ansible will evaluate "False" or "false" as False even though this string would be truthy in Python. But, I can't make it to log anything without directly modifying the yml. Maybe the environment variable isn't getting passed?

How do you run the tests with debug?

$ MOLECULE_DEBUG=True molecule test

doesn't work for me.

As for the no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" expression - it's everywhere that I think it needs to be, that wasn't my problem.

@StephenKing
Copy link

Try molecule --debug

@retr0h
Copy link
Contributor Author

retr0h commented Jul 24, 2017

Yeah, you only get output when running --debug as @StephenKing suggested. Manually passing MOLECULE_DEBUG=True molecule test will not work since Molecule controls the setting of MOLECULE_DEBUG internally and resets whatever you may have passed.

@retr0h
Copy link
Contributor Author

retr0h commented Aug 3, 2017

All outstanding v2 bugs have been addressed with 2.0.0rc14.

Once the RCs were released, I started getting legitimate feedback, so my apologies for those of you that I broke. Once we release Molecule v2 we will not introduce breakage in minor/patch releases.

@b-long
Copy link

b-long commented Aug 9, 2017

Hi there, I'd like to help with your testing, but I'm having some difficulty finding a simple workflow for testing roles with an AWS / EC2 provider. Does anyone have an example to share?

@retr0h
Copy link
Contributor Author

retr0h commented Aug 9, 2017

Hi there, I'd like to help with your testing, but I'm having some difficulty finding a simple workflow for testing roles with an AWS / EC2 provider. Does anyone have an example to share?

@b-long molecule init role -r foo -d ec2

Configure molecule/default/create.yml, molecule/default/destroy.yml, and molecule/default/molecule.yml to your liking.

@bitozoid
Copy link

bitozoid commented Aug 9, 2017

Hi, I'm new to molecule and started using v2 for my roles. Here are some issues (rc14):

  • when creating a vagrant scenario, instance_raw_config_args is missing in create.yml.
  • issue Molecule login crash on iTerm2 resize window #545 again
  • destroy removes all roles in .molecule/roles (empty dirs)
  • docker terminal does not work properly:
    • write any commands
    • go up history (Ctrl-P) (nothing seen)
    • type anything (seen again)

@bitozoid
Copy link

bitozoid commented Aug 9, 2017

It looks that there is a way to avoid Ctrl-P behaviour in docker terminal. Create ~/.docker/config.json like this:

{
    "detachKeys": "ctrl-q,ctrl-q"
}

@retr0h
Copy link
Contributor Author

retr0h commented Aug 9, 2017

@bitozoid please file issues with details.

@retr0h
Copy link
Contributor Author

retr0h commented Aug 9, 2017

It looks that there is a way to avoid Ctrl-P behaviour in docker terminal. Create ~/.docker/config.json like this:

The only true keybindings are vi keybindings ;p lol

@bitozoid
Copy link

@retr0h #917, #918, #919.

@alainchiasson
Copy link
Contributor

Have been away for bit - Nice to see a release 2. 0 !! 👍

@retr0h
Copy link
Contributor Author

retr0h commented Sep 5, 2017

v2 is out 👍

Thanks all for your feedback, issues, and help 👏

@retr0h retr0h closed this as completed Sep 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests