GithubHelp home page GithubHelp logo

geerlingguy / docker-ubuntu1604-ansible Goto Github PK

View Code? Open in Web Editor NEW
19.0 5.0 50.0 15 KB

Ubuntu 16.04 LTS (Xenial) Docker container for Ansible playbook and role testing.

Home Page: https://hub.docker.com/r/geerlingguy/docker-ubuntu1604-ansible/

License: MIT License

Shell 20.15% Dockerfile 79.85%
docker ansible container image hub ubuntu ubuntu1604 xenial

docker-ubuntu1604-ansible's Introduction

Ubuntu 16.04 LTS (Xenial) Ansible Test Image

CI Docker pulls

Ubuntu 16.04 LTS (Xenial) Docker container for Ansible playbook and role testing.

Tags

  • latest: Latest stable version of Ansible.

The latest tag is a lightweight image for basic validation of Ansible playbooks.

How to Build

This image is built on Docker Hub automatically any time the upstream OS container is rebuilt, and any time a commit is made or merged to the master branch. But if you need to build the image on your own locally, do the following:

  1. Install Docker.
  2. cd into this directory.
  3. Run docker build -t ubuntu1604-ansible .

Note: Switch between master and testing depending on whether you want the extra testing tools present in the resulting image.

How to Use

  1. Install Docker.
  2. Pull this image from Docker Hub: docker pull geerlingguy/docker-ubuntu1604-ansible:latest (or use the image you built earlier, e.g. ubuntu1604-ansible).
  3. Run a container from the image: docker run --detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro geerlingguy/docker-ubuntu1604-ansible:latest (to test my Ansible roles, I add in a volume mounted from the current working directory with --volume=`pwd`:/etc/ansible/roles/role_under_test:ro).
  4. Use Ansible inside the container: a. docker exec --tty [container_id] env TERM=xterm ansible --version b. docker exec --tty [container_id] env TERM=xterm ansible-playbook /path/to/ansible/playbook.yml --syntax-check

Notes

I use Docker to test my Ansible roles and playbooks on multiple OSes using CI tools like Jenkins and Travis. This container allows me to test roles and playbooks using Ansible running locally inside the container.

Important Note: I use this image for testing in an isolated environment—not for production—and the settings and configuration used may not be suitable for a secure and performant production environment. Use on production servers/in the wild at your own risk!

Author

Created in 2016 by Jeff Geerling, author of Ansible for DevOps.

docker-ubuntu1604-ansible's People

Contributors

geerlingguy avatar jaredledvina avatar maglub avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

docker-ubuntu1604-ansible's Issues

Getting error "AttributeError: 'module' object has no attribute 'SSL_ST_INIT'"

Looks like something related to cryptography and pyopenssl...

See example failed build: https://travis-ci.org/geerlingguy/ansible-role-glusterfs/jobs/445178766#L794-L795

TASK [geerlingguy.glusterfs : Ensure PPA for GlusterFS is present.] ************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
fatal: [instance]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1540313003.97-32937704496159/AnsiballZ_apt_repository.py\", line 113, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1540313003.97-32937704496159/AnsiballZ_apt_repository.py\", line 105, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1540313003.97-32937704496159/AnsiballZ_apt_repository.py\", line 48, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/tmp/ansible_apt_repository_payload_vUy42f/__main__.py\", line 124, in <module>\n  File \"/tmp/ansible_apt_repository_payload_vUy42f/ansible_apt_repository_payload.zip/ansible/module_utils/urls.py\", line 95, in <module>\n  File \"/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py\", line 54, in <module>\n    import OpenSSL.SSL\n  File \"/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py\", line 8, in <module>\n    from OpenSSL import rand, crypto, SSL\n  File \"/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py\", line 118, in <module>\n    SSL_ST_INIT = _lib.SSL_ST_INIT\nAttributeError: 'module' object has no attribute 'SSL_ST_INIT'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

This happened on a few different builds.

error when running

I tried to create a container as per the README and run it on my Ubuntu 14.04 machine. I get following error

$ docker run --detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro systemd16_geer /usr/lib/systemd/systemd
WARNING: Error loading config file:/home/vagrant/.docker/config.json - stat /home/vagrant/.docker/config.json: permission denied
afbea0f43e462f206f4889f331f6567c8cea8d2d02cc846ea4bcb27be2fedc36
docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"/usr/lib/systemd/systemd\": stat /usr/lib/systemd/systemd: no such file or directory".

Low priority: apt failing to load package: build-essential

I'm using your travis test setup and the corresponding dockers. The ubuntu1604 is failing for the build-essential package, and for at least some of the child packages in build-essential (I tried to work around it by installing all of them separately).

I have run the role successfully on several different ubuntu16s, including AWS EC2s and this vagrant. I don't know if there is something simple for you to do to freshen your docker, as I am not a docker guru. I do know that there appears to be this difference between your u16 and a stock AWS ubuntu16.

The role is here if you are interested. Any feedback is welcome, as I patterned off of your good works.

The following ansible should replicate the error:

compiled_python3_debian_deps:
- build-essential
- libssl-dev
- libcurl4-openssl-dev
- zlib1g-dev
- libncurses5-dev
- libncursesw5-dev
- libreadline-dev
- libsqlite3-dev
- libgdbm-dev
- libdb5.3-dev
- libbz2-dev
- libexpat1-dev
- liblzma-dev
- checkinstall
- zlibc
- tk-dev
- libc6-dev

  • name: install deps for building source
    apt:
    name: "{{ item }}"
    state: installed
    with_items: "{{ compiled_python3_debian_deps }}"

FutureWarning: CTR mode needs counter parameter, not IV

Using this image for CircleCI 2.0 deployment, and getting following message

/usr/lib/python2.7/dist-packages/Crypto/Cipher/blockalgo.py:141: FutureWarning: CTR mode needs counter parameter, not IV
  self._cipher = factory.new(key, *args, **kwargs)

can be found: https://circleci.com/gh/mglaman/porter/25

Looks like it's due to paramiko/paramiko#714. Looks like package managers haven't updated. Not sure if there's a way we can fix (or need to? build doesn't fail.) But wanted to mention it.

Missing iproute2 causes ansible_default_ipv4 to be empty

I've been attempting to sort out why my Ubuntu 16.04 tests are failing due to ansible_default_ipv4 not being defined. I tracked this down to the fact that this fact uses the command ip -4 route get 8.8.8.8 here https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/facts/network/linux.py#L71

However, it looks like the base ubuntu:16.04 image does not ship with iproute2 installed:

root@265e6d2b2383:/# ip -4 route get 8.8.8.8
bash: ip: command not found
root@265e6d2b2383:/# ansible localhost -m setup  | grep ansible_default_ipv4
root@265e6d2b2383:/#

@geerlingguy - Would it be fair to include that package in this image?

Builds failing likely due to Python 2 support ending

Builds failing when pip tries installing:

Traceback (most recent call last):
  File "get-pip.py", line 24244, in <module>
    main()
  File "get-pip.py", line 199, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    from pip._internal.cli.main import main as pip_entry_point
  File "/tmp/tmpw8qqxl/pip.zip/pip/_internal/cli/main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax

Cant install git and other packages

When i try to run one of my roles (it has gantsign.oh-my-zsh as dependency) with this container, i get the following error:

TASK [gantsign.oh-my-zsh : install dependencies] *******************************
failed: [localhost] (item=git) => {"changed": false, "item": "git", "msg": "No package matching 'git' is available"}
failed: [localhost] (item=zsh) => {"changed": false, "item": "zsh", "msg": "No package matching 'zsh' is available"}

The code of the executed task is

---
- name: install dependencies
  become: yes
  package:
    name: '{{ item }}'
    state: present
  with_items:
    - git
    - zsh

In your container for ubuntu1404 and in my local xenial vagrant-machine it is working without problems.
Probably im stupid, and the error is on my end, but im kinda out of ideas what to try next to solve the problem. Any help is greatly appreciated.

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.