2017-05-08 38 views
1

我可以將我的web-packer.json模板中定義的變量用於user_data_file中的文件。我可以在打包模板中使用變量user_data_file

我正在使用user_data_file來設置wimrm並將用戶添加到管理員組。在安裝網絡服務器之前。

一些網絡packer.json模板

"builders": [ 
    { 
     "type": "amazon-ebs", 
     "vpc_id": "{{user `vpc_id`}}", 
     "subnet_id": "{{user `subnet_id`}}", 
     "associate_public_ip_address": true, 
     "access_key": "{{user `aws_access_key`}}", 
     "secret_key": "{{user `aws_secret_key`}}", 
     "region": "eu-west-1", 
     "source_ami": "ami-40003a26", 
     "instance_type": "c4.xlarge", 
     "ami_name": "cms-sitecore", 
     "communicator": "winrm", 
     "winrm_username": "{{user `winrm_username`}}", 
     "winrm_timeout": "30m", 
     "user_data_file": "./bootstrap-aws.ps1" 
    } 
    ], 
    "provisioners": [ 
    { 
     "type": "file", 
     "source": "./install/", 
     "destination": "C:/install" 
    }, 
    { 
     "type": "powershell", 
     "inline": [ 
     "Install-WindowsFeature -Name Web-Asp-Net45,Web-Static-Content,Web-Mgmt-Console,Web-Http-Errors,Web-Http-Logging,Web-Stat-Compression" 
     ] 
    } 
    ] 

回答

1

的你就是不行。 user_data_file不是模板,因此沒有插值。您必須使用user_data或在Packer外部預處理user_data_file

相關問題