Define Multiple remote user in Ansible -
i trying run playbook on multiple ec2 instances running different operating systems.to ssh system ansible needs use remote username . in aws cloud, instance os such redhat , amazon linux have username ec2-user login instances running ubuntu need use ubuntu username. please me figure out way automate process , me understand how can define multiple remote users in playbook.
now 1 way of doing can define in host file or in host_vars file using dynamic inventory generating ip's of instances dynamically based on tag value.
i have tried using conditional statement in main playbook file guess restricted use in main file.
define tags in instances when created, example
ostype = redhat
when gather ec2 facts, can see there group named
"tag_ostype_redhat": [ "server1", "server2", ],
now, can create file called group_vars/tag_ostype_redhat/main.yml
, add required username in there.
Comments
Post a Comment