Azure Custome_Data for separate VMs

What would be the right way to use to custom data sections? I tried the below and a few more approaches but it seems I hit the “wall”. The first one (right side) would install ansible, the second one left side would install nano on all VMs. Any guidance will be greatly appreciated. The files work separately but how can I put all together and run on different machines.

custom_data = count.index == 0 ? filebase64(“master_customdata.tpl”) : filebase64(“customdata.tpl”)