Giter Club home page Giter Club logo

ansible-role-template's Introduction

Build Status

ansible-role-template

Template for custom Ansible roles.

Technical Requirements

Pre-requirements for Linux

  • install ansible
sudo apt-get update
sudo apt-get install software-properties-common
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt-get install ansible
  • check if python > v2 is installed
python --version
  • install vagrant for local vm provisioning
sudo apt-get install virtualbox
sudo apt-get install vagrant
  • install vagrant cachier plugin
vagrant plugin install vagrant-cachier

Ansible files and folder structure

  • ansible folder strucutre
site.yml                  # master playbook
servers.yml               # enable specific roles for hosts
ansible-role-template/    # this hierarchy represents a "role"
    /defaults             # define variables for usage in tasks 
    /handlers             # define "handlers" for start, stop and reload processes
    /meta                 # some metadata for the ansible galaxy
    /molecule             # molecule testing in tavis-ci
    /tasks                # tasks that will be executed on the servers
  • order of file execution

    • site.yml
    • dbservers.yml (based on hosts)
    • tasks
      • main.yml
        • sample_playbooks.yml
    • handlers
      • main.yml

Running playbooks

  • clone repo and configure your hosts
git clone [email protected]:yanehi/ansible-role-template.git
cd ansible-role-template
  • start virtual machine with centos7
vagrant up
  • copy the ssh-key from the ansible host to the required hosts

    • cat ~/.ssh/id_rsa.pub
  • on the hosts

    • mkdir ~/.ssh
    • touch ~/.ssh/authorized_keys && chmod 600 authorized_keys
    • copy your ansible hosts ssh-key to the authorized_keys file on each host
  • check the connection form the ansible host to the other hosts

    • ansible -m ping all
  • execute your ansible playbook

    • ansible-playbook <path to folder with role>/site.yml

Local linter

  • before pushing to travis-ci run yamllint and ansible-lint locally over your ansible role
  • requirements:
    • currently working only with linux
    • yamllint and ansible-lint are installed
./local_role_linter.sh <path to local ansible role repository>

ansible-role-template's People

Watchers

 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.