Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to unset http_proxy in ansible playbook

In most ansible example, it is to set environment like setting http_proxy below, see http://docs.ansible.com/playbooks_environment.html

- hosts: all
  tasks:
  - apt: name=cobbler state=installed
    environment:
      http_proxy: http://proxy.example.com:8080

In my case, I need this http_proxy in system shell, while I want to disable this in playbook, how can I achieve this ?

If I work in shell, I can use unset http_proxy

like image 933
Larry Cai Avatar asked Aug 28 '14 09:08

Larry Cai


People also ask

How do you set an environment variable in ansible?

You can use the environment keyword at the play, block, or task level to set an environment variable for an action on a remote host. With this keyword, you can enable using a proxy for a task that does http requests, set the required environment variables for language-specific version managers, and more.

How do I see ansible environment variables?

We can use the ansible_env and lookup function to retrieve the environment variables stored. - name: Ansible playbook to get linux environment variables. The above playbook retrieves all the environment variables inside the unix os. Now we need to retrieve the USER env variable.

Can ansible environment variables be created modified?

win_environment module – Modify environment variables on windows hosts. This module is part of the ansible.

How can I set the PATH or any other environment variable for a task or entire playbook?

How can I set the PATH or any other environment variable for a task or entire play?  Setting environment variables can be done with the environment keyword. It can be used at the task or other levels in the play.


1 Answers

You could temporarily disable the proxy for the host(s) or URL you wanted to talk to, e.g.

environment:
  no_proxy: 192.168.1.2,www.google.com
like image 166
Rick Bolton Avatar answered Sep 27 '22 17:09

Rick Bolton