Confused with proxy / env

55 views
Skip to first unread message

Florian Heigl

unread,
Jul 18, 2014, 2:34:02 PM7/18/14
to ansible...@googlegroups.com
Hi,

I have a little problem with conditionally setting a proxy.

situation:
- many systems in different domains (since hosting env)
- two domains are internal and only get outside connection via a proxy

So, I need no proxy set for all systems that aren't in those domains.
For those two domains, the proxy should be assigned.

What I have:
in group_vars/all:
---
ansible_python_interpreter: /usr/local/bin/python
proxies:
  http_proxy: http://no-proxy

in group_vars/subdomain_domain_de:
---
proxies:
  http_proxy: http://proxy.subdomain_domain_de:8080/


the playbook is and output are here at hastebin:



now, the confusing part.
When I run this, I see the node *is* being assigned to the group, but not getting the proxy from the group_var.
I added one in all, and yes, it gets that one.

Also, it seems to be a problem if i refer to environment: proxies since they only apply to 30 of the systems. All the others don't have one
How do I do that without duplicating code? (run one play for proxied, based on the domain and one for the others? Sounds wrong)

The docs actually have an example for setting proxies, which is nice, but it's just too trivial to help with this :(

any help very appreciated.

Michael DeHaan

unread,
Jul 19, 2014, 7:58:11 AM7/19/14
to ansible...@googlegroups.com
"

situation:
- many systems in different domains (since hosting env)
- two domains are internal and only get outside connection via a proxy
"

This is EXACTLY why the environment support was written, actually.

I was automating an OpenStack config at a very, hmm, structured, company and I had to get to some things on one proxy, some things on another, and sometimes I needed to turn OFF the proxy settings to get things.  A certain other config tool couldn't really even do this, so I said, dang it, I've got this, and "enviornment:" in Ansible was born.

It sounds like you are trying to specify proxies in inventory, yet, you need to really set them per task.

So I would probably define things as "proxy_env_one" and "proxy_env_two" (with better names), and per task, specify which to use.

Reading the above though, I'm not sure you're trying to switch between them in the same tasks though, and it may just be that your system isn't in the group you think it is?

We'd need to see your inventory.




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a52963bd-6664-4ceb-b325-bc28b0009ac6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages