简体   繁体   中英

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

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:

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.
  2. I don't actually recognize that define block thing in there, maybe that's an older OpsWorks syntax?
  3. You can definitely run an Ansible playbook from Chef code, but I would probably go a little simpler than you have there. Probably just run ansible-playbook locally and aim it at localhost.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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