有個增長機器後自動註冊到 ansible hosts 的需求,閒來無事拿 bash 寫了個 webserver 搞了下。在大佬指引下,還加了受權校驗。。html
just for fun...node
bash 仍是挺好玩的linux
gayhubgit
a simple bash script shows the power of nc(netcat)github
It does something like ansible Dynamic Inventory.
It receive http request from client, and save the reported node IP(encrypted with openssl)
to /etc/ansible/hosts or somewhere else.web
This script do nothing but combine the awesome linux command togher:ubuntu
The main point of doing this is to show the power of linux command.
You can use it as I ansible dynamic inventory if you know what you are doing, but
it's not recommended to use this in production.centos
git clone https://github.com/FingerLiu/auth-enabled-bash-server # centos yum install -y dos2unix # ubuntu apt install -y dos2unix
cd auth-enabled-bash-server ./server.sh
nohup ./server.sh & echo $! > run.pid;tail -f nohup.out
kill `cat run.pid`
PASSWORD=12345678Afz NODE_IP=192.168.1.111 ./client.sh