How to set proxy only for a particular ansible task?

rolz picture rolz · Nov 10, 2016 · Viewed 15.8k times · Source

I want to set an environment proxy only for a particular ansible task like get_url module to download some application from internet. Other all tasks should run without any proxy. How do I achieve this task.

Answer

Zlemini  picture Zlemini · Nov 10, 2016

You can set a proxy per task, like so:

get_url:
  url=http://remote.host.com/file
  dest=/tmp/file
environment:
  http_proxy: http://proxy.example.com:8080