The Chef Test Kitchen EC2 driver can connect to Windows instances two ways.
Using a custom image with known admin account credentials
When we use a custom built image which has a local administrator account with known username and password, specify it in the kitchen.yml file.
driver:
name: ec2
aws_ssh_key_id: MY_SSH_KEY_NAME
...
platforms:
- name: windows-2019
driver:
image_id: "ami-MY_CUSTOM_AMI_ID"
instance_type: t3.medium
security_group_ids: ['sg-MY_SECURITY_GROUP_ID1','sg-MY_SECURITY_GROUP_ID2']
transport:
name: winrm
elevated: true # Required for the installation of some Windows features
connection_timeout: 60
connection_retries: 10
username: MY_ADMIN_USERNAME
password: MY_ADMIN_PASSWORD
Standard Amazon AMI with random password
When we use an Amazon standard Windows AMI, the kitchen-ec2 driver needs to retrieve the random password by using the SSH key the server was launched with.
driver:
name: ec2
aws_ssh_key_id: MY_SSH_KEY_NAME
...
platforms:
- name: windows-2019
driver:
image_id: "ami-MY_CUSTOM_AMI_ID"
instance_type: t3.medium
security_group_ids: ['sg-MY_SECURITY_GROUP_ID1','sg-MY_SECURITY_GROUP_ID2']
transport:
name: winrm
elevated: true # Required for the installation of some Windows features
connection_timeout: 60
connection_retries: 10
username: Administrator
ssh_key: MY_SSH_KEY_PATH/MY_SSH_KEY_FILE.pem
If the ssh key location is not specified in the transport section of the platform in the kitchen.yml file, we get the error message:
Failed to complete #converge action: [password is a required option] on …
Troubleshooting
When you get the error message:
Failed to complete #converge action: [password is a required option] on …
- Make sure the transport section of the platform in the kitchen.yml file contains the line
ssh_key: MY_SSH_KEY_PATH/MY_SSH_KEY_FILE.pem
- It is possible, that the saved password of the Windows instance in the
.kitchen/...yml
file is not valid anymore. Destroy the instance and execute thekitchen converge
command again.