【发布时间】:2016-07-19 03:45:32
【问题描述】:
首先,我看过很多类似标签的帖子,但没有任何效果.. 我有一个现有的 Ansible 主机,我成功地使用它来将软件部署到其他服务器。我想使用 Vagrant 设置一个测试环境来运行我现有的剧本而不做任何更改。
我在不同的服务器上安装了 Ansible 和 Vagrant,并复制了 playbook、inventory 和 group/host vars 文件。
但是,当我使用 Ansible(远程)配置程序运行 vagrant up 调用 Vagrant 主机上的 playbook 时,它会在针对主机运行时给出以下消息:localhost
PLAY [Set fact for later use] **************************************************
skipping: no hosts matched
剧本(摘录)如下所示:
- name: Set fact for later use
hosts: localhost
tasks:
- name: set number of hosts for later use
set_fact: num_hosts="{{ groups[tagname] | length }}"
我也试过了:
- name: Set fact for later use
hosts: 127.0.0.1
connection: local
tasks:
- name: set number of hosts for later use
set_fact: num_hosts="{{ groups[tagname] | length }}"
我的静态清单(提取)如下所示:
'# Ungrouped hosts, specify before any group headers.
localhost ansible_connection=local
我在剧本和清单文件中尝试了动态清单和localhost/127.0.0.1 的各种组合,但在 Vagrant 主机上总是跳过该步骤。
【问题讨论】: