GithubHelp home page GithubHelp logo

ansible-exercise's Introduction

Ansible Exercise

Getting started with Ansible – execute commands and run playbooks against a set of hosts. Minimal configuration required

You Need

  • A 'workstation' that has Docker running. This can be Google Cloud Shell, which is free to use, and it also has a browser-based editor!
  • At least one virtual machine (in the cloud, probably) that runs Ubuntu. This exercise was tested with Ubuntu 18.04

1 – Your Ansible Shell

This is the place where you run ansible. Once more, do this in the Google Cloud Shell for example, but any Mac or Linux with Docker should be fine.

git clone https://github.com/u1i/devops-course

cd devops-course/scripts

./run-ansible.sh

This will create a directory 'ansible' in your $HOME directory. All files you create and edit should be in there.

2 – The Hosts

These are the machines we want to manipulate using Ansible. Provision one or two in the cloud and make sure they have Ubuntu 18.04 running.

In an SSH session do this:

git clone https://github.com/u1i/devops-course

cd devops-course/scripts

sudo ./add-user.sh

WARNING: This one opens a 'backdoor' to your machine by installing SSH Keys. Do only use for test machines and delete them right after

3 – Add the IP Addresses of the Hosts to Ansible

Back in your Ansible Shell create a file called 'hosts' (the absolute path of the file should be /etc/ansible/hosts) and add each IP address of the hosts into a new line

4 – Ping all Hosts from Ansible

The following command should now work:

ansible all -m ping -u devops

35.247.152.243 | SUCCESS => { "changed": false, "ping": "pong" } 34.87.127.234 | SUCCESS => { "changed": false, "ping": "pong" }

5 – Executing Commands on All Hosts

ansible all -a "/bin/echo hello" -u devops

ansible all -a "hostname" -u devops

6 – Install Apache with a Playbook

Create the following file apache.yml on your Ansible Shell:

apache.yml

Run the playbook

ansible-playbook apache.yaml -u devops

ansible-exercise's People

Contributors

u1i avatar

Watchers

 avatar  avatar  avatar

Forkers

franktanah

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.