manuelraa / yaml_folder_inventory Goto Github PK
View Code? Open in Web Editor NEWAnsible inventory plugin for better inventory structure
License: GNU General Public License v3.0
Ansible inventory plugin for better inventory structure
License: GNU General Public License v3.0
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!"
}
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
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
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:
If people want to rely on this I should make sure there are tests in place to ensure functionality keeps working even after changes
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"
]
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.