mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
yumpkg add metalink
This commit is contained in:
parent
c5cfe214cd
commit
7dcb34e6bf
4 changed files with 42 additions and 27 deletions
1
changelog/58931.added.md
Normal file
1
changelog/58931.added.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Added metalink to mod_repo in yumpkg and documented in pkgrepo state
|
|
@ -2982,10 +2982,13 @@ def mod_repo(repo, basedir=None, **kwargs):
|
||||||
the URL for yum to reference
|
the URL for yum to reference
|
||||||
mirrorlist
|
mirrorlist
|
||||||
the URL for yum to reference
|
the URL for yum to reference
|
||||||
|
metalink
|
||||||
|
the URL for yum to reference
|
||||||
|
.. versionadded:: 3008.0
|
||||||
|
|
||||||
Key/Value pairs may also be removed from a repo's configuration by setting
|
Key/Value pairs may also be removed from a repo's configuration by setting
|
||||||
a key to a blank value. Bear in mind that a name cannot be deleted, and a
|
a key to a blank value. Bear in mind that a name cannot be deleted, and one
|
||||||
baseurl can only be deleted if a mirrorlist is specified (or vice versa).
|
of baseurl, mirrorlist, or metalink is required.
|
||||||
|
|
||||||
Strict parsing of configuration files is the default, this can be disabled
|
Strict parsing of configuration files is the default, this can be disabled
|
||||||
using the ``strict_config`` keyword argument set to False
|
using the ``strict_config`` keyword argument set to False
|
||||||
|
@ -2996,16 +2999,20 @@ def mod_repo(repo, basedir=None, **kwargs):
|
||||||
|
|
||||||
salt '*' pkg.mod_repo reponame enabled=1 gpgcheck=1
|
salt '*' pkg.mod_repo reponame enabled=1 gpgcheck=1
|
||||||
salt '*' pkg.mod_repo reponame basedir=/path/to/dir enabled=1 strict_config=False
|
salt '*' pkg.mod_repo reponame basedir=/path/to/dir enabled=1 strict_config=False
|
||||||
salt '*' pkg.mod_repo reponame baseurl= mirrorlist=http://host.com/
|
salt '*' pkg.mod_repo reponame basedir= mirrorlist=http://host.com/
|
||||||
|
salt '*' pkg.mod_repo reponame basedir= metalink=http://host.com
|
||||||
"""
|
"""
|
||||||
|
# set link types
|
||||||
|
link_types = ("baseurl", "mirrorlist", "metalink")
|
||||||
|
|
||||||
# Filter out '__pub' arguments, as well as saltenv
|
# Filter out '__pub' arguments, as well as saltenv
|
||||||
repo_opts = {
|
repo_opts = {
|
||||||
x: kwargs[x] for x in kwargs if not x.startswith("__") and x not in ("saltenv",)
|
x: kwargs[x] for x in kwargs if not x.startswith("__") and x not in ("saltenv",)
|
||||||
}
|
}
|
||||||
|
|
||||||
if all(x in repo_opts for x in ("mirrorlist", "baseurl")):
|
if [x in repo_opts for x in link_types].count(True) >= 2:
|
||||||
raise SaltInvocationError(
|
raise SaltInvocationError(
|
||||||
"Only one of 'mirrorlist' and 'baseurl' can be specified"
|
f"One and only one of {', '.join(link_types)} must be specified and is required"
|
||||||
)
|
)
|
||||||
|
|
||||||
use_copr = False
|
use_copr = False
|
||||||
|
@ -3022,12 +3029,11 @@ def mod_repo(repo, basedir=None, **kwargs):
|
||||||
del repo_opts[key]
|
del repo_opts[key]
|
||||||
todelete.append(key)
|
todelete.append(key)
|
||||||
|
|
||||||
# Add baseurl or mirrorlist to the 'todelete' list if the other was
|
# Add what ever items in link_types is not in repo_opts to 'todelete' list
|
||||||
# specified in the repo_opts
|
linkdict = {x: set(link_types) - {x} for x in link_types}
|
||||||
if "mirrorlist" in repo_opts:
|
todelete.extend(
|
||||||
todelete.append("baseurl")
|
next(iter([y for x, y in linkdict.items() if x in repo_opts.keys()]), [])
|
||||||
elif "baseurl" in repo_opts:
|
)
|
||||||
todelete.append("mirrorlist")
|
|
||||||
|
|
||||||
# Fail if the user tried to delete the name
|
# Fail if the user tried to delete the name
|
||||||
if "name" in todelete:
|
if "name" in todelete:
|
||||||
|
@ -3090,10 +3096,10 @@ def mod_repo(repo, basedir=None, **kwargs):
|
||||||
"was not given"
|
"was not given"
|
||||||
)
|
)
|
||||||
|
|
||||||
if "baseurl" not in repo_opts and "mirrorlist" not in repo_opts:
|
if all(x not in repo_opts.keys() for x in link_types):
|
||||||
raise SaltInvocationError(
|
raise SaltInvocationError(
|
||||||
"The repo does not exist and needs to be created, but either "
|
"The repo does not exist and needs to be created, but none of "
|
||||||
"a baseurl or a mirrorlist needs to be given"
|
f"{', '.join(link_types)} was given"
|
||||||
)
|
)
|
||||||
filerepos[repo] = {}
|
filerepos[repo] = {}
|
||||||
else:
|
else:
|
||||||
|
@ -3101,16 +3107,15 @@ def mod_repo(repo, basedir=None, **kwargs):
|
||||||
repofile = repos[repo]["file"]
|
repofile = repos[repo]["file"]
|
||||||
header, filerepos = _parse_repo_file(repofile, strict_parser)
|
header, filerepos = _parse_repo_file(repofile, strict_parser)
|
||||||
|
|
||||||
# Error out if they tried to delete baseurl or mirrorlist improperly
|
# Error out if they tried to delete all linktypes
|
||||||
if "baseurl" in todelete:
|
for link_type in link_types:
|
||||||
if "mirrorlist" not in repo_opts and "mirrorlist" not in filerepos[repo]:
|
linklist = set(link_types) - {link_type}
|
||||||
|
if all(
|
||||||
|
x not in repo_opts and x not in filerepos[repo] and link_type in todelete
|
||||||
|
for x in linklist
|
||||||
|
):
|
||||||
raise SaltInvocationError(
|
raise SaltInvocationError(
|
||||||
"Cannot delete baseurl without specifying mirrorlist"
|
f"Cannot delete {link_type} without specifying {' or '.join(linklist)}"
|
||||||
)
|
|
||||||
if "mirrorlist" in todelete:
|
|
||||||
if "baseurl" not in repo_opts and "baseurl" not in filerepos[repo]:
|
|
||||||
raise SaltInvocationError(
|
|
||||||
"Cannot delete mirrorlist without specifying baseurl"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Delete anything in the todelete list
|
# Delete anything in the todelete list
|
||||||
|
|
|
@ -145,10 +145,10 @@ def managed(name, ppa=None, copr=None, aptkey=True, **kwargs):
|
||||||
**YUM/DNF/ZYPPER-BASED SYSTEMS**
|
**YUM/DNF/ZYPPER-BASED SYSTEMS**
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
One of ``baseurl`` or ``mirrorlist`` below is required. Additionally,
|
One of ``baseurl``, ``mirrorlist``, or ``metalink`` below is required.
|
||||||
note that this state is not presently capable of managing more than one
|
Additionally, note that this state is not presently capable of managing
|
||||||
repo in a single repo file, so each instance of this state will manage
|
more than one repo in a single repo file, so each instance of this state
|
||||||
a single repo file containing the configuration for a single repo.
|
will manage a single repo file containing the configuration for a single repo.
|
||||||
|
|
||||||
name
|
name
|
||||||
This value will be used in two ways: Firstly, it will be the repo ID,
|
This value will be used in two ways: Firstly, it will be the repo ID,
|
||||||
|
@ -182,6 +182,11 @@ def managed(name, ppa=None, copr=None, aptkey=True, **kwargs):
|
||||||
mirrorlist
|
mirrorlist
|
||||||
A URL which points to a file containing a collection of baseurls
|
A URL which points to a file containing a collection of baseurls
|
||||||
|
|
||||||
|
metalink
|
||||||
|
A URL for a curated list of non-stale mirrors only usable with yum/dnf
|
||||||
|
|
||||||
|
.. versionadded:: 3008.0
|
||||||
|
|
||||||
comments
|
comments
|
||||||
Sometimes you want to supply additional information, but not as
|
Sometimes you want to supply additional information, but not as
|
||||||
enabled configuration. Anything supplied for this list will be saved
|
enabled configuration. Anything supplied for this list will be saved
|
||||||
|
|
|
@ -3234,3 +3234,7 @@ def test_59705_version_as_accidental_float_should_become_text(
|
||||||
yumpkg.install("fnord", version=new)
|
yumpkg.install("fnord", version=new)
|
||||||
call = cmd_mock.mock_calls[0][1][0]
|
call = cmd_mock.mock_calls[0][1][0]
|
||||||
assert call == expected_cmd
|
assert call == expected_cmd
|
||||||
|
|
||||||
|
|
||||||
|
def test_mod_repo():
|
||||||
|
pass
|
||||||
|
|
Loading…
Add table
Reference in a new issue