Coder Social home page Coder Social logo

ansible_layout_example's Introduction

Ansible example structure

This repository is an example of how you could setup an ansible script repository. It has been described in Ansible best practises

What is Ansible

  • Configuration Management tool ** We don't want something like that anymore
  • It communicates with remote machines over SSH
  • configured via ini files
  • Can be run from any machine with Python 2.6 or 2.7 installed (Currently)
  • Managed nodes need Python 2.4 or later

Ansible Language

Modules

  • (also referred to as “task plugins” or “library plugins”) are the workers in ansible
  • Ansible ships with a number of modules that can be executed directly on remote hosts (List of all Modules)
  • Users can also write their own modules ( in python <3 ), but you probably don't need to.

Playbooks

  • are Ansible’s configuration, deployment, and orchestration language
  • describe a policy you want your remote systems to enforce
  • can and should be idempotent (can be run several times without changing anything)

Inventories

Ansible works against multiple systems in your infrastructure at the same time. It does this by selecting portions of systems listed in Ansible’s inventory file, which defaults to being saved in the location /etc/ansible/hosts. You can specify a different inventory file using the -i <path> option on the command line.

  • contain groups of servers to tell ansible, which servers your system is made up of
  • written in the ini file format
  • servers may be added to multiple groups
  • groups of groups possible as well (for building a tree of servers)

Roles

  • Structure defines file usage (Convention over Configuration)

Running ansible

Running a module ad hoc

ansible scriptclub -m ping
ansible all -a "/bin/echo hello"
ansible -i inventory_file webservers -m service -a "name=httpd state=restarted"

Running playbooks

You can either provision all servers by running:

ansible-playbook -i testing.ini site.yml 

or provision only a subset of your servers via:

ansible-playbook -i testing.ini site.yml --limit dbservers
ansible-playbook -i testing.ini webservers.yml

Ansible Vault ...

... is a secure Key-Value store, which allows keeping sensitive data such as passwords or keys in an encrypted file. This vault file can then be distributed or placed in source control.

To create a new encrypted data file, run the following command:

ansible-vault create secure.yml

It will ask you for a password.

And to edit it afterwards run:

ansible-vault edit secure.yml

To run a playbook, which contains vault-encrypted variables, you can either tell ansible to ask you for the password:

ansible-playbook -i testing.ini site.yml  --ask-vault-pass

Or you create a file with that password and pass it to ansible:

cat your_secret_password > ~/.vault_pass
ansible-playbook -i testing.ini site.yml --vault-password-file ~/.vault_pass

Don't forget to add this file to your .gitignore if you put it inside of your repository!

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.