2014-12-08 2 views
2

는 포장에 바르, 내 스크립트는 다음과 같다 : 수 또한기본 변수를 사용하는 패커? 내가 옵션을 사용할 수있는 가능성을 알아 내기 위해 노력했습니다

packer build    \ 
    -var 'config=master' \ 
    template.json 

을하지만 :

"provisioners": [{ 
    "type": "shell", 
    "scripts": [ 
    "scripts/centos/5.11/puppet-{{user `config`}}.sh", 
    ] 
}], 
"variables": { 
    "config": "{{user `type`}} | slave", 
} 

은 일반적인 명령이 될 것입니다 있었 다음을 수행 할 수 있습니다.

packer build template.json # were config would default to slave 

답변

6

명령 줄 변수는 json 템플릿의 설정보다 우선합니다. 패커의 문서를 참조하십시오 : https://www.packer.io/docs/templates/user-variables.html

그래서 템플릿에 기본값을 설정하고 이미 사용하고있는 명령 행 예제로 덮어 씁니다.

템플릿이 될 것이다 :

"provisioners": [{ 
    "type": "shell", 
    "scripts": [ 
     "scripts/centos/5.11/puppet-{{user `config`}}.sh" 
    ] 
}], 
"variables": { 
    "config": "slave" 
} 
관련 문제