- name: "First things first - install latest patches"

      apt: update_cache=yes upgrade=full

    - name: "First things first - create random root password"

      apt: name={{ item }} state=present

      with_items:

        - pwgen

        - whois

    - shell: /usr/bin/pwgen -s 40 1

      register: root_password

    - shell: "/usr/bin/mkpasswd {{ root_password.stdout }} --method=SHA-512"

      register: root_crypted_password

    - user: name=root password={{ root_crypted_password.stdout }}

    - debug: msg="Password for user 'root' has been set to {{ root_password.stdout }}"