'Running the ansible play on particular group of servers by taking the name of groups as input dynamically

Lets say I have got inventory file like this
inventory.txt

abc
cde 
def 

[check1:children]
abc

[check2:children]
cde

[check3: children]
def

Now I will take input from user eg: check1,check3 separated by comma in a variable and then I want to run my next play on those groups check1,check3.
How can I achieve this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source