将“vagrant ssh config”输出转换为清单主机以实现ansible的简单脚本
vagranttoansible的Python项目详细描述
将vagrant ssh-config转换为清单文件的简单库 为了安西布尔。
用法
在您的vagrant目录中,运行脚本vagrant2ansiblethis 将在 当前目录以及名为.vagrant-ssh-config的文件 输出vagrant ssh-config)。
脚本已经用vagrant 2.0进行了测试,但它应该使用 早期版本的《流浪汉》。
安装
$ pip install vagranttoansible
示例
$ vagranttoansible
此配置:
Host machine1HostName 127.0.0.1User vagrantPort 2222UserKnownHostsFile /dev/nullStrictHostKeyChecking noPasswordAuthentication noIdentityFile /home/mha-dw/Projets/ansible/.vagrant/machines/machine1/virtualbox/private_keyIdentitiesOnly yesLogLevel FATALHost machine2HostName 127.0.0.1User vagrantPort 2200UserKnownHostsFile /dev/nullStrictHostKeyChecking noPasswordAuthentication noIdentityFile /home/mha-dw/Projets/ansible/.vagrant/machines/machine2/virtualbox/private_keyIdentitiesOnly yesLogLevel FATAL
将是
machine1 ansible_host=127.0.0.1 ansible_user=vagrant ansible_ssh_common_args='-o StrictHostKeyChecking=no' ansible_ssh_private_key_file=/home/mha-dw/Projets/ansible/.vagrant/machines/machine1/virtualbox/private_key ansible_port=2222machine2 ansible_host=127.0.0.1 ansible_user=vagrant ansible_ssh_common_args='-o StrictHostKeyChecking=no' ansible_ssh_private_key_file=/home/mha-dw/Projets/ansible/.vagrant/machines/machine2/virtualbox/private_key ansible_port=2200
$ vagranttoansible --help usage: vagranttoansible [-h][-V][-v][-o OUTPUT_FILE_NAME] Simple script to transform 'vagrant ssh-config' output to an inventory hosts for Ansible. This script must be run in your vagrant folder. optional arguments: -h, --help show this help message and exit -V, --version Print version and exits -v, --verbose Print more information -o OUTPUT_FILE_NAME, --output-file-name OUTPUT_FILE_NAME The inventory file name to write hosts to. Default: stdout
待办事项
- 或许可以删除Stormsh依赖项
- 在不同的流浪环境下进行测试
将添加更多选项。请随意贡献。
学分
穆罕默德·穆克塔尔·海达拉(elmhaidara@gmail.com)