Coder Social home page Coder Social logo

ansible-101's Introduction

Getting starting with Ansible with a Docker LAB ๐Ÿณ

This repo is part of my blog post on geting started with Ansible and becoming a DevOps.

The LAB

The LAB is made of 3 containers to be managed by Ansible:

  • Docker Debian
  • Docker Ubuntu
  • Docker Centos

Plus a Docker Ansible, to have and avoid installing Ansible on your laptop.

Bootstrap Ansible LAB

To bootstrap this tutorial, I wrote and init script, by doing following tasks:

  • Delete previous 3 containers Debian, Ubuntu et Centos
  • Create an RSA key allowing Ansible connection through SSH
  • Starting 3 instances Docker Debian, Docker Ubuntu, and Docker Centos
  • Ssh key injection in each Docker instance using ssh-copy-id (password will be ask: toor)
  • Ansible hosts inventory creation

To "ping" our 3 nodes:

docker run -it --rm -v `pwd`/hosts:/etc/ansible/hosts -v `pwd`/id_rsa:/root/.ssh/id_rsa itwars/ansible-cli all -m ping
172.17.0.3 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
172.17.0.4 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
172.17.0.2 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

To setup Nginx on Debian Ansible node:

docker run -it --rm -v `pwd`/hosts:/etc/ansible/hosts -v `pwd`/id_rsa:/root/.ssh/id_rsa itwars/ansible-cli debian -m apt -a "name=nginx state=present"

To start Nginx on Debian Ansible node:

docker run -it --rm -v `pwd`/hosts:/etc/ansible/hosts -v `pwd`/id_rsa:/root/.ssh/id_rsa itwars/ansible-cli debian -m service -a "name=nginx state=started"

ansible-101's People

Contributors

itwars avatar

Watchers

 avatar  avatar  avatar

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.