Hey guys, I'm following 
this https://serversforhackers.com/running-ansible-programmatically but 
I've built a RESTful API around it using cherrypy. 

I generate an inventory file and try to set the "host_list" variable in the 
ansible.playbook.PlayBook object but it doesn't seem like this is working.

Here's the snippet of code. The playbook I'm just passing in the string 
location of it, but the inventoryfile is generated according to the link 
above. I'm currently not removing it and I can look in /tmp and find the 
file and see that it's correct.

    class playbookrunner:

      stats = callbacks.AggregateStats()
      playbook_cb = callbacks.PlaybookCallbacks(verbose=1)
      runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=1)

      def __init__(self, inventoryfile, playbookfile):
        self.inventoryfile = inventoryfile
        self.playbookfile = playbookfile

      def execute(self):
        pb = ansible.playbook.PlayBook(
            playbook=self.playbookfile,
            host_list=self.inventoryfile.name,
            stats=playbookrunner.stats,
            callbacks=playbookrunner.playbook_cb,
            runner_callbacks=playbookrunner.runner_cb,
        )
        return pb.run()


When I try to run this I just get "skipping: no hosts matched"

Any help here? Is it possible to generate an inventory file and actually 
use it?


-- 
*The information transmitted is intended only for the person or entity to 
which it is addressed and may contain confidential and/or privileged 
material.  Any review, retransmission, dissemination or other use of, or 
taking of any action in reliance upon, this information by persons or 
entities other than the intended recipient is prohibited.   If you received 
this in error, please contact the sender and delete the material from any 
computer.*

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/828bc2bf-0c03-453c-abb7-4b15225bc67b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to