在AWS上使用带有Ansible的Packer看似随机超时

时间:2017-04-06 19:28:21

标签: amazon-web-services ansible packer

我使用PackerAnsible烘焙AWS AMI。似乎在大约6分钟左右的Packer运行后,该过程将失败。除了花了大约6分钟,我似乎无法找到关于发生了什么的合理解释。 Ansbile剧本将在整个过程中的不同点失败,但总是在我启动Packer后大约6分钟。

遇到此问题时,我总是收到Ansible错误。我得到Timeout (12s) waiting for privilege escalation prompt:Connection to 127.0.0.1 closed.\r\n

有没有办法延长与playbook或Packer构建器相关的超时?

Packer文件内容:

{
  "provisioners": [{
    "type": "ansible",
    "playbook_file": "../ansible/nexus.yml"
  }],

  "builders": [{
    "type": "amazon-ebs",
    "region": "us-east-2",
    "source_ami_filter": {
        "filters": {
            "virtualization-type": "hvm",
            "name": "amzn-ami-hvm*-gp2",
            "root-device-type": "ebs"
        },
        "owners": ["137112412989"],
        "most_recent": true
    },
    "instance_type": "t2.medium",
    "ami_virtualization_type": "hvm",
    "ssh_username": "ec2-user",
    "ami_name": "Nexus (Latest Amazon Linux Base) {{isotime \"2006-01-02T15-04-05-06Z\"| clean_ami_name}}",
    "ami_description": "Nexus AMI",
    "run_tags": {
        "AmiName": "Nexus",
        "AmiCreatedBy": "Packer"
    },
    "tags": {
        "Name": "Nexus",
        "CreatedBy": "Packer"
    }
  }]
}

1 个答案:

答案 0 :(得分:0)

我解决了这个问题,在Ansible配置文件中添加了以下参数:

[defaults]
forks = 1

[ssh_connection]
ssh_args = -o ControlMaster=no -o ControlPath=none -o ControlPersist=no
pipelining = false

希望它有所帮助。