There are several ways, the easiest is if your inventory script
provides OS info:

remote_user: "{{ansible_distibution == 'Fedora'|ternary('fedora', 'root')

If you have no info ahead of time you can test connecting and then use
group_by (example below) or the same expression above on the result
var. If using group_by you can preset group_vars/fedora =>
ansible_ssh_user: fedora

- hosts: all
  remote_user: root
  gather_facts: False
  tasks:
     - ping:
       register: rootlogin
       ignore_errors: yes

    - group_by: key=fedora
      when: rootlogin|failed


-- 
Brian Coca

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAJ5XC8nwc08X1W7ghJzZmce3Ka%2BDS3OCnokZMeZupf-jQoZ0ew%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to