Próbuję wykonać instrukcje these, aby zbudować podstawowy obraz AWS przy użyciu Packer.io. Ale to nie działa dla mnie.Problemy z utworzeniem podstawowego AWS AMI za pomocą Packer.io. Limit czasu SSH
Oto mój plik Szablon:
{
"variables": {
"aws_access_key": "",
"aws_secret_key": ""
},
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "us-east-1",
"source_ami": "ami-146e2a7c",
"instance_type": "t2.micro",
"ssh_username": "ubuntu",
"ami_name": "packer-example {{timestamp}}",
# The following 2 lines don't appear in the tutorial.
# But I had to add them because it said this source AMI
# must be launched inside a VPC.
"vpc_id": "vpc-98765432",
"subnet_id": "subnet-12345678"
}]
}
Można zauważyć, że musiałem zboczyć z instrukcjami dodając dwie linie na dole (na VPC i podsieci). To dlatego, że ciągle otrzymuję następujący błąd:
==> amazon-ebs: Error launching source instance: The specified instance type
can only be used in a VPC. A subnet ID or network interface
ID is required to carry out the request.
(VPCResourceNotSpecified)
Że VPC i podsieć są tymczasowymi, które ręcznie musiałem utworzyć. Ale dlaczego miałbym to robić? Dlaczego program pakujący nie tworzy, a następnie usuwa je tak, jak widzę, tworzy tymczasową grupę zabezpieczeń i parę kluczy?
Co więcej, nawet po dodaniu tych dwóch linii nie uda się utworzyć interfejsu AMI, ponieważ otrzymuje on limit czasu SSH. Czemu? Nie mam problemu z ręcznym SSHingiem do innych instancji w tej VPC. Tymczasowa instancja pakera ma InstanceState=Running
, StatusChecks=2/2
i SecurityGroup, która zezwala na SSH z całego świata.
Zobacz wyjście debugowania polecenia packer poniżej:
$ packer build -debug -var 'aws_access_key=MY_ACCESS_KEY' -var 'aws_secret_key=MY_SECRET_KEY' packer_config_basic.json
Debug mode enabled. Builds will not be parallelized.
amazon-ebs output will be in this color.
==> amazon-ebs: Inspecting the source AMI...
==> amazon-ebs: Pausing after run of step 'StepSourceAMIInfo'. Press enter to continue.
==> amazon-ebs: Creating temporary keypair: packer 99999999-8888-7777-6666-555555555555
amazon-ebs: Saving key for debug purposes: ec2_amazon-ebs.pem
==> amazon-ebs: Pausing after run of step 'StepKeyPair'. Press enter to continue.
==> amazon-ebs: Creating temporary security group for this instance...
==> amazon-ebs: Authorizing SSH access on the temporary security group...
==> amazon-ebs: Pausing after run of step 'StepSecurityGroup'. Press enter to continue.
==> amazon-ebs: Launching a source AWS instance...
amazon-ebs: Instance ID: i-12345678
==> amazon-ebs: Waiting for instance (i-12345678) to become ready...
amazon-ebs: Private IP: 10.0.2.204
==> amazon-ebs: Pausing after run of step 'StepRunSourceInstance'. Press enter to continue.
==> amazon-ebs: Waiting for SSH to become available...
==> amazon-ebs: Timeout waiting for SSH.
==> amazon-ebs: Pausing before cleanup of step 'StepRunSourceInstance'. Press enter to continue.
==> amazon-ebs: Terminating the source AWS instance...
==> amazon-ebs: Pausing before cleanup of step 'StepSecurityGroup'. Press enter to continue.
==> amazon-ebs: Deleting temporary security group...
==> amazon-ebs: Pausing before cleanup of step 'StepKeyPair'. Press enter to continue.
==> amazon-ebs: Deleting temporary keypair...
==> amazon-ebs: Pausing before cleanup of step 'StepSourceAMIInfo'. Press enter to continue.
Build 'amazon-ebs' errored: Timeout waiting for SSH.
==> Some builds didn't complete successfully and had errors:
--> amazon-ebs: Timeout waiting for SSH.
==> Builds finished but no artifacts were created.
Po uruchomieniu programu pakującego sprawdzam poprawność w szablonie, pojawia się błąd w komentarzach mieszania. Rzeczywiście, komentarze nie są częścią specyfikacji json. –
kmarsh