Hello Brian,

I have made some tests and it seems that hosts conditional it is not 
working for the instances that cannot login (either root or fedora, tested 
both).

First test:

If i create the group according to fedora access rules, the group for the 
centos instances it is not created:

---

- name: upgrade packages 
  hosts: all
  remote_user: fedora
  sudo: yes
  sudo_user: root
  gather_facts: false
  tasks:
    - ping:
      register: fedoralogin
      ignore_errors: yes
    - group_by: key=fedora
      when: fedoralogin|success

- name: upgrade centos instances
  hosts: all:!fedora
  remote_user: root
  roles:
    - { role: infraops/upgrade_packages}


The group_by creates the fedora group, with the correct instance. but 
 all:!fedora it is empty: FATAL: no hosts matched or all hosts have already 
failed -- aborting   (ignore_errors is set to yes)


In the same fashion if the script is changed to remote_user: root (thus 
accessing CentOS instances), the group_by 


- name: upgrade packages
  hosts: all
  remote_user: root
  gather_facts: false
  tasks:
    - ping:
      register: rootlogin
      ignore_errors: yes
    - group_by: key=fedora
      when: rootlogin|failed

- name: upgrade fedora instances
  hosts: fedora
  remote_user: fedora
  sudo: yes
  sudo_user: root
  roles:
    - { role: infraops/upgrade_packages}


fedora group_by it is not created,  (the only user that was able to login 
into the instance is root -- CentOS instance)

fatal: [X.X.X.X] => failed to transfer file to Please login as the user 
"fedora" rather than the user "root"./ping:



So i have been able to capture hosts that the remote_user can login into 
the hosts, the complement it is not captured.


Thank you!



On Monday, July 13, 2015 at 11:14:27 PM UTC-5, Brian Coca wrote:
>
> you really only need 1 group, not sure why both did not get created 
> though. 
>
> with one group you can have these play targets: 
>
> - hosts: group 
>
> - hosts: all:!group 
>
> ^ first will target all hosts in the group, the 2nd all hosts NOT in the 
> group. 
>
>
> -- 
> 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/02d65932-5e8f-4afd-bd7a-81169e713958%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to