为什么 Ansible 无法解析我的 azure 动态清单配置文件?
Why isn't Ansible able to parse my azure dynamic inventory config file?
我正在尝试为 Ansible 设置动态清单以与 Azure 一起使用,但我收到一些消息,因为 Ansible 无法解析我的 yaml 文件。
到目前为止我做了什么:
Created Azure Service Principal and added credentials to /home/user/.azure/credentials (I know they recommend placing them in
/home/.azure/credentials and I tried that, but it seems that my
Ansible looks for them in the /home/user directory.
I placed both the python plugin (the original, unedited plugin) and its yaml config file in /etc/ansible/inventory_plugins. The config
file looks like this:
plugin: azure_rm
include_vm_resource_groups:
- vm_1197_rg
auth_source: auto
- Testing the functionality with: ansible all -m ping -i ./myazure_rm.yml
输出:
ansible 2.8.1 config file = /etc/ansible/ansible.cfg configured
module search path = [u'/root/.ansible/plugins/modules',
u'/usr/share/ansible/plugins/modules'] ansible python module
location = /usr/lib/python2.7/site-packages/ansible executable
location = /bin/ansible python version = 2.7.5 (default, Apr 9
2019, 14:30:50) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] Using
/etc/ansible/ansible.cfg as config file Skipping due to inventory
source not existing or not being readable by the current user azure_rm
declined parsing /etc/ansible/inventory_plugins/myazure_rm.yml as it
did not pass it's verify_file() method [WARNING]: Unable to parse
/etc/ansible/inventory_plugins/myazure_rm.yml 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'
似乎我在 运行 命令时使用了错误的扩展名。我使用的是 .yml 而不是像实际调用文件那样使用 .yaml。
'当使用 azure_rm
清单插件时,清单文件的 NAME 实际上对解析很重要。
它必须以下列之一结尾:
azure_rm.yml
azure_rm.yaml
例如,以下任何文件名都是有效的:
inventory_azure_rm.yml
inventoryazure_rm.yml
why_is_this_a_good_idea_azure_rm.yml
如果文件不是以 azure_rm.yml
结尾,您将收到如下一般错误消息:
[WARNING]: * Failed to parse $FILENAME with auto plugin: inventory config '$FILENAME ' could not be verified by plugin 'azure_rm'
我正在尝试为 Ansible 设置动态清单以与 Azure 一起使用,但我收到一些消息,因为 Ansible 无法解析我的 yaml 文件。
到目前为止我做了什么:
Created Azure Service Principal and added credentials to /home/user/.azure/credentials (I know they recommend placing them in /home/.azure/credentials and I tried that, but it seems that my Ansible looks for them in the /home/user directory.
I placed both the python plugin (the original, unedited plugin) and its yaml config file in /etc/ansible/inventory_plugins. The config file looks like this:
plugin: azure_rm
include_vm_resource_groups:
- vm_1197_rg
auth_source: auto
- Testing the functionality with: ansible all -m ping -i ./myazure_rm.yml
输出:
ansible 2.8.1 config file = /etc/ansible/ansible.cfg configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /bin/ansible python version = 2.7.5 (default, Apr 9 2019, 14:30:50) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] Using /etc/ansible/ansible.cfg as config file Skipping due to inventory source not existing or not being readable by the current user azure_rm declined parsing /etc/ansible/inventory_plugins/myazure_rm.yml as it did not pass it's verify_file() method [WARNING]: Unable to parse /etc/ansible/inventory_plugins/myazure_rm.yml 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'
似乎我在 运行 命令时使用了错误的扩展名。我使用的是 .yml 而不是像实际调用文件那样使用 .yaml。
'当使用 azure_rm
清单插件时,清单文件的 NAME 实际上对解析很重要。
它必须以下列之一结尾:
azure_rm.yml
azure_rm.yaml
例如,以下任何文件名都是有效的:
inventory_azure_rm.yml
inventoryazure_rm.yml
why_is_this_a_good_idea_azure_rm.yml
如果文件不是以 azure_rm.yml
结尾,您将收到如下一般错误消息:
[WARNING]: * Failed to parse $FILENAME with auto plugin: inventory config '$FILENAME ' could not be verified by plugin 'azure_rm'