GithubHelp home page GithubHelp logo

ansible-test's Issues

Missing requirements in build

It might be a package issue, but when you run the command it results in this:

Running setup.py install for cryptography
    c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
     #include <ffi.h>
                     ^
    compilation terminated.
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/opt/ansible/venv/build/cryptography/setup.py", line 335, in <module>
        **keywords_with_side_effects(sys.argv)
      File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "/opt/ansible/venv/local/lib/python2.7/site-packages/setuptools/dist.py", line 239, in __init__
        self.fetch_build_eggs(attrs.pop('setup_requires'))
      File "/opt/ansible/venv/local/lib/python2.7/site-packages/setuptools/dist.py", line 264, in fetch_build_eggs
        replace_conflicting=True
      File "/opt/ansible/venv/local/lib/python2.7/site-packages/pkg_resources.py", line 580, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "/opt/ansible/venv/local/lib/python2.7/site-packages/pkg_resources.py", line 818, in best_match
        return self.obtain(req, installer) # try and download/install
      File "/opt/ansible/venv/local/lib/python2.7/site-packages/pkg_resources.py", line 830, in obtain
        return installer(requirement)
      File "/opt/ansible/venv/local/lib/python2.7/site-packages/setuptools/dist.py", line 314, in fetch_build_egg
        return cmd.easy_install(req)
      File "/opt/ansible/venv/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 593, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "/opt/ansible/venv/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 623, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "/opt/ansible/venv/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 809, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "/opt/ansible/venv/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1015, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "/opt/ansible/venv/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1003, in run_setup
        raise DistutilsError("Setup script exited with %s" % (v.args[0],))
    distutils.errors.DistutilsError: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    Complete output from command /opt/ansible/venv/bin/python -c "import setuptools, tokenize;__file__='/opt/ansible/venv/build/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-5lm8Op-record/install-record.txt --single-version-externally-managed --compile --install-headers /opt/ansible/venv/include/site/python2.7:
    c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory

 #include <ffi.h>

                 ^
This can be fixed by adding `libffi-dev` in the `apt-get install` command

Test in LXC

Nice package !

Have you considered running tests in a LXC guests ? LXC may be a better tool because it does distribution isolation, rather than process isolation: it runs a real init as PID 1.

You could run something like this to create the LXC guests the test needs from the test inventory file:

- hosts: localhost
  vars:
    LXC_PATH: /var/lib/lxc  # change to /tmp to run in ram with -e

  tasks:
  - name: Configure container
    lxc_container:
      name: '{{ item }}'
      template: debian
      state: started
      template_options: --release wheezy
      lxc_path: '{{ LXC_PATH }}'
    with_items: '{{ groups["all"] }}'

  - name: Ensure .ssh directory exists in container
    file:
      path: '{{ LXC_PATH }}/{{ item }}/.ssh'
      state: directory
      mode: 0700
    with_items: '{{ groups["all"] }}'

  - name: Add your SSH key in the container
    copy:
      src: '{{ lookup("env", "HOME") }}/.ssh/id_rsa.pub'
      dest: '{{ LXC_PATH }}/{{ item }}/.ssh/authorized_keys'
      mode: 0600
    with_items: '{{ groups["all"] }}'

Then you could execute your playbooks from the host.

Testing on multiple hosts may be useful for more complicated tests such as orchestration tests.

Thoughts ?

[abandoned repo?] Official ansible-test binary name collision โ€” this project seems to have published a misleading package on PyPI

Hello! Ansible Core Engineering Team member here ๐ŸŽค.

ansible-core has a tool called ansible-test. It used to be development-only but a few major versions back it started being exposed as ansible-test executable and now if somebody will do pip install ansible-test ansible, they'll conflict trying to overwrite each other.

Our official ansible-test is a test runner that we use in our own CI for running various sanity, unit, and integration tests. Besides that, it's an official solution to running tests in end-users' Ansible Collections. In particular, it supports running tests in docker containers as well as in the host environment.
There's a different type of testing that's not covered by the official ansible-test but is covered by another active community project called Molecule. It allows running roles against automatically orchestrated envs, including container-based, just like this project.

Looking at the activity of this repository, it seems to be unmaintained for the last 3 years (and the PyPI release was 6 years ago). It only seems fair to recommend users to use the official tooling from Ansible Core and Molecule projects.

There's one problem, though: when folks hear about the need to use ansible-test, they often end up in this dead project while they are expected to use the official one. This creates some amount of friction as it is misleading.

@jerm @grinich @rcoh @SJLC @spang @woohgit would you be open to migrating this project to a different name on GitHub and PyPI to help reduce the confusion this collision creates?

Joining forces

I am the maintainer of the molecule project. I see this project is similar to ours. Would you be interested in joining forces?

John

python package index (PyPi) migration breaks ansible-test?

When running ansible-test sanity --list-tests command from ansible documentation, the docker instance fails to init due to PyPi erroring out because it can't install ansible into the docker instance(?):

vagrant@vagrant-acs:~$ sudo ansible-test sanity --list-tests
Sending build context to Docker daemon  6.405MB
Step 1/8 : FROM debian:7.7
 ---> 6d129b37ec3b
Step 2/8 : MAINTAINER Rob McQueen
 ---> Using cache
 ---> 2497f1a1838e
Step 3/8 : RUN apt-get update && apt-get install -y   python-dev   python-virtualenv   sudo
 ---> Using cache
 ---> 73436b884880
Step 4/8 : RUN mkdir /opt/ansible && virtualenv /opt/ansible/venv && /opt/ansible/venv/bin/pip install ansible
 ---> Running in 7c8aa8fbe804
New python executable in /opt/ansible/venv/bin/python
Installing distribute.............................................................................................................................................................................................done.
Installing pip...............done.
Downloading/unpacking ansible
  Cannot fetch index base URL http://pypi.python.org/simple/
  Could not find any downloads that satisfy the requirement ansible
No distributions at all found for ansible
Storing complete log in /root/.pip/pip.log
The command '/bin/sh -c mkdir /opt/ansible && virtualenv /opt/ansible/venv &&   /opt/ansible/venv/bin/pip install ansible' returned a non-zero code: 1
Traceback (most recent call last):
  File "/usr/local/bin/ansible-test", line 69, in <module>
    main(context)
  File "/usr/local/bin/ansible-test", line 45, in main
    '-t', DOCKER_CONTAINER, '.']
  File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['docker', 'build', '-t', 'testbox', '.']' returned non-zero exit status 1

This is likely caused by the recent PyPi migration of trusted host site (see below)

Stackoverflow link

Note: Sometime during April 2018, the Python Package Index was migrated from pypi.python.org to pypi.org. This means "trusted-host" commands using the old domain no longer work.

su, sudo conflict with become

I absolutely love this lightweight and fast testing tool, and that it doesn't require me to install all the weight of test-kitchen to run. However, I'm running into this problem no matter what I do:

Step 8 : CMD /opt/ansible/venv/bin/ansible-playbook -i inventory.yml     -c local -s -e testing=true -e role=$DOCKER_TEST_ROLE     -vvvv playbook.yml; /bin/bash
 ---> Running in 3187901e93db
 ---> b17e33c00016
Removing intermediate container 3187901e93db
Successfully built b17e33c00016
Usage: ansible-playbook playbook.yml

ansible-playbook: error: Sudo arguments ('--sudo', '--sudo-user', and '--ask-sudo-pass') and su arguments ('-su', '--su-user', and '--ask-su-pass') and become arguments ('--become', '--become-user', and '--ask-become-pass') are exclusive of each other

I get the same results with or without adding -vvvv.

No such file or directory: 'x86_64-linux-gnu-gcc'

When running ansible-test with --image ubuntu:16.04, setup of the environment inside the container fail with

unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

No support for yum based distributions

The apt-* commands in the Dockerfile are hard-coded for Debian based distributions. It will be good to allow detection of OS family and change them with their yum equivalents.

$ ansible-test logstash -i centos            
Sending build context to Docker daemon  193.5kB
Step 1/8 : FROM centos
 ---> 328edcd84f1b
Step 2/8 : MAINTAINER Rob McQueen
 ---> Using cache
 ---> d1c31afe5d68
Step 3/8 : RUN apt-get update && apt-get install -y   python-dev   python-virtualenv   sudo
 ---> Running in 977da8b18afa
/bin/sh: apt-get: command not found
The command '/bin/sh -c apt-get update && apt-get install -y   python-dev   python-virtualenv   sudo' returned a non-zero code: 127
Traceback (most recent call last):
  File "/usr/local/bin/ansible-test", line 69, in <module>
    main(context)
  File "/usr/local/bin/ansible-test", line 45, in main
    '-t', DOCKER_CONTAINER, '.']
  File "/usr/lib/python2.7/subprocess.py", line 186, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['docker', 'build', '-t', 'testbox', '.']' returned non-zero exit status 127

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.