dysosmus / ansible-completion Goto Github PK
View Code? Open in Web Editor NEWBasic bash completion for Ansible
License: GNU General Public License v3.0
Basic bash completion for Ansible
License: GNU General Public License v3.0
There are a few more ansible tools. Namely:
Would you like to implement completion for those as well in this repo or at least accept pull-requests?
It writen only for freebsd?
In linux md5->md5sum and other keys to stat.
It work on linux whith -
@@ -86 +86 @@
- local hash_module_path=$(md5 -q -s "$module_path")
+ local hash_module_path=$(echo "$module_path" | md5sum |awk {'print $1'})
@@ -116 +117 @@
- echo $(stat -f "%Sm" -t "%s" $1)
+ echo $(stat -c "%Z" $1)
In the readme the step 2 tells:
- Copy/move the
ansible-completion.bash
in yourbash_completion.d
folder (/etc/bash_completion.d
,/usr/local/etc/bash_completion.d
or~/bash_completion.d
).
But that path does not exist anymore. See https://archlinux.org/todo/use-usrsharebash-completioncompletions-for-package-bash-completions/
Instead, I think each *-completion.bash file except ansible-completion.bash should source the common one. I.e. include the following line after shebang:
source /usr/share/bash-completion/completions/ansible
Looks like the file names for ansible-pull and ansible-vault got switched around.
Thanks!
Scott
Edit: oh, and the ansible-vault function is also labeled as _ansible-pull.
If enable -
set -o noclobber
it have errors like
ansible myhost -m bash: /tmp/25576.module-name.ansible.completion: cannot overwrite existing file
As variant it fixed -
- local cache_file=/tmp/${$}.${module_path:+"$hash_module_path".}module-name.ansible.completion
+ # /tmp/<pid>.<hash of the module path if exsist>.module-name.ansible.completion and time for set -o noclobber
+ local cache_file=/tmp/${$}.$(date +%s).${module_path:+"$hash_module_path".}module-name.ansible.completion
And it work, but it doesnt good solution, i think -
find /tmp/ -name "*.completion"
/tmp/25576.1399165774.module-name.ansible.completion
/tmp/25576.1399165789.module-name.ansible.completion
/tmp/25576.1399165767.module-name.ansible.completion
/tmp/25576.module-name.ansible.completion
/tmp/25576.1399165783.module-name.ansible.completion
/tmp/25576.1399165770.module-name.ansible.completion
I wanted to point out that the installation steps for a user-defined bash completion
A) direct users to make a non hidden directory for thier user configuration, which breaks the norm and
B) doesn't actually get autoloaded by the bash shell.
However, according to http://serverfault.com/q/506612/210994
a user can make a file ~/.bash_completion
and append to that file with the completions they want.
Or even better, make a directory ~/.bash_completion.d/
and populate the ~/.bash_completion
file with the body:
~/.bash_completion
#!/usr/bin/env bash
if [ -d "$HOME/.bash_completion.d" ]; then
for filename in "$HOME/.bash_completion.d/*"; do
source $filename
done
fi
Any file placed in ~/.bash_completion.d/
will be loaded.
This utilizes the existing bash autoload, And leaves the config files as hidden files to follow precedent.
Hello. Thanks for this project.
Seems like this project is completely separate and unofficial. Could be this mentioned in the readme?
Also, how it differs from the python-argcomplete method, described in official documentation here? Could this be mentioned in readme too?
Hi,
I wanted to learn about bash completion by writing something like this, for ansible-playbook.
In particular, I wanted to make it so, that when you provide a parameter for the inventory, for example -i inventory/my-inventory
and then you add the --limit
parameter, it would complete the possible parameter values according to what is in that inventory.
Would you consider that a suitable addition?
Not sure how hard it is though... ;)
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.