[英]Is it possible to use output from a script run on the packer provisioners to create tags for the generated AMI?
I am using packer to generate AMIs that are preconfigured with some programs - both installed from apt and compiled from source. 我正在使用打包程序来生成预先配置有某些程序的AMI-既从apt安装又从源代码编译。 I would like to be able to tag the generated AMI with the versions of the installed programs but I can't figure out how I would do that.
我希望能够使用已安装程序的版本标记生成的AMI,但是我不知道该怎么做。
On the provisioned machine I would run: 在配置的机器上,我将运行:
program --version
and get something like 并得到像
v1.3
The problem is I'm not able to run this until after the machine is provisioned and install so I am unable to add that information to the template file prior to running packer build. 问题是直到配置和安装机器后我才能运行此程序,因此在运行Packer构建之前,我无法将该信息添加到模板文件中。
Does anyone have any suggestions for how I can accomplish this? 有人对我如何完成此工作有任何建议吗?
for the software versions you know up ahead, you can use the tags property "amazon-ebs" builder. 对于您之前了解的软件版本,可以使用标签属性“ amazon-ebs”构建器。 if it's going to be dynamic/ install latest available version, then you can have a script that prints out the software version to a file and use the File provisioner with direction set to "download", so the file is available on the host.
如果要是动态的/安装最新的可用版本,则可以使用脚本将软件版本打印到文件中,并使用文件配置器将其方向设置为“下载”,以便文件在主机上可用。
Then you can read the file and run "aws ec2 create-tags" command to add additional tags to the ami. 然后,您可以读取文件并运行“ aws ec2 create-tags”命令以向ami添加其他标签。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.