I want to search for available groups in the server and print the groups 
doesn't exist.

- name: Checking if group exist
  lineinfile:
    dest: /etc/group
    line: "{{ item.group }}"
  check_mode: yes
  register: verify_group
  loop: "{{ UserAddList.add_users }}"
  failed_when: verify_group is not changed
  no_log: true

This is the input file I'm using 

---
add_users:
- name: test1_123
  group: test2_123456
  additional_groups:
  - test2
  password: test1_newcdsaf
  sudo_entry: 'ALL=(ALL)  NOPASSWD: ALL'
- name: test1_1234
  group: test2
  additional_groups:
  - group1
  password: test1_newcdsaf
  sudo_entry: 'ALL=(ALL)  NOPASSWD: ALL'

I want to display message to user the groups that are not present and fail 
the job. Please suggest

Thanks in advance. 

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/873b05c1-3f0f-406d-b0ca-93749af3bb11%40googlegroups.com.

Reply via email to