Comments (6)
Files identified in the description:
None
If these files are incorrect, please update the component name
section of the description or use the component bot command.
from ansible.
You can accomplish this by downloading the RPM using the get_url
module which allows you to set the agent https://docs.ansible.com/ansible/latest/collections/ansible/builtin/get_url_module.html#parameter-http_agent. Then you can install the downloaded RPM using the yum module.
from ansible.
I knew that there was a way to avoid this by customizing the user agent with a different approach but I supposed that this could be solved at the root level by making the default process more reliable in these situation with widely used CDN like Akamai, Cloudflare etc.
The yum
command itself works as intended by itself on the target machine if I simply issue
yum install https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
So the first thing that one does is translate it (by following the docs) to
- name: Install Mysql 5.7 Community Repo
yum:
name: "https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm"
state: present
which doesn't work because the UA ansible-httpget
gets a bad score.
I was thinking to send a PR that sets an UA with more context and details like the module name (if available):
def get_user_agent(module=None):
"""Returns a user agent used by open_url"""
python_version = sys.version_info
module_part = ''
if not module is None and hasattr(module, '_name') and module._name:
module_part = "; %s" % module._name
return u'ansible-httpget/{ansible_version} ({platform}{module_part}; python:{py_major}.{py_minor}.{py_micro})'.format(
ansible_version=ansible_version,
platform=platform.system(),
module_part=module_part,
py_major=python_version.major,
py_minor=python_version.minor,
py_micro=python_version.micro,
)
which, in this case, translates to ansible-httpget/2.16.3 (Linux; ansible.legacy.yum; python:2.7.5)
that works by default.
from ansible.
@lucalooz It could be configurable by adding an http_agent
option to the arg spec:
diff --git a/lib/ansible/module_utils/yumdnf.py b/lib/ansible/module_utils/yumdnf.py
index 7eb9d5fc2b..b70e937cf4 100644
--- a/lib/ansible/module_utils/yumdnf.py
+++ b/lib/ansible/module_utils/yumdnf.py
@@ -35,6 +35,7 @@ yumdnf_argument_spec = dict(
enable_plugin=dict(type='list', elements='str', default=[]),
enablerepo=dict(type='list', elements='str', default=[]),
exclude=dict(type='list', elements='str', default=[]),
+ http_agent=dict(type='str', default='ansible-httpget'),
installroot=dict(type='str', default="/"),
install_repoquery=dict(type='bool', default=True),
install_weak_deps=dict(type='bool', default=True),
but I don't think we want to add every option supported by open_url to every module that might fetch a URL. The yum module fetches the URL first to see if it's installed. I also don't think we can change the default without potentially breaking playbooks.
from ansible.
@s-hertel I concur that we can't add every url setting to every module, maybe just a global configuration for the default UA.
I was just proposing to have a more detailed UA respecting the RFC that contains information about the calling module of fetch_url
in urls.py
.
ansible/lib/ansible/module_utils/urls.py
Line 1195 in 386edc6
I don't know if there are tests that we can run to ensure that's not breaking anything or if it's important to keep the same exact UA for historical reasons because some server may have an hardcoded rule for ansible-httpget
.
from ansible.
@s-hertel I concur that we can't add every url setting to every module, maybe just a global configuration for the default UA.
We generally avoid new global configuration options that change how the playbook runs, because it breaks content portability. This seems a little niche for a new play keyword. A get_url task in a playbook also seems easier to maintain than some keyword or config that affects some unknown tasks.
It's unfortunate the module fetches the file at all, since there are probably a lot of ways our URL-fetching differs from yum. Making User-Agent configurable and nothing else seems arbitrary - I see lots of HTTP related config options in https://man7.org/linux/man-pages/man5/yum.conf.5.html. Ideally we would defer to the yum
CLI to see if any changes would be made (but it doesn't support that).
I was just proposing to have a more detailed UA respecting the RFC that contains information about the calling module of fetch_url in urls.py.
HTTP RFC 7231 specifies that the version is optional.
from ansible.
Related Issues (20)
- Drop support for Python 3.10 on the controller HOT 1
- Drop support for Python 3.7 on the target HOT 2
- Replace Ubuntu 20.04 with 24.04 in ansible-test HOT 2
- Replace Fedora 39 with 40 in ansible-test HOT 1
- Replace FreeBSD 14.0 with 14.1 in ansible-test HOT 2
- Replace Alpine 3.19 with 3.20 in ansible-test HOT 1
- Replace RHEL 9.3 with 9.4 in ansible-test HOT 1
- Update sanity test requirements HOT 1
- Update PowerShell and .NET in the base container HOT 1
- Create stable branches for default container repos HOT 1
- wait_for_connection not working properly with Juniper QFX HOT 2
- mysql_role fails to parse show grant response from mysql HOT 1
- Having subroles in a role HOT 7
- Handlers not executed of roles referenced by dependency in combination with conditional role in playbook HOT 10
- handlers are skipped on conditional role include HOT 3
- DNF/YUM module - nbackground requirements-install ignore disablerepo/enablerepo options HOT 3
- diff mode + assemble + remote_src=false raises fatal error HOT 3
- package_facts module does not update packages host facts with apk when cache is empty or network unreacheable HOT 1
- Server not found in Kerberos database HOT 2
- Changes to linux.py for setup module to return more relevant information for s390 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible.