可以使用ansible变量在剧本中声明主机吗? [英] Can ansible variables be used to declare hosts in a playbook?
本文介绍了可以使用ansible变量在剧本中声明主机吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下格式的剧本:
---
- hosts: myIP
tasks:
- name: Install a yum package in Ansible example
yum:
name: ThePackageIWantToInstall
state: present
其中 myIP
和 ThePackageIWantToInstall
是变量.
当作业模板运行时,我希望 额外变量 弹出窗口中的用户能够使用:
When the job template runs, I would like the user in the extra variables popup to be able to go with:
myIP = 192.168.1.1
ThePackageIWantToInstall = nano
由于文档中没有提供通过作业模板提供变量的示例,这可能吗?
As the documentation doesn't provide an example of supplying a variable via a job template, is this possible?
推荐答案
是.
- name: Do The Thing
hosts: "{{ foo }}"
roles:
- "{{ role }}"
需要胡须和引号.
(我不使用它,但是建议将其作为编辑,谢谢...)
foo:值
这篇关于可以使用ansible变量在剧本中声明主机吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文