2

I have a number of variables that can be populated from bash queries on execution. I'm struggling to find a way to make this a reality.

Essentially, I'm trying to accomplish this:

{
  "variables": {
    "ssh_name": "root",
    "ssh_pass": "password123",
    "server_version": "grep product.version= ../product.properties | sed 's:product.version=::'"
  },
  "builders": [
    {
      "type": "virtualbox-iso",

I've tried several iterations of this, but I can't seem to find a working substitution call.

NickS
  • 23
  • 2
  • 1
    I can't figure out what you're trying to do. Is that an example output? What is your input in that case? – divibisan Apr 06 '18 at 17:13
  • The variable "server_version" should be set from the command that follows. It doesn't, I've tried a couple different ways to approach it, but no luck so far. – NickS Apr 06 '18 at 17:34
  • Please review [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) – Stefan Crain Apr 08 '18 at 13:45

1 Answers1

0

Just pass it in with a subshell:

packer build -var server_version=$(grep product.version= ../product.properties | \
sed 's:product.version=::') template.json
Stefan Crain
  • 2,010
  • 3
  • 21
  • 22
Rickard von Essen
  • 4,110
  • 2
  • 23
  • 27