使用在Windows 2019上运行良好的相同Ansible代码,我在Windows 2022上遇到了致命错误。代码如下:
name: Grab the windows password we need from AWS to write to inventory
ec2_win_password:
aws_access_key: "{{ assumed_role.sts_creds.access_key }}"
aws_secret_key: "{{ assumed_role.sts_creds.secret_key }}"
security_token: "{{ assumed_role.sts_creds.session_token }}"
instance_id: "{{ created_instance.instance_ids.0 }}"
key_file: "{{ secret_key }}"
region: "{{ target_region }}"
wait: yes
register: win_password
以下是我看到的错误:
fatal: [localhost]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"access_key": "A.....",
"aws_access_key": "A.....",
"aws_ca_bundle": null,
"aws_config": null,
"aws_secret_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"debug_botocore_endpoint_logs": false,
"endpoint_url": null,
"instance_id": "i-0123456789",
"key_data": null,
"key_file": "/runner/env/tmpeol1opcf",
"key_passphrase": null,
"profile": null,
"region": "us-east-1",
"secret_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"security_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"session_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"validate_certs": true,
"wait": true,
"wait_timeout": 120
}
},
"msg": "wait for password timeout after 120 seconds"
}
ec2_win_password Ansible模块是否与Windows 2022不兼容?
1条答案
按热度按时间fquxozlt1#
问题已确定。AWS Windows 2022 EC2(AMI)默认使用EC2 Launch V2,但Windows 2016/2019使用EC2 Launch(V1)。这些参考文献描述了我所经历的:https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2launch-v2.htmlhttps://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2launch.html
如果通过代码部署Windows 2022 EC2,那么需要运行这两个PowerShell脚本:
C:/Program Files/Amazon/EC2Launch/ec2launch' reset --block
C:/Program Files/Amazon/EC2Launch/ec2launch' sysprep --shutdown --block
下面是如何使用Packer执行此操作的示例:
https://discuss.hashicorp.com/t/packer-with-aws-ec2launch/15244