VM proxy configuration

850 views
Skip to first unread message

Thibaud Lepretre

unread,
Jun 20, 2014, 6:48:11 AM6/20/14
to packe...@googlegroups.com
I'm using packer inside "proxified" network and I know that packer is using standard proxy env variables:

- http_proxy
- https_proxy

But my problem is located inside VM and when I want to provisioned its VM I must add the following configuration at each provisioners:

{
    "variables": {
        "http_proxy": "{{env `http_proxy`}}",
        "https_proxy": "{{env `https_proxy`}}",
        "ftp_proxy": "{{env `ftp_proxy`}}",
        "no_proxy": "{{env `no_proxy`}}"
    },
    ...
    "provisioners": [
        {
            "only": ["virtualbox-iso"],
            "environment_vars": [
                "http_proxy={{user `http_proxy`}}",
                "https_proxy={{user `https_proxy`}}",
                "ftp_proxy={{user `ftp_proxy`}}",
                "no_proxy={{user `no_proxy`}}"
            ],
            "type": "shell",
            "execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
            "scripts": [
                ...
            ]
        },
        {
            "environment_vars": [
                "http_proxy={{user `http_proxy`}}",
                "https_proxy={{user `https_proxy`}}",
                "ftp_proxy={{user `ftp_proxy`}}",
                "no_proxy={{user `no_proxy`}}"
            ],
            "type": "shell",
            "execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
            "inline": ["yum update"]
        }
    ]
}

It's a bit redundant.

There is a better way to achieve my goal?

Alvaro Miranda Aguilera

unread,
Jun 20, 2014, 6:57:31 PM6/20/14
to packe...@googlegroups.com
you can have 1 shell code, and use
[
"command....",
"command..",
"command"
]

no need to write a full block for each line/command


--
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thibaud Lepretre

unread,
Jun 21, 2014, 5:17:16 AM6/21/14
to packe...@googlegroups.com
Yeah but I have to split the commands because somes are only for provider virtualbox-iso and other are default (for all provider)

Ethan S.

unread,
Nov 4, 2015, 1:16:49 PM11/4/15
to Packer
I believe packer now supports the concept of "overrides" for specific providers, so you can use the common blocks and just override commands for specific providers.
Reply all
Reply to author
Forward
0 new messages