Running the playbook

Before we run the playbook, we need to add the following to group_vars/common.yml:

environment_name: "windows_example"ec2_region: "eu-west-1"

The host inventory file called production should contain the following:

[ec2_instance][ec2_instance:vars]ansible_connection=winrmansible_user="Administrator"ansible_password="{{ lookup('password', 'group_vars/generated_administrator chars=ascii_letters,digits length=30') }}"ansible_winrm_server_cert_validation=ignore

As you can see, we are using the WinRM connector to connect to our Windows instance using the administrator username and the password we set when running the user data script when launching the instance. The site.yml file should have the following content:

---- name: ...

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.