Packer shell Provisioner

From NovaOrdis Knowledge Base
Revision as of 17:48, 15 November 2019 by Ovidiu (talk | contribs) (→‎scripts)
Jump to navigation Jump to search

External

Internal

Overview

shell Provisioner Types

inline

{
  ...
  "provisioners": [
    {
      "type": "shell",
      "inline": ["sudo yum install ansible"]
    },
  ... 
  ]
}

script

{
  ...
  "provisioners": [
    {
      "type": "shell",
      "only": [
        "my-builder"
      ],
      "environment_vars": [
        "SOMETHING={{ user `something` }}"
      ],
      "execute_command": "echo '' | {{ .Vars }} sudo -S -E -u root '{{ .Path }}'",
      "script": "config/something.sh"
    },
  ... 
  ]
}

scripts

{
  ...
  "provisioners": [
    {
      "type": "shell",
      "only": [
        "my-builder"
      ],
      "environment_vars": [
        "SOMETHING={{ user `something` }}"
      ],
      "execute_command": "echo '' | {{ .Vars }} sudo -S -E -u root '{{ .Path }}'",
      "scripts": [
        "scripts/something.sh",
        "scripts/something-else.sh",
       ]
    },
  ... 
  ]
}

Parameters

execute_command

A String that specifies the command to use to execute the script. The default value, unless specified, is:

chmod +x {{ .Path }}; {{ .Vars }} {{ .Path }}