我正尝试在剧本中为清单文件中提到的主机执行任务,这些主机归为“ Jira”,但由于某些原因,我的团队未被确定可以选择。有关文件的内容,请看下面。
如何使用清单中的所有主机运行剧本中提到的所有任务?
我有一个包含以下内容的清单文件:Hosts.yml
all: # the all group contains all hosts
hosts:
ansible:
ansible_host: #{ansible-controller}
ansible_user: root
crowd:
ansible_host: #{crowd}
ansible_user: root
jira:
ansible_host1: 53.31.54.56
ansible_host2: 53.31.54.55
我有包含内容的剧本:
---
- name: Install Jira Application
hosts: jira
gather_facts: true
become: true
remote_user: root
roles:
- ansible-preparation
#- jira-applicationsetup
我总是收到以下错误消息:
root@sedcagse0550:/usr/Anil/InfraAutomation/gsep-infrastructure-automation : ansible-playbook jira-fullinstall.yml
[WARNING]: Could not match supplied host pattern, ignoring: jira
PLAY [Install Jira Application] *************************************************************
skipping: no hosts matched
PLAY RECAP **********************************************************************************
如何对清单文件中提到的所有主机执行所有任务?
答案 0 :(得分:0)
如果我理解正确,则您的库存文件应如下所示:
ansible: # Group Name
hosts:
ansible_host: #Host name
ansible_user: root # Host Variable
crowd:
hosts:
ansible_host: #{crowd}
ansible_user: root
jira:
hosts:
ansible_host1:
ansible_host: 53.31.54.56
ansible_host2:
ansible_host: 53.31.54.55`
Please refer this link for detailed formatting about yaml based inventory
答案 1 :(得分:0)
您应使用库存参数(-i)运行ansible-playbook,如下所示:
ansible-playbook -i Hosts.yml jira-fullinstall.yml
否则,ansible检查默认清单文件位置为“ / etc / ansible / hosts”。
如果您的Hosts.yml已经在该位置,请检查您的清单文件。在Ansible 2.7 User Guide中,YAML库存文件如下所示:
all:
jira:
hosts:
53.31.54.56:
53.31.54.55: