OK it works now: [ansible@repo tasks]$ vi create_users - hosts: "{{ variable_hosts | default('all') }}" remote_user: ansible become: yes tasks: - name: Loading input file users include_vars: file: users.yml - name: Make sure we have a group existing group: name: "{{item.groupname}}" state: present with_items: '{{group_list}}'
- name: Allow {{ item.groupname }} to have passwordless sudo lineinfile: dest: /etc/sudoers state: present regexp: '^%{{ item.groupname }}' line: '%{{ item.groupname }} ALL=(ALL) NOPASSWD: ALL' when: ' item.use_sudo == True' with_items: '{{group_list}}' - name: Add sudoers users to wheel group user: name: "{{ item.username }}" groups: 'jtendo' append: yes state: present createhome: yes system: yes comment: "Ansible Automation Tool" with_items: '{{user_list}}' - name: Sudoers or update sudoers file and validate lineinfile: "dest=/etc/sudoers insertafter=EOF line='{{ item.username }} ALL=(ALL) NOPASSWD: ALL' regexp='^{{ item.username }} .*' state=present" when: ' item.use_sudo == True' with_items: '{{user_list}}' -- 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 ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/149aa673-80fd-41b8-93fb-d5d8caabf61e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.