GithubHelp home page GithubHelp logo

alancoding / ansible-inventory-file-examples Goto Github PK

View Code? Open in Web Editor NEW
36.0 6.0 21.0 389 KB

Examples and counter-examples of Ansible inventory files

License: MIT License

Python 86.72% Shell 13.28%
ansible-inventory ansible dynamic-inventory awx

ansible-inventory-file-examples's Introduction

Ansible-inventory-file-examples

Examples and counter-examples of Ansible inventory files

Goals of these are mostly academic, to demonstrate a syntax, scaling pattern, or issue reproducer. None of these are designed to reflect best practices for using Ansible.

README files are given in many subdirectories.

Top level is mostly organized by file type, with further subdivisions by topic. While this isn't always maintained, an attempt is made.

Using these

Everything is designed to be ran from the CLI from the root of the project root. Aside from one folder for playbook, and other testing scripts, everything is an inventory file that goes in with the -i flag. That means you should see -i <relative path in project>. There are multiple testing commands you can use on any given inventory file.

# run the absolute minimal playbook
ansible-playbook -i top_level_file.ini debugging/hello_world.yml
# print the hostvars for all the hosts
ansible-playbook -i top_level_file.ini debugging/hostvars_print.yml
# dump standard representation of the inventory contents
ansible-inventory -i top_level_file.ini --list --export

Quick and dirty performance profiling

Reference for doing the cProfile stuff

ansible/ansible#13673

pip install pyprof2calltree
python -m cProfile -o outme $(which ansible-playbook) -i <rel_path> debugging/hello_world.yml
pyprof2calltree -i outme
qcachegrind outme.log

Commands from the root of project

Ansible config file example

Inventory plugin path via magic inventory_plugins dir:

ansible-inventory -i plugins/config_path/same_dir/cow.yaml --playbook-dir=plugins/config_path/same_dir --list

Inventory plugin path via child directories:

ansible-inventory -i plugins/config_path/sub_dir/cow.yaml --playbook-dir=plugins/config_path/sub_dir --list

Inventory plugin path via relative directory and using parent directories:

ansible-inventory -i plugins/config_path/inventory_dir/cow.yaml --playbook-dir=plugins/config_path/inventory_dir --list

All of these work testing locally.

Debugging process for the final example:

ansible-inventory -i plugins/config_path/inventory_dir/cow.yaml --playbook-dir=plugins/config_path/other_dir --list
ansible-doc -t inventory -l --playbook-dir=plugins/config_path/inventory_dir

ansible-inventory-file-examples's People

Contributors

alancoding avatar spredzy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ansible-inventory-file-examples's Issues

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.