-
Notifications
You must be signed in to change notification settings - Fork 897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proxy support for cloning ansible repo and add provider #15762
Conversation
Current status: In summary: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ailisp The bug referenced is about embedded ansible with IPv6, however the code changes are related to the git worktree (automate model code).
If you want to solve the embedded ansible bug, you need to look at how the embedded ansible application is configured. You'll may have to give it the proxy information when running the setup playbook.
@bdunne tasks:
- apt: name=cobbler state=installed
environment:
http_proxy: http://proxy.example.com:8080 I think it's better to have a "global proxy" configuration for Ansible or Ansible Tower. Then we reconfigure it when save proxy settings in ManageIQ. Or have an Ansible Tower API to add http_proxy for a play's enviroment, then call that in ManageIQ. What do you think? Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ailisp We do not use git directly when dealing with playbook repos, the code changed in this PR is not related to EmbeddedAnsible and will not change it's behavior.
Additionally, the BZ referenced seems to be talking about not being able to add a cloud provider after setting up the proxy settings. To me, it doesn't seem like they even got to setting up EmbeddedAnsible.
I'll need some more clarity in the BZ before we can come up with a way of addressing whatever it is they are saying is broken.
@carbonin right. Brandon has explained similar idea to me and thanks for having some clarification for this BZ. |
@carbonin @bdunne |
@ailisp I think this approach likely won't work for sending the proxy environment to embedded ansible. The services that make up the embedded ansible installation are started by systemd which cleans the environment when it starts services. I think we would need to either set this stuff up in the systemd environment files for the ansible services or need to specifically configure the ansible setup to configure it iteslf (which I'm not sure how to do). |
@carbonin |
lib/embedded_ansible.rb
Outdated
EOF | ||
File.open(SETTING_FILE, 'a') do |file| | ||
file.write(proxy_settings) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be cleaner if it were just two calls to File#write
:
File.open(SETTING_FILE, 'a') do |file|
file.write("AWX_TASK_ENV['HTTP_PROXY'] = #{proxy}\n")
file.write("AWX_TASK_ENV['HTTPS_PROXY'] = #{proxy}\n")
end
Also can we check that these ENV vars are not present in settings.py before writing them? It feels like this would write the config multiple times if the role were removed and re-added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Do we need an extra file.write('\n')
before the first file.write
. In case settings.py
doesn't contain a fresh empty line. And what is preferred way to check that ENV vars? By search AWX_TASK_ENV['HTTP_PROXY']
string in py
file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need an extra file.write('\n') before the first file.write. In case settings.py doesn't contain a fresh empty line.
Yeah, that's probably a good idea.
And what is preferred way to check that ENV vars? By search AWX_TASK_ENV['HTTP_PROXY'] string in py file?
Sounds good to me.
lib/embedded_ansible.rb
Outdated
if VMDB::Util.http_proxy_uri(:embedded_ansible) | ||
_log.error("Can't set proxy for Embedded Ansible Tower in container environment") | ||
elsif VMDB::Util.http_proxy_uri | ||
_log.warn("Global proxy settings will not work for Embedded Ansible Tower in container environment") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that this is the case, but I don't think this would really be needed for the container case either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For container case, we can't modify it's settings.py and set the proxy settings since the ansible tgwer already set up in container. You mean we don't need to consider this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't modify it's settings.py and set the proxy settings since the ansible tgwer already set up in container.
Of course, you're right here.
You mean we don't need to consider this case?
I mean that in OpenShift at least, it's likely that we will have more permissive network that will allow us to access the resources we need. I'm just thinking that a proxy will be a less common use case in containers.
@@ -825,11 +825,13 @@ | |||
:password: | |||
:port: | |||
:user: | |||
:scheme: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change being made?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's for socks5 proxy. If leave empty or "http", VMDB::Util.http_uri_proxy
will return a http proxy uri. If scheme is "socks5", it will construct a socks5://...
proxy. Both http proxy and socks5 proxy works when putting in http_proxy
env var.
VMDB::Util.http_uri_proxy: https://github.com/ManageIQ/manageiq/blob/master/lib/vmdb/util.rb#L3
lib/embedded_ansible.rb
Outdated
@@ -8,6 +8,7 @@ class EmbeddedAnsible | |||
ANSIBLE_ROLE = "embedded_ansible".freeze | |||
SETUP_SCRIPT = "ansible-tower-setup".freeze | |||
SECRET_KEY_FILE = "/etc/tower/SECRET_KEY".freeze | |||
SETTING_FILE = "/etc/tower/settings.py".freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think SETTINGS_FILE
would be a better constant name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK!
Dismissing Brandon's review as the patch is no longer touching the referenced code.
@ailisp Can you squash out some of the commits that are making changes which are no longer present in this patch? |
@carbonin OK, will squash them after these changes and works for test |
cfd8ff0
to
3b3f43f
Compare
@miq-bot remove-label wip |
@carbonin Finally it works on Pavol's VM. Thank you a lot for your help. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you write some specs for the process of setting the proxy info in the file.
Feel free to just test the private method on its own.
lib/embedded_ansible.rb
Outdated
else | ||
exist_settings | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this is all a bit over-engineered.
I think it would be easier to read if we just deleted the lines with these keys from the file, then appended the new proxy lines to the end if the proxy is set in our settings.
I don't think this process of finding the start of the previous proxy settings is really necessary.
Pseudo code should reduce to:
current_contents = File.read(SETTINGS_FILE)
new_contents = current.gsub(/^.*AWX_TASK_ENV\['(HTTPS?_PROXY|NO_PROXY)'\].*$/, "")
if proxy_is_set
new_contents << proxy_info
end
File.write(SETTINGS_FILE, new_contents)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this looks better
415b338
to
1ffa5e9
Compare
5f082f1
to
b7166b2
Compare
105b862
to
7672e03
Compare
Checked commits ailisp/manageiq@c9ca903~...7672e03 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
Proxy support for cloning ansible repo and add provider (cherry picked from commit 2526eb7) https://bugzilla.redhat.com/show_bug.cgi?id=1496912
Fine backport details:
|
Proxy support for cloning ansible repo and add provider (cherry picked from commit 2526eb7) https://bugzilla.redhat.com/show_bug.cgi?id=1496912
ISSUE: currently we get proxy setting from Configuration -> Advanced but didn't use it for cloning ansible repo or add provider. In pure ipv6 network, there is no Internet access without proxy so proxy must be used.
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1475954
\cc @bdunne @yrudman @gtanzillo
@miq-bot add-label wip, bug