Skip to content

PackerLink

CommandLink

packer build packer.json

# variables を外部ファイルで渡す。基本的に全てこの形に落とすと管理が楽
packer build -var-file=variables.json packer.json

Base TemplateLink

{
  "_comment": "コメントはroot階層に一回しか書けないみたい",
  "description": "できるだけ書きましょう",
  "variables": {
    // 外部から変更可能な変数
  },

  "builders": [
    {
    // 複数のビルダーを書くこともできるみたいだけど、1ファイル1組み立てのほうがわかりやすい気がする
    // ちなみにファイルはjsonなので、コメントは_commentしか書けないし、validateされるので適当な名前のキーは受け付けない
    }
  ],

  "provisioners": [
    {
      "type": "shell",
      "script": "setup_things.sh"
    },
    {
      "type": "ansible",
      "playbook_file": "./playbook.yml"
    }
  ]
}