Hello Ansible team!
I’m having great time with Ansible and I want make my experience (and Ansible) better.
My story is related with administrating over 500 nodes with legacy and hacks, so I can’t do everything “The right way” (and this is just “my personal” inventory part ). That’s why I had to start thinking about extra options. I will describe a few thoughts and ask you for discussion. And my apologies for possible mistakes in my English.
So, let’s go!
I am using my Ansible bash_completion (full of hacks) and it helps me now. So I promised to share it with community. Today, I started improvement work on it… and had first blockers. I tried to make it really cool and support all possible completions.
First one is inventory completion (groups, hosts). I have my inventory-script with extra feature – show all hosts and groups (I have got about 60+ groups and 450+ nodes). And that is really “The Feature” of CMS for me (and all my colleagues). Somewhere we have poor infrastructure, sometimes we have special tasks – so we use ansible cli for per host/group shell executions (no playbooks).
For me it is a very big reason to use second field (host_group_pattern) with bash_completion. And I failed with it today.
I can’t do in my terminal this:
ansible my_cool_group:!dead_hosts:!unused.example.com -m shell -a ‘uptime’
Bash use symbols “!”, “&” for its internal things. So we can do an “ugly hack” (this is just my opinion – no offence ):
ansible “my_cool_group:!dead_hosts:!unused.example.com” -m shell -a ‘uptime’
But it is (maybe) uncompletable and totally unhandy in my background/case. So let me propose you another syntax – we can replace this characters this way:
- “!” => “-”, # this is like numbers: positive and negative
- “&” => “^”, # conjunction symbol
- “:” => “,” (optional). # I really feel comma for this case – we use commas everyday for lists (appendings)
I totally understand about changing this part in so huge project, so it could be smooth. “–future” option for this behavior for example. Think about it. My UX experience is all about this thesis.
Let’s go further, second thing: in my practice we have a very good agreement about group naming – start group name with special character (I prefer “@” and someone use “%”).
UX remark: it helps our vision to extremely fast distinguish hosts from groups – it is about, how our sight works (visual pattern at the first word/name symbol).
I’m asking you for keeping this ability (support some “special” characters in group names) and propose to think about this idea for Ansible “Best practice” (not insisting here, just sharing thoughts).
Third one!
I have my hack with inventory script for getting group and host lists, but Ansible doesn’t have it for now. I think, it is a good idea to separate inventory features from Ansible part (CMS) – I am about “–list-hosts”. If we extract this to another “tool” (for example “ansible-inventory”), we can make ansible (tool) keys more focused and at the same time make Ansible (project) more powerful about inventory integration (I will write a bit more about this later in this message).
Ansible-inventory can be improved by “–list-groups” (minimal required key) and other. And more! We could pass parameters to Inventory script – it would proxy any Inventory system functionality to ansible toolset. One tool – infinite abilities, homogeneous environment (as a UX guy, I’m double-pointing this point! )
Fourth.
Ansible have great option “–limit”, in our practice we faced with an issue: limit hosts by variable (still in command line) – can we add this option too? # Suddenly pretty short point.
Next, fifth!
Last one about my bash_completion issue. I grab options for completion from “ansible --help” (and the same for other tools), but it would be much better to have some “contract” here – agreement about fetching list of keys. And the questions:
- can I rely on current “–help” output format?
- or you can prompt an existing way (maybe I missed it)
Great, that’s all questions based on bash_completion work. I think I have some more notes, but there are a bit outdated. I promise to examine them and to patches or reports.
Last part, a little bit more about my background – I am going to start Inventory system project and I want to have integrations with Ansible. In my environment we really need inventory system more powerful than ini-file. We work with our current solution in a bit more complex way. And I really feel to use one toolset for close tasks. And my vision is an “ansible-inventory” “glue/proxy” tool to integrate any Inventory system with this extremely powerful CMS tools – Ansible.
Thank you very much for reading, I hope we can have a very positive and fruitful discussion. I hope Michael will join this theme.