Git Product home page Git Product logo

ansiblecm's Introduction

Ansible Control Machine (Docker'ized)

A Docker based Ansible control machine useful for running playbooks with a consistent environment. Other similar images look to build the software items into a Docker image using Ansible, or automate the creation of a control machine, but what I wanted is to be able to run Ansible playbooks consistently using an immutable environment.

With Ansible, a typical use case is to have your CI server (Jenkins, Bamboo, etc...) orchestrate a set of playbooks to perform tasks (provision cloud resources, install packages, configure applications, etc...). The CI environments evolve over time often introducing dependencies which conflict with those required to run the desired version of Ansible and supporting modules which is a pain to manage IMO. This Docker image allows you to run a fixed version of Ansible, with dependencies for some of the popular modules (ec2, route53, archive, yum, apt, etc...) in an environment which will not change as the Ansible control machine's environment becomes immutable.

Having the Ansible control machine's environment packaged up in a Docker container, the ability to provision resources using it dynamically becomes possible using a wide variety of configurations. For example, you can run this control machine via:

  • Jenkins slaves configured with nothing more than Docker
  • As tasks on Amazon Elastic Compute Service (ECS)
  • As short lived pods on Kubernetes
  • On your laptop without pre-installing Ansible

Basically, this control machine can be run anywhere you can run a Docker container.

Build

docker build --tag ansiblecm:6.2.0 .

Usage

Docker images are available on Docker Hub.

By default, this control machine will assume the execution of an Ansible playbook. To specify which playbook to run, simply map the playbook into the container like so:

docker run -it --rm -v <absolute path to playbook>:/tmp/playbook:Z jmal98/ansiblecm:6.2.0 <playbook arguments>

For example, the following will run the playbook in the current directory.

docker run -it --rm -v $PWD:/tmp/playbook:Z jmal98/ansiblecm:6.2.0 site.yml -i inventory/hosts

This control machine is also useful for running Ansible "one liners" which do not require a playbook. The example below runs the setup module on the web machines as specified in the inventory file.

docker run -it --rm --entrypoint ansible jmal98/ansiblecm:6.2.0 web -m setup -i inventory

Demo

A demo of how to use this control machine locally is provided. For details on the setup and execution of the demo, see DEMO.

Versions

The versions of this image will closely track to the versions of Ansible. The versions of module dependencies will be fixed to compatible versions.

Contributing

Contributions are welcome.

License

Apache License 2.0, see LICENSE.

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.