Install debian with packer. After installation, the postinstall.sh script should work. But it does not work, because after the first launch, the system asks for a username and password. Maybe I did not add something in the .json file? Fragment of json file:

............. "ssh_username": "user", "ssh_password": "user", "ssh_port": 22, ............. } } ] } ], "provisioners": { "type": "shell", "script": [ "postinstall.sh", "apt-get -y install mc" }, ] } 

Script:

 apt-get update apt-get -y install mc 

Another way is to write in json like this:

 "provisioners": { "type": "shell", "inline": [ "apt-get update", "apt-get -y install mc" 

But also does not work

    1 answer 1

    You are not in the order of the brackets.

     "provisioners": [ { "type": "shell", "inline": [ "sleep 30", "sudo apt-get update", "sudo apt-get install -y nano mc " ] } ] 

    All this will work, provided that you have previously added your user user to the sudo group.

    You can also use the validate option:

     packer validate -var-file=vars.json debian.json 

    Helps to remove some number of errors.