如何通过命令行运行具有来自互联网的源的Ansible playbook?

huangapple go评论67阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年6月16日 15:33:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76487909.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定