【问题标题】:Ansible does not locate localhost in hosts fileAnsible 没有在 hosts 文件中找到 localhost
【发布时间】:2020-12-16 21:07:06
【问题描述】:

我在 yaml 格式的 ansible hosts 文件中使用 localhost。每当我运行剧本时,我都会收到以下警告。 playbook 使用隐式 localhost 成功运行。为什么会发生这种情况,我该如何纠正?

➜  ec2 ansible-playbook site.yml -i inventory/hosts.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

我不清楚 ansible 为什么会报告此警告。以下是我的 hosts.yml 内容。

all:
  children:
    hosts:
      localhost:

【问题讨论】:

    标签: linux ansible devops


    【解决方案1】:

    您的库存格式不正确。如果您在all 下有一个children 键,那么您需要一个子组名称。例如:

    all:
      children:
        mygroupname:
          hosts:
            localhost:
    

    如果你没有任何子组,那么你可以写:

    all:
      hosts:
        localhost:
    

    当然,如果您唯一的主机是localhost,您就不需要清单文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多