I am using dynamic inventory and i didn't find anything about how to run a playbook with more than one user. When i configure a specific remote user in my ansible.cfg file, the ssh connection works only for the OS types that uses that specific user. I am not even sure where should it be configured? In the playbook itself i have configured to go to a different OS types. I know it works with static inventory file as well, but i have no idea how to configure it with dynamic inventory. I am using ansible galaxy role to run as ansible playbook: https://galaxy.ansible.com/geerlingguy/docker I tried configuring group_vars but it doesn't work. I need to be able to ssh to all of the instances i have using different users, using the same playbook.
This is how my dynamic inventory looks like:
plugin: aws_ec2
regions:
- "us-east-1"
keyed_groups:
- key: tags.Ansible
- key: tags.Name
filters:
tag:Ansible:
- ubuntu
- redhat
compose:
ansible_host: public_ip_address
This is the playbook i run:
---
# docker.yml
- name: Use a galaxy role to install docker
hosts: "all"
become: true
roles:
- role: "geerlingguy.docker"
tags: ["docker"]