GithubHelp home page GithubHelp logo

ansible-init's Introduction

ansible-init

Ansible playbook for creating ansible playbooks.

The playbook sets up the common ansible project structure described in the ansible best practices.

Usage:

Use either of the methods below to set up a local directory and file structure ready for ansible-playbook use. All that's needed is to modify the inventory, then add tasks, handlers, files and templates.

ansible-playbook \
init.yml \
-i production \
--connection=local \
--extra-vars='{"roles": ["web", "database"], "project_dir": "/tmp/ansible-project"}'

or using a JSON file with variables:

ansible-playbook \
init.yml \
-i production \
--connection=local \
--extra-vars='@project.json'

Default project JSON file:

{
    "roles": [
        "web",
        "database"
    ],
    "project_dir": "/tmp/ansible-project"
}

roles: array of roles that should be created

project_dir: the directory in which to create the ansible project

Notes

The project will be built locally by default.

To run on a remote server, remove --connection=local from the CLI and change the production inventory file to specify the destination server.

Examples

Project

/tmp/ansible-project/
├── database.yml
├── group_vars
├── host_vars
├── master.yml
├── production
├── roles
│   ├── database
│   │   ├── files
│   │   ├── handlers
│   │   │   └── main.yml
│   │   ├── meta
│   │   ├── tasks
│   │   │   └── main.yml
│   │   ├── templates
│   │   └── vars
│   └── web
│       ├── files
│       ├── handlers
│       │   └── main.yml
│       ├── meta
│       ├── tasks
│       │   └── main.yml
│       ├── templates
│       └── vars
├── staging
└── web.yml

Files

master.yml

---
# master playbook

- include: web.yml
- include: database.yml

web.yml

---
# web role

- hosts: web
  roles:
    - { role: web }

roles/web/tasks/main.yml

---
# Tasks for web

#- name: example
#  action: example
#  notify:
#    - restart service
#  tags:
#    - example

roles/web/handlers/main.yml

---
# Handlers for web

#- name: example restart
#  action: service name=service state=restarted

CHANGELOG

Version 0.0.1 – April 2, 2014

  • Initial release.

License

MIT: http://davestern.mit-license.org

ansible-init's People

Contributors

davestern avatar

Watchers

 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.