azure - 使用 Azure 动态清单时 Playbook 失败
问题描述
正如标题所示,我正在使用 Azure 动态清单文件,并且在针对收集的清单运行剧本时遇到问题。
我正在使用 Ansible 2.9.1 并使用此处找到的说明来设置清单文件。
$ ansible --version
ansible 2.9.1
config file = None
configured module search path = ['/home/myuser/.ansible/plugins/modules',
'/usr/share/ansible/plugins/modules']
ansible python module location = /home/myuser/.local/lib/python3.6/site-packages/ansible
executable location = /home/myuser/.local/bin/ansible
python version = 3.6.9 (default, Sep 11 2019, 16:40:19) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
我的库存文件:
plugin: azure_rm
include_vm_resource_groups:
- mytestrg
auth_source: cli
cloud_environment: AzureUSGovernment
hostvar_expressions:
ansible_connection: "'winrm'"
ansible_user: "'azureuser"
ansible_password: "'Password1'"
ansible_winrm_server_cert_validation: "'ignore'"
keyed_groups:
- prefix: some_tag
key: tags.sometag | default('none')
exclude_host_filters:
- powerstate != 'running'
使用清单文件时,简单的临时命令(如 ping)会成功。我无法开始工作的是针对它运行一个剧本。
我的剧本:
- hosts: all
name: Run whoami
tasks:
- win_command: whoami
register: whoami_out
- debug:
var: whoami_out
我用来运行剧本的命令:
ansible-playbook -i ./inventory_azure_rm.yaml whoami.yaml
无论我将剧本针对的主机是什么,它都失败了:
[警告]:无法匹配提供的主机模式,忽略:playbooks/whoami.yaml
[警告]:没有匹配的主机,无事可做
关于如何克服这个问题的任何建议?我感谢任何帮助!
解决方案
推荐阅读
- sql - PostgreSQL json 提取
- html - 在 routerLinkActive="active" 上更改按钮内子垫图标的颜色
- mongodb - MongoDB聚合 - 将字符串数组减少为对象,键和值作为数组中字符串的出现次数
- c++ - 您可以在 C++ 的 for 循环中使用 2 种不同类型的变量吗?
- scala - 使用 Alpakka S3 连接器的多个下载请求
- css - 在css网格中同步切换列
- dart - Dart:实例无法访问静态字段?
- go - 停止阻塞的 goroutine
- nginx - 无法使用 nginx 提供静态内容。获取 403 禁止错误
- maven - 使用 maven 从子 pom 中的父 pom 扩展属性