添加 "shell-local" post-处理器但 运行 很多次
Add a "shell-local" post-processor but run many times
我正在使用 Packer 0.9.0 并作为 post-处理器 "shell-local" 到 运行 一个脚本。问题是每个生成的工件(.vmdk、.vmx 等)的 shell 脚本 运行 我不知道原因。
源代码:
{
"variables": {
"root_password": "pass",
"output_directory": "output/centos6-aufs-master-slave-vmw"
},
"builders": [
{
"type": "vmware-iso",
"name": "centos6-aufs-master-slave-vmw",
"iso_url": "http://myrepo/software/isos/CentOS-6.5-x86_64-minimal.iso",
"iso_checksum": "ee3c7e96ad0a33d8af787acbf6d54e56",
"iso_checksum_type": "md5",
"ssh_username": "root",
"ssh_password": "{{user `root_password`}}",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"shutdown_command": "shutdown -P now",
"boot_command": [
"<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/al-master-slave-ks.cfg<enter><wait>"
],
"boot_wait": "10s",
"disk_size": 51200,
"disk_type_id": "0",
"format": "ovf",
"guest_os_type": "rhel6-64",
"tools_upload_flavor": "linux",
"http_directory": "http",
"output_directory": "{{user `output_directory`}}",
"vmx_data": {
"memsize": "2048",
"numvcpus": "1",
"cpuid.coresPerSocket": "1"
}
}
],
"post-processors": [
{
"type": "shell-local",
"only": ["centos6-aufs-master-slave"],
"inline": ["cd scripts","./vmx-to-ova.sh"],
"environment_vars": ["PACKER_OUTPUT_DIRECTORY=/home/myuser/projects/IT/packer-project/output/centos6-aufs-master-slave-vmw"]
}
]
}
您的 post-处理器将为每个工件 运行 一次。使用 artifice post-processor 覆盖工件列表,强制 shell-local post-processor 使用选定的工件。
例如:
"post-processors": [
[
{
"type": "artifice",
"only": ["centos6-aufs-master-slave-vmw"],
"files": ["{{user `output_vmw_directory`}}/centos6-aufs-master-slave-vmw.vmx"]
},
{
"type": "shell-local",
"only": ["centos6-aufs-master-slave-vmw"],
"scripts": [
"scripts/vmx-to-ova.sh"
],
"environment_vars": ["PACKER_OUTPUT_DIRECTORY=/home/myuser/projects/IT/packer-project/centos6-aufs-master-slave/{{user `output_vmw_directory`}}"]
}
]
]
我正在使用 Packer 0.9.0 并作为 post-处理器 "shell-local" 到 运行 一个脚本。问题是每个生成的工件(.vmdk、.vmx 等)的 shell 脚本 运行 我不知道原因。
源代码:
{
"variables": {
"root_password": "pass",
"output_directory": "output/centos6-aufs-master-slave-vmw"
},
"builders": [
{
"type": "vmware-iso",
"name": "centos6-aufs-master-slave-vmw",
"iso_url": "http://myrepo/software/isos/CentOS-6.5-x86_64-minimal.iso",
"iso_checksum": "ee3c7e96ad0a33d8af787acbf6d54e56",
"iso_checksum_type": "md5",
"ssh_username": "root",
"ssh_password": "{{user `root_password`}}",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"shutdown_command": "shutdown -P now",
"boot_command": [
"<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/al-master-slave-ks.cfg<enter><wait>"
],
"boot_wait": "10s",
"disk_size": 51200,
"disk_type_id": "0",
"format": "ovf",
"guest_os_type": "rhel6-64",
"tools_upload_flavor": "linux",
"http_directory": "http",
"output_directory": "{{user `output_directory`}}",
"vmx_data": {
"memsize": "2048",
"numvcpus": "1",
"cpuid.coresPerSocket": "1"
}
}
],
"post-processors": [
{
"type": "shell-local",
"only": ["centos6-aufs-master-slave"],
"inline": ["cd scripts","./vmx-to-ova.sh"],
"environment_vars": ["PACKER_OUTPUT_DIRECTORY=/home/myuser/projects/IT/packer-project/output/centos6-aufs-master-slave-vmw"]
}
]
}
您的 post-处理器将为每个工件 运行 一次。使用 artifice post-processor 覆盖工件列表,强制 shell-local post-processor 使用选定的工件。 例如:
"post-processors": [
[
{
"type": "artifice",
"only": ["centos6-aufs-master-slave-vmw"],
"files": ["{{user `output_vmw_directory`}}/centos6-aufs-master-slave-vmw.vmx"]
},
{
"type": "shell-local",
"only": ["centos6-aufs-master-slave-vmw"],
"scripts": [
"scripts/vmx-to-ova.sh"
],
"environment_vars": ["PACKER_OUTPUT_DIRECTORY=/home/myuser/projects/IT/packer-project/centos6-aufs-master-slave/{{user `output_vmw_directory`}}"]
}
]
]