首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >azure_rm不可用插件无法解析动态库存

azure_rm不可用插件无法解析动态库存
EN

Stack Overflow用户
提问于 2022-02-24 17:54:43
回答 1查看 1.5K关注 0票数 2

我无法为Azure创建一个不可见的动态库存。我得到以下错误:

代码语言:javascript
运行
复制
bash-5.1# ansible-inventory -i inventory_azure_rm.yaml --graph -vvv
ansible-inventory [core 2.12.2]
  config file = /playbook/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-inventory
  python version = 3.9.7 (default, Nov 24 2021, 21:15:59) [GCC 10.3.1 20211027]
  jinja version = 3.0.3
  libyaml = False
Using /playbook/ansible.cfg as config file
host_list declined parsing /playbook/inventory_azure_rm.yaml as it did not pass its verify_file() method
toml declined parsing /playbook/inventory_azure_rm.yaml as it did not pass its verify_file() method
[WARNING]:  * Failed to parse /playbook/inventory_azure_rm.yaml with script plugin: problem running /playbook/inventory_azure_rm.yaml --list ([Errno 13] Permission denied:
'/playbook/inventory_azure_rm.yaml')
  File "/usr/lib/python3.9/site-packages/ansible/inventory/manager.py", line 290, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/usr/lib/python3.9/site-packages/ansible/plugins/inventory/script.py", line 150, in parse
    raise AnsibleParserError(to_native(e))
[WARNING]:  * Failed to parse /playbook/inventory_azure_rm.yaml with auto plugin: name 'client_secret' is not defined
  File "/usr/lib/python3.9/site-packages/ansible/inventory/manager.py", line 290, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/usr/lib/python3.9/site-packages/ansible/plugins/inventory/auto.py", line 58, in parse
    plugin.parse(inventory, loader, path, cache=cache)
  File "/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/inventory/azure_rm.py", line 219, in parse
    self._credential_setup()
  File "/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/inventory/azure_rm.py", line 240, in _credential_setup
    self.azure_auth = AzureRMAuth(**auth_options)
  File "/root/.ansible/collections/ansible_collections/azure/azcollection/plugins/module_utils/azure_rm_common.py", line 1522, in __init__
    self.azure_credential_track2 = client_secret.ClientSecretCredential(client_id=self.credentials['client_id'],
[WARNING]:  * Failed to parse /playbook/inventory_azure_rm.yaml with yaml plugin: Plugin configuration YAML file, not YAML inventory
  File "/usr/lib/python3.9/site-packages/ansible/inventory/manager.py", line 290, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/usr/lib/python3.9/site-packages/ansible/plugins/inventory/yaml.py", line 112, in parse
    raise AnsibleParserError('Plugin configuration YAML file, not YAML inventory')
[WARNING]:  * Failed to parse /playbook/inventory_azure_rm.yaml with ini plugin: Invalid host pattern 'plugin:' supplied, ending in ':' is not allowed, this character is reserved to provide a port.
  File "/usr/lib/python3.9/site-packages/ansible/inventory/manager.py", line 290, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/usr/lib/python3.9/site-packages/ansible/plugins/inventory/ini.py", line 136, in parse
    raise AnsibleParserError(e)
[WARNING]: Unable to parse /playbook/inventory_azure_rm.yaml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
@all:
  |--@ungrouped:

inventory_azure_rm.yaml文件是:

代码语言:javascript
运行
复制
plugin: azure.azcollection.azure_rm
auth_source: credential_file
plain_host_names: yes
include_vm_resource_groups:
  - <redacted>
keyed_groups:
  - key: tags.applicationRole
    separator: ""

ansible.cfg文件是:

代码语言:javascript
运行
复制
[defaults]
inventory = inventory_azure_rm.yaml

[inventory]
enable_plugins = host_list, script, auto, yaml, ini, toml

Ansible Azure收藏版

代码语言:javascript
运行
复制
bash-5.1# ansible-galaxy collection list

# /root/.ansible/collections/ansible_collections
Collection         Version
------------------ -------
azure.azcollection 1.11.0

如果能帮我解决这个问题,我将不胜感激。谢谢。

更新:

  • 固定了inventory_azure_rm.yaml文件权限。bash-5.1# ls -la inventory_azure_rm.yaml -rw-r--r-1根根2002月24日17:27

  • 更新了问题描述的错误堆栈跟踪,再次运行该命令.

Update2:

Azure credentials文件如下所示:

代码语言:javascript
运行
复制
bash-5.1# cat ~/.azure/credentials
[default]
subscription_id=<redacted>
client_id=<redacted>
secret=<redacted>
tenant=<redacted>
cloud_environment=AzureCloud
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-25 13:08:39

最后,我设法解决了解析动态库存的问题。我做了以下工作:

代码语言:javascript
运行
复制
pip install -r https://raw.githubusercontent.com/ansible-collections/azure/dev/requirements-azure.txt && \
ansible-galaxy collection install azure.azcollection:1.11.0

我改变了两件事:

  • 反转安装集合及其依赖项的顺序。首先,我需要安装dependencies.
  • Install,然后安装azure.azcollection --它的azure.azcollection依赖项--来自requirements.txt的依赖项--随集合本身而来,而不是从Github.

执行。

这是工作的代码:

代码语言:javascript
运行
复制
ansible-galaxy collection install azure.azcollection:1.11.0 && \
pip install -r ~/.ansible/collections/ansible_collections/azure/azcollection/requirements-azure.txt 

requirements.txt文件与https://raw.githubusercontent.com/ansible-collections/azure/dev/requirements-azure.txt的GitHub文件和~/.ansible/collections/ansible_collections/azure/azcollection/requirements-azure.txt的本地requirements.txt文件的区别在于azure-mgmt-network包版本。在线版本是19.1.0,本地版本是12.0.0

代码语言:javascript
运行
复制
bash-5.1# diff -w requirements-azure.txt ~/.ansible/collections/ansible_collections/azure/azcollection/requirements-azure.txt
--- requirements-azure.txt
+++ /root/.ansible/collections/ansible_collections/azure/azcollection/requirements-azure.txt
@@ -19,7 +19,7 @@
 azure-mgmt-monitor==3.0.0
 azure-mgmt-managedservices==1.0.0
 azure-mgmt-managementgroups==0.2.0
-azure-mgmt-network==19.1.0
+azure-mgmt-network==12.0.0
 azure-mgmt-nspkg==2.0.0
 azure-mgmt-privatedns==0.1.0
 azure-mgmt-redis==5.0.0
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71256239

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档