User role

Next up, we have the user role, which we can run the following command to create:

$ ansible-galaxy init roles/user

This role creates a user for us to connect to our instance with. The defaults that can be found in roles/user/defaults/main.yml are as follows:

ansible:  username: "ansible"  password: "{{ lookup('password', 'group_vars/generated_ansible chars=ascii_letters,digits length=30') }}"  groups:    - "Users"    - "Administrators"

As you can see, here we are defining a user called ansible that has a 30-character random password. The ansible user will be a member of the Users and Administrators groups. There is a single task in roles/user/tasks/main.yml using the win_user module, which looks like:

- name: ensure that the ansible created ...

Get Learn Ansible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.