ansible / molecule

Molecule aids in the development and testing of Ansible content: collections, playbooks and roles
https://ansible.readthedocs.io/projects/molecule/
MIT License
3.88k stars 662 forks source link

Better way of using different OS family types with serverspec tests? #846

Closed racorretjer closed 7 years ago

racorretjer commented 7 years ago

Issue Type

Molecule and Ansible details

ansible --version
ansible 2.3.0.0
  config file =
  configured module search path = Default w/o overrides
  python version = 2.7.13 (default, Apr  4 2017, 09:51:50) [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38)]

molecule --version
molecule, version 1.24.0

Desired Behaviour

I'm currently using molecule in conjunction with serverspec and docker. I'm trying to test different cases with the os[:family] bit provided by serverspec, but am only able to successfully do so if I include the following before the actual tests:

host = ENV['TARGET_HOST']
set :host, host
set :docker_container, host

I was wondering if you knew of a better way to do this? The serverspec docs have you create the docker images/containers WITH serverspec as opposed to dynamically targeting containers, so I didn't have any luck looking there.

retr0h commented 7 years ago

What you are doing looks reasonable. I haven't used serverspec in quite some time. We primarily use testinfra. Serverspec is actually deprecated in molecule v2.

However, you should still be able to target os[:family] in your tests in the way you described.

racorretjer commented 7 years ago

Thanks! I thought I was just hacking my through this issue, but there doesn't seem to be any other way of doing it. It's a shame that serverspec won't be supported on v2. But I'd rather have a solid piece of software that does something well rather than trying to do everything halfway. Great piece of software, btw. I depend on it everyday.