Thanks for the tip, that works quite well (and reduced the places in the 
files that have the config from about 6 to 2 times, but I may get down to a 
single config variable)

I have figured out the ansible setting of the environment, so I just add 
that in case anybody finds this thread later via google.

Setting the proxy in profile.d or by sourcing a file will set the 
environment for the ansible-playbook command locally, to pass it the tasks 
that are run by ansible, add the following in yaml file:

- hosts: xxx

  roles:
     - xxx
     ...

  environment:
    http_proxy: "{{ lookup('env', 'http_proxy') }}"
    https_proxy: "{{ lookup('env', 'https_proxy') }}"

The lookup function will not fail if the variable is not set so that should 
work with unset proxy env as well.


On Friday, July 7, 2017 at 2:23:23 PM UTC+2, Alvaro Miranda Aguilera wrote:
>
> I personally do this trick.
>
> I always copy a file called proxy.env and first line of the scripts is 
> source the file.
>
> If I am on a environment that requires proxy, just put in the file the 
> information.
> if I am on environment that doesn't require proxy, have an empty file.
>
> Not sure for ansible
>
> On Fri, Jul 7, 2017 at 12:56 PM, Alexander Lehmann <[email protected] 
> <javascript:>> wrote:
>
>> I am currently building vmware and virtualbox images with packer in the 
>> corporate environment (firewalled network) on my local machine, which 
>> requires a http/https proxy setting for any internet repo like yum, maven, 
>> ansible galaxy etc.
>>
>> I have currently solved that by setting the env variables in each step 
>> (shell scripts, ansible command etc), I wonder if there is a way to set 
>> this for all commands that are run in the provisioners.
>>
>>
>> -- 
>> This mailing list is governed under the HashiCorp Community Guidelines - 
>> https://www.hashicorp.com/community-guidelines.html. Behavior in 
>> violation of those guidelines may result in your removal from this mailing 
>> list.
>>  
>> GitHub Issues: https://github.com/mitchellh/packer/issues
>> IRC: #packer-tool on Freenode
>> --- 
>> 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 [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/packer-tool/48745a06-5eaa-4c41-8fbf-d2d21ef599b4%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/packer-tool/48745a06-5eaa-4c41-8fbf-d2d21ef599b4%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Alvaro
>
>

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
--- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/6cfc4dcf-9176-4739-b602-e807995545c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to