这是我的打包程序模板:
{
"provisioners": [{
"type": "shell",
"inline": [ "echo user-data script should create this file; ls /tmp/derp.txt" ]
}],
"builders": [{
"type": "amazon-ebs",
"region": "us-east-1",
"instance_type": "t2.micro",
"ssh_username": "ec2-user",
"ami_name": "packer-example {{timestamp}}",
"user_data_file": "user-data.text",
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "amzn2-ami-hvm-2*",
"root-device-type": "ebs"
},
"owners": ["amazon"],
"most_recent": true
}
}]
}
这是用户数据脚本(user-data.text):
#!/bin/bash
echo zzzzzzzzzz >> /tmp/derp.txt
echo zzzzzzzzzz >> /tmp/derp.txt
echo zzzzzzzzzz >> /tmp/derp.txt
echo zzzzzzzzzz >> /tmp/derp.txt
这似乎不起作用,因为在运行打包程序构建程序时出现此错误:
==> amazon-ebs:ls:无法访问/tmp/derp.txt:没有此类文件或目录
那么打包程序是在用户数据运行之前运行的吗?有没有一种方法可以让用户数据在打包程序之前运行?