Giter VIP home page Giter VIP logo

ansible-play's Introduction

Ansible Playground

This repository is to be used for playing with and creating Ansible Playbooks.

Localhost Instructions

Vagrant is used on the localhost, but is wrapped in a bash script abstraction layer to automatically create the inventory files and modify the ansible.cfg as necessary.

  • ./initlocal.sh
    • Create the Vagrant Machines requested
    • Provision the Machine with the default playbook ./ansible/playbooks/initServer.yml
    • Create an inventory file ./ansible/inventories/vagrant/hosts

The vagrantfile requires unique and count to be passed as environment variables.

$ ./initlocal.sh vm 2
$ unique=vm count=2 vagrant ssh vm2

Test Ansible

The init scripts automatically create the necessary ansible.cfg and inventory files. Test the connectivity to the servers that were created.

ansible all -m ping

Running a playbook

$ ansible-playbook ansible/<playbookname>.yml

Install a Swarm Cluster

Playbook swarmCluster installs docker and can configure servers into a swarm.

To configure a swarm you must modify the inventory file and tag the servers as manager or worker.

[manager]
vm1
vm2
vm3

[worker]
vm4
vm5
vm6

NOTE: To configure a swarm on vagrant you must set the swarm interface variable to enp0s3 in vagrant/group_vars. swarm_iface: 'enp0s8'

Connect to server

$ vagrant ssh

Remove Server

$ vagrant destroy

Azure Instructions

Init Script will create a simple Azure Virtual Machine with up to date patches and ready for ansible commands.

$ ./init.sh <unique>

Running a playbook

$ INVENTORY_FILE="ansible/hosts/azure"
$ ansible-playbook -i ${INVENTORY_FILE} ansible/<playbookname>.yml

Connect to server

$ ./connect.sh <unique>

Remove Server

$ ./clean.sh <unique>

Example Activities

Build a Swarm Cluster with 3 manager nodes and 3 worker nodes

$ ./init.sh <unique> 6
$ ansible-playbook ./ansible/playbooks/swarmCluster.yml

Configure Persistant Storage

$ vboxwebsrv -H 0.0.0.0 -v >/dev/null 2>&1 &
$ ansible-playbook ./ansible/playbooks/storageVagrant.yml

# When done bring back the task and kill it
$ fg

Notes to Remember

Use JQ to quickly retrieve ansible variables

$ ansible jumpserver -m setup   | sed 's/.*|.*=>.*/{/g' |jq .ansible_facts.ansible_env

Initialize Virtualbox for Rexray Storage

$ VBoxManage setproperty websrvauthlibrary null
$ vboxwebsrv -H 0.0.0.0 -v

ansible-play's People

Contributors

danielscholl avatar

Watchers

James Cloos 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.