testinfra | Testinfra test your infrastructures | Continuous Deployment library
kandi X-RAY | testinfra Summary
kandi X-RAY | testinfra Summary
Testinfra test your infrastructures
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of testinfra
testinfra Key Features
testinfra Examples and Code Snippets
---
# The driver part of this file tells kitchen what platform to
# provision and run tests on. This can be swapped for other drivers
# such as EC2/DigitalOcean etc.
driver:
name: vagrant
# The platforms part tells the driver on what system we wa
# tests/prometheus/test_prometheus.py
def test_prometheus_is_running(host):
service = host.service("prometheus")
assert service.is_running
assert service.is_enabled
def test_prometheus_listening(host):
assert host.socket('tcp://0.0.
./moleculew test
Additional options:
--ansible VERSION Use the specified version of Ansible
--docker-lib VERSION Use the specified version of the Python Docker
library
--molecule VERSION Use
Community Discussions
Trending Discussions on testinfra
QUESTION
With testinfra, I'm using
get_variables()
method from testinfra.modules.ansible.Ansible but it seems that testinfra cannot evaluate my Ansible variable.
Let's describe my poc.
...ANSWER
Answered 2021-Mar-20 at 06:00You're testing the inventory. The result is correct
QUESTION
I'm trying to write a test suite for verifying the state of some servers using testinfra.
It's my first time working with python/testinfra/pytest.
As a brief pseudocodey example
test_files.py
...ANSWER
Answered 2020-Jul-29 at 07:25That's a fine question, and it looks like you've come at it from a couple different angles already. I'm no expert myself, but there are a few different ways I can think to do something like this in pytest. They all involve handing the heavy lifting over to fixtures. So here's a quick breakdown of one way to adapt the code you've already shared to use some fixtures:
Default Parameters
It looks like you've got some parameters that are not host-specific. It likely makes sense to pull those into a session-scoped fixture so you can reuse the same values across many hosts:
QUESTION
I've being trying to run find good repositories or examples of using molecule with kvm. But so far all of them gets this.
{'lint': ['must be of string type']}
I have no clue how to fix this. Like this
...ANSWER
Answered 2020-Feb-26 at 16:09This error is because your molecule has been updated to version 3 while your test code is still with version 2. For version 3, use
QUESTION
I use molecule a lot with the docker driver. There are a few cases where docker is not the right tool to test ansible roles against, so I'd like to spin up a vm in openstack.
I've created an ansible role with molecule role -r
and changed the driver in molecule.yml to 'openstack'. This is an example of my current molecule.yml:
ANSWER
Answered 2020-Feb-01 at 00:38The default driver is docker. You should create your role from start with the openstack driver. This will put the correct setting for you in molecule.yml as well as create the necessary base files in your default scenario:
QUESTION
I have the problem where my default values are normally stored in defaults/main.yml
for running ansible scripts but I have not found a way to override them. I am using molecule to test, and I want a method of passing in variables into my molecule/default/molecule.yml
or to molecule/default/playbook.yml
so that I can dynamically set phpVersion
.
- Here is where the variable is statically set with a default value
ANSWER
Answered 2020-Jan-26 at 11:23Edit: it might actually be possible to do better than below but I didn't get time to test it fully. Solution below is still valid. Choose the best one for you.
You can actually pass env vars to the molecule ansible provisionner from molecule.yml
(see doc which itself accepts env vars for templating with fallback to default values.
Here is the new idea. It is cleaner in the molecule playbook that solution below but needs two different env vars (one for the command line and the over one passed by molecule to the playbook).
In molecule.yml
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install testinfra
You can use testinfra like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page