---
- name: Add OS user
  user:
    name="{{ admin_user }}" comment="Privileged Administrator user"
    shell=/bin/bash
    group=sudo

- name: Enable default repos
  apt_repository: repo='deb http://ftp.debian.org/debian/ jessie main' state=present
  when: ansible_distribution == "Debian"

- name: Update packages cache
  apt: update_cache=yes

- name: Install sudo package
  apt: name=sudo state=latest

- name: sudo without password
  lineinfile: "dest=/etc/sudoers state=present regexp='^%sudo ALL' line='%sudo ALL=(ALL) NOPASSWD: ALL'"

- name: Set up authorized_keys for the admin user
  authorized_key: user="{{ admin_user }}"
                  key="{{ item }}"
  with_file:
    - keys/administrators

---
- name: Add OS user
  user:
    name="{{ admin_user }}" comment="Privileged Administrator user"
    shell=/bin/bash
    group=sudo

- name: Enable default repos
  apt_repository: repo='deb http://ftp.debian.org/debian/ jessie main' state=present
  when: ansible_distribution == "Debian"

- name: Update packages cache
  apt: update_cache=yes

- name: Install sudo package
  apt: name=sudo state=latest

- name: sudo without password
  lineinfile:
    dest: /etc/sudoers
    state: present
    regexp: '^%sudo ALL='
    line: '%sudo ALL=(ALL) NOPASSWD: ALL'
    validate: 'visudo -cf %s'

- name: Set up authorized_keys for the admin user
  authorized_key: user="{{ admin_user }}"
                  key="{{ item }}"
  with_file:
    - keys/administrators

Add validate for lineinfile module
Add validate for lineinfile module
