dynamic inventory with host files

Hi,

We have a use case in which I want to run playbook on specific set of machines and same task on spot instances which belongs to same set of machines but we dont have entry into host file.

We have cluster of machines (on demand) and some spot instances. I want to deploy code to all these machines (on demand + spot instances). So when we deploy code we want to deploy to all machines in one playbook run.

I am using python script to get the public ip of those spot instances.

I am looking a way to run playbook on on demand instances and one additional task inside the playbook which will call same playbook

role/hadoop/task/release.yml


  • name: check out project from github

git: >
repo=git@github.com:Abc/abc.git
version=master
dest=/srv/jobs-prod/abc_hadoop/
force=yes
key_file=/root/.ssh/{{ GIT_PRIVATE_KEY }}
register: git_checkout
when: branch == master and branch is defined
run_once: True
serial: 4
tags:

  • git_tag

Then I have playbook as following

Fetches up to date remote branch to local machine

tasks:

This task runs on inventry list provided

  • include: role/hadoop/task/release.yml

After this first task is done I want to run same play on spot instance as second task in the same playbook. Is there any way to do this ?