我正在尝试使用Ansible动态清单来安装软件/执行配置管理。
我已按照Microsoft的指示执行了以下说明: https://docs.microsoft.com/en-us/azure/ansible/ansible-manage-azure-dynamic-inventories
来自我的VM的命令在这里:
az group create --resource-group ansible-inventory-test-rg --location eastus
az vm create --resource-group ansible-inventory-test-rg --name ansible-inventory-test-vm1 --image UbuntuLTS --generate-ssh-keys
az vm create --resource-group ansible-inventory-test-rg --name ansible-inventory-test-vm2 --image UbuntuLTS --generate-ssh-keys
az account show
az resource tag --tags nginx --id /subscriptions/<Subscription ID>/resourceGroups/ansible-inventory-test-rg/providers/Microsoft.Compute/virtualMachines/ansible-inventory-test-vm1
wget https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/azure_rm.py
chmod +x azure_rm.py
ansible -i azure_rm.py ansible-inventory-test-rg -m ping
但是会产生如下错误:
[WARNING]: * Failed to parse /media/sf_C_DRIVE/OnlyOnMyPC/ansible.rhel75.master/azure_rm.py with script plugin: Inventory script
(/media/sf_C_DRIVE/OnlyOnMyPC/ansible.rhel75.master/azure_rm.py) had an execution error: /usr/lib/python2.7/site-packages/requests/__init__.py:91:
RequestsDependencyWarning: urllib3 (1.24.1) or chardet (2.2.1) doesn't match a supported version! RequestsDependencyWarning) 'Cloud' object has no attribute 'find'
[WARNING]: * Failed to parse /media/sf_C_DRIVE/OnlyOnMyPC/ansible.rhel75.master/azure_rm.py with ini plugin:
/media/sf_C_DRIVE/OnlyOnMyPC/ansible.rhel75.master/azure_rm.py:22: Error parsing host definition ''''': No closing quotation
[WARNING]: Unable to parse /media/sf_C_DRIVE/OnlyOnMyPC/ansible.rhel75.master/azure_rm.py as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
[WARNING]: Could not match supplied host pattern, ignoring: ansible-inventory-test-rg
我并不感到惊讶,因为从技术上讲,从Internet上下载的内容无法直接使用,必须有一定的连接。
我无法理解此处遗失的链接,因为我执行的是Microsoft网站的文档,我在这里遗漏了什么吗?
Python脚本又如何知道应用特定剧本的订阅,资源组和虚拟机?
答案 0 :(得分:0)
让它起作用,也许还有比我更好的答案,但这已经使它起作用了。
export AZURE_CLIENT_ID="xxxxxxxxxxxxxxxxxxxxx"
export AZURE_SECRET="xxxxxxxxxxxxxxxxxxxxxxxx"
export AZURE_SUBSCRIPTION_ID="xxxxxxxxxxxxxxx"
export AZURE_TENANT="xxxxxxxxxxxxxxxxxxxxxxxx"
就是这样。