Added new VM to existing AWS cluster

Hey everyone!

I have been working on Ansible from past few months now and I am really impressed by the active community here that takes interest in discussing and addressing various issues.

My issue is a bit complex and hence, I am putting it below. Looking forward for expert guidance/pointers to find the best way to achieve what I am trying to do. Please consider that in my approach I plan to have as much of idem-potency so that existing flow can be used.

We use Ansible to deploy our solution on AWS. There are generally 2 VMs which are being spawned in the process which does package installation, configures few daemons, install MySQL, etc. Basically, both the VMs are identical in terms of package/configuration. For those interested in knowing about the application, it is ambari based solution which deploys several Apache projects using blueprints.

Now, considering an scenario where one of the VM is unhealthy, I want to add a new node in the existing cluster for which first requirement is to install the new node which should use the existing logic to install all the packages. I am using dynamic inventory scripts for AWS to fetch and filter a specific tag which we apply while creating a new VM. Also, I am going to take input of active or healthy VM as its IP is required by new VM to spawn few cluster related resources.

My question is to how can I use the existing ansible workspace/playbooks to achieve something like this where playbooks aren’t being run on the existing active VM but only on the newly spawned VM. This way, I don’t have to rewrite any separate playbook. As per my investigation, if I set a fact for the active VM and then have someway to bypass the execution of playbooks on it, I can achieve this but need to know if someone has already worked on it or guide me in getting a better solution.

Looking forward for help/suggestions.