英文:
How to run Ansible playbook with source from internet by command line?
问题
我有一个名为 playbook.yml
的剧本,位于一个带有URL的网站上。是否可以通过命令行界面(CLI)运行此剧本,而无需对本地剧本进行更改?
通常,我使用命令 ansible-playbook /local/path/to/playbook
来运行一个剧本。
我不想更改本地剧本的任何内容来完成这个任务。我需要运行附加的剧本到一个环境中,并且没有权限更改该环境。
英文:
I have a playbook named playbook.yml
located on a website with a URL. Is it possible to run this playbook via the command line interface (CLI), without having to make changes to the local playbook?
Normally, I use the command ansible-playbook /local/path/to/playbook
to run a playbook.
I do not want to change any of local playbook to finish this. I need to run additional playbook to an environment and do not have permission to change that environment.
答案1
得分: 1
你应该能够在假设机器上安装了curl
/wget
(或其他一些获取playbook的方式)的情况下使用STDIN
。
curl https://my.server.com/playbook.yml | ansible-playbook -i inventory/ /dev/stdin
wget -O - https://my.server.com/playbook.yml | ansible-playbook -i inventory/ /dev/stdin
如果你的playbook使用用户输入提示,这种方法可能不太适用。不确定。
英文:
You should be able to use STDIN
for this assuming curl
/wget
is installed on the machine (or some other way to fetch the playbook).
curl https://my.server.com/playbook.yml | ansible-playbook -i inventory/ /dev/stdin
wget -O - https://my.server.com/playbook.yml | ansible-playbook -i inventory/ /dev/stdin
This might not work nicely with prompting for user-input if your playbook uses that. Not sure.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论