Coder Social home page Coder Social logo

yaml_folder_inventory's People

Contributors

manuelraa avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

handedemir

yaml_folder_inventory's Issues

Invalid parsing of file ending by yml_or_yaml function

The yml_or_yaml splitting and checking is wrong.

When having e.g. a file like foo.bar.txt it would split to ["foo", "bar", "txt"] and it takes the index "1" which means it would look at bar.
The other problem is when having a file with no extension it produces a IndexError JUST_A_FILE -> ["JUST_A_FILE"] -> Index 1 -> IndexError

Feature: special 'allhostnames' group containing all ansible_hosts

Sometimes instead of instances we want to target all the actuall hosts. Would be good if this can be done e.g. this way:

- name: Do something with hosts
  hosts: allhostnames
  tasks:
    ...

The feature should be added as a possible config value which can be defined in inventory section of the ansible.cfg

Incorrect recursive group var handling

By using the normal set_variable method the variable gets applied to the complete group of all folder paths and not only inside the folder path where it is specified

Inventory setup

[user@rocky-dever example]$ find ./test
./test
./test/yaml_folder.yml
./test/folder_one
./test/folder_one/apache
./test/folder_one/apache/main.yml
./test/folder_two
./test/folder_two/apache.yml
./test/folder_two/apache
./test/folder_two/apache/main.yml

[user@rocky-dever example]$ cat ./test/folder_two/apache.yml
apache_var: test

Expected result

[user@rocky-dever example]$ ansible-inventory --list -i ./test/yaml_folder.yml 
{
    "_meta": {
        "hostvars": {
            "folder_one-apache-apache1": {},
            "folder_two-apache-apache1": {
                "apache_var": "test"
            }
        }
    },
    "all": {
        "children": [
            "apache",
            "ungrouped"
        ]
    },
    "apache": {
        "hosts": [
            "folder_one-apache-apache1",
            "folder_two-apache-apache1"
        ]
    }
}

Actual result

[user@rocky-dever example]$ ansible-inventory --list -i ./test/yaml_folder.yml 
{
    "_meta": {
        "hostvars": {
            "folder_one-apache-apache1": {
                "apache_var": "test"
            },
            "folder_two-apache-apache1": {
                "apache_var": "test"
            }
        }
    },
    "all": {
        "children": [
            "apache",
            "ungrouped"
        ]
    },
    "apache": {
        "hosts": [
            "folder_one-apache-apache1",
            "folder_two-apache-apache1"
        ]
    }
}

Global variables might not get parsed?

Quick find from taking a closer look at the example.
Either spelling mistake or the variables are not getting parsed correctly

TASK [Print global haproxy group var] *******************************************************************************************************************************************************
ok: [internal-simu-haproxy-haproxy-db1] => {
    "haproxy_global_variable": "VARIABLE IS NOT DEFINED!"
}
ok: [internal-simu-haproxy-haproxy-db2] => {
    "haproxy_global_variable": "VARIABLE IS NOT DEFINED!"
}
ok: [external-prod-haproxy-haproxy-db1] => {
    "haproxy_global_variable": "VARIABLE IS NOT DEFINED!"
}
ok: [external-prod-haproxy-haproxy-db2] => {
    "haproxy_global_variable": "VARIABLE IS NOT DEFINED!"
}

Add tests

If people want to rely on this I should make sure there are tests in place to ensure functionality keeps working even after changes

Feature - add host to custom groups from path tree

Hi, it is possible to add host to custom groups from entire path?

Example:
From hosts in file:
./inventory/service/type/environment/main.yml
to:

  • hosts in groups:
  • service
  • service_type
  • service_type_environment
  • environment (this is already implemented)

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.