demo-2 issue
ramesher opened this issue · comments
Helllo,
I am going through your udemy course and and geeting below error for demo-2. Can you please suggest.
I am installing amazon linux.
aws_key_pair.mykey: Creating...
aws_key_pair.mykey: Creation complete after 1s [id=mykey]
aws_instance.example: Creating...
aws_instance.example: Still creating... [10s elapsed]
aws_instance.example: Still creating... [20s elapsed]
aws_instance.example: Still creating... [30s elapsed]
Error: Error in function call: Call to function "file" failed: no file exists at mykey.
Hi Ramesher,
Best to use the Q&A in Udemy if you want a fast response. To fix this error you'll need to create mykey using "ssh-keygen -f mykey
"
-Edward
Hello wardviaence,
I need some help on how can we make ext4 FS and mount automatically
script.sh
#!/bin/bash
sudo mkfs -t ext4 /dev/xvdf
sudo mkdir -p /opt/sag/wm105/uat
sudo mount /dev/xvdf /opt/sag/wm105/uat
sudo echo /dev/xvdf /opt/sag/wm105/uat ext4 defaults 0 0 >> /etc/fstab
Error:
aws_instance.AUGTWLU01: Provisioning with 'remote-exec'...
aws_instance.AUGTWLU01 (remote-exec): Connecting to remote host via SSH...
aws_instance.AUGTWLU01 (remote-exec): Host: 52.91.110.131
aws_instance.AUGTWLU01 (remote-exec): User: ec2-user
aws_instance.AUGTWLU01 (remote-exec): Password: false
aws_instance.AUGTWLU01 (remote-exec): Private key: true
aws_instance.AUGTWLU01 (remote-exec): Certificate: false
aws_instance.AUGTWLU01 (remote-exec): SSH Agent: false
aws_instance.AUGTWLU01 (remote-exec): Checking Host Key: false
aws_instance.AUGTWLU01 (remote-exec): Connected!
aws_instance.AUGTWLU01 (remote-exec): mke2fs 1.42.9 (28-Dec-2013)
aws_instance.AUGTWLU01 (remote-exec): Could not stat /dev/xvdf --- No such file or directory
aws_instance.AUGTWLU01 (remote-exec): The device apparently does not exist; did you specify it correctly?
aws_instance.AUGTWLU01 (remote-exec): mount: special device /dev/xvdf does not exist
aws_instance.AUGTWLU01 (remote-exec): mke2fs 1.42.9 (28-Dec-2013)
aws_instance.AUGTWLU01 (remote-exec): Could not stat /dev/xvdg --- No such file or directory
aws_instance.AUGTWLU01 (remote-exec): The device apparently does not exist; did you specify it correctly?
aws_instance.AUGTWLU01 (remote-exec): mount: special device /dev/xvdg does not exist
aws_instance.AUGTWLU01: Creation complete after 1m46s [id=i-05c3ea88d0d0badb0]
aws_volume_attachment.ebs_volume2_attach: Creating...
aws_volume_attachment.ebs_volume1_attach: Creating...
aws_volume_attachment.ebs_volume1_attach: Still creating... [10s elapsed]
aws_volume_attachment.ebs_volume2_attach: Still creating... [10s elapsed]
aws_volume_attachment.ebs_volume1_attach: Still creating... [20s elapsed]
aws_volume_attachment.ebs_volume2_attach: Still creating... [20s elapsed]
aws_volume_attachment.ebs_volume2_attach: Creation complete after 21s [id=vai-56908924]
aws_volume_attachment.ebs_volume1_attach: Creation complete after 21s [id=vai-3507965655]
Can you please suggest how can i resolve this?
You shouldn't use the remote provisioner for this. Amazon has user-data that you can use which is executed when the instance starts, and when the volume is attached. You can use the script in jenkins-packer-demo/scripts/ which attaches a volume for jenkins. It waits until the volume is attached, checks whether there is a filesystem, and formats it if there isn't. Should work for your use-case as well.
-Edward