如何在执行剧本时在命令行中添加多个清单文件 [英] How to add multiple inventory files in command line while executing a playbook
问题描述
我有一本包含两个不同剧本的剧本
I am having a playbook with two different plays
Sample.yml
- name : Play1
hosts: Host1
tasks:
...
- name: Play2
hosts: Host2
tasks:
...
我需要使用两个不同的主机( Host1和Host2 )运行此剧本,并且这两个不同的主机存在于清单中的两个单独的文件( Hostfile1和Hostfile2 )中/目录.
I need to run this playbook with two different hosts(Host1 and Host2) and these two different hosts are present in two separate files(Hostfile1 and Hostfile2) under inventory/ directory.
inventory/
Hostfile1
Hostfile2
.
.
HostfileN
我想知道在运行剧本时如何包括两个不同的主机文件.我知道通过在命令行中包含整个文件夹( inventory/)可以实现此目的,但是我在清单/文件夹中有很多主机文件,因此此选项将加载未使用的主机文件.
I want to know how to include two different hosts file while running the playbook. I know by including the entire folder (inventory/) in command line we can achieve this but I have lot of hosts files inside inventory/ folder so this option will load unused hosts file.
我试图像下面那样跑
ansible-playbook -i inventory/Hostfile1,Hostfile2 sample.yml
但这没用.因此,有人知道如何通过在命令行中提供多个主机文件来运行剧本吗?
But this didn't work. So, do anyone know how to run the playbook by providing multiple hosts file in command line?
推荐答案
只需多次提供-i
ansible-playbook -i inventory/Hostfile1 -i inventory/Hostfile2 sample.yml
这篇关于如何在执行剧本时在命令行中添加多个清单文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!