简体   繁体   English

是否可以从Chef AWS / Opworks食谱中运行Ansible剧本?

[英]Is it possible to run an Ansible playbook from a Chef AWS/Opworks cookbook?

I try to figure out if it's possible to create a Chef cookbook that ssh into an Ansible server and run some Ansible cookbook from AWS Opworks on the current node 我试图弄清楚是否可以创建一个ssh到Ansible服务器的Chef食谱,并在当前节点上从AWS Opworks运行一些Ansible食谱

I think of a script that I can put in a execute like this : 我想到了可以放入这样的脚本中的脚本:

define :foobar_magento2_deploy  do
  release_path = node[:app_release_path]

  execute 'Ansible playbook' do
    command "ssh -i key ansible-server 'ansible-playbook arg1 arg2'"
  end
end

Do you think it's possible ? 您认为有可能吗? Is there some caveats ? 有一些警告吗? Hints ? 提示?

Edit from @coderanger answer: 从@coderanger答案编辑:

define :foobar_magento2_deploy  do
  release_path = node[:app_release_path]

  execute 'Ansible playbook' do
    command "git clone ansible-playbook"
    command "cd ansible-playbook"
    command "ansible-playbook -l localhost playbook.yml"
  end
end

So a couple of things: 有几件事:

  1. OpsWorks Stacks is dangerously out of date and using it should be considered highly suspect. OpsWorks Stacks危险地过时,应高度怀疑使用它。
  2. I don't actually recognize that define block thing in there, maybe that's an older OpsWorks syntax? 我实际上不认识其中define块的东西,也许那是较旧的OpsWorks语法?
  3. You can definitely run an Ansible playbook from Chef code, but I would probably go a little simpler than you have there. 您绝对可以从Chef代码中运行Ansible剧本,但我想可能会比您那里简单一些。 Probably just run ansible-playbook locally and aim it at localhost. 可能只是在本地运行ansible-playbook ,并将其定位为localhost。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM