mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
yum: check if env groups are installed (#31182)
This commit is contained in:
parent
d025aca66f
commit
13631ececa
1 changed files with 21 additions and 7 deletions
|
@ -322,14 +322,28 @@ def po_to_envra(po):
|
||||||
return '%s:%s-%s-%s.%s' % (po.epoch, po.name, po.version, po.release, po.arch)
|
return '%s:%s-%s-%s.%s' % (po.epoch, po.name, po.version, po.release, po.arch)
|
||||||
|
|
||||||
|
|
||||||
def is_group_installed(name):
|
def is_group_env_installed(name):
|
||||||
|
name_lower = name.lower()
|
||||||
|
|
||||||
my = yum_base()
|
my = yum_base()
|
||||||
groups_list = my.doGroupLists()
|
if yum.__version__ >= '3.4':
|
||||||
for group in groups_list[0]: # list of the installed groups on the first index
|
groups_list = my.doGroupLists(return_evgrps=True)
|
||||||
name_lower = name.lower()
|
else:
|
||||||
|
groups_list = my.doGroupLists()
|
||||||
|
|
||||||
|
# list of the installed groups on the first index
|
||||||
|
groups = groups_list[0]
|
||||||
|
for group in groups:
|
||||||
if name_lower.endswith(group.name.lower()) or name_lower.endswith(group.groupid.lower()):
|
if name_lower.endswith(group.name.lower()) or name_lower.endswith(group.groupid.lower()):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
if yum.__version__ >= '3.4':
|
||||||
|
# list of the installed env_groups on the third index
|
||||||
|
envs = groups_list[2]
|
||||||
|
for env in envs:
|
||||||
|
if name_lower.endswith(env.name.lower()) or name_lower.endswith(env.environmentid.lower()):
|
||||||
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@ -740,7 +754,7 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos, i
|
||||||
|
|
||||||
# groups
|
# groups
|
||||||
elif spec.startswith('@'):
|
elif spec.startswith('@'):
|
||||||
if is_group_installed(spec):
|
if is_group_env_installed(spec):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
pkg = spec
|
pkg = spec
|
||||||
|
@ -846,7 +860,7 @@ def remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos, in
|
||||||
|
|
||||||
for pkg in items:
|
for pkg in items:
|
||||||
if pkg.startswith('@'):
|
if pkg.startswith('@'):
|
||||||
installed = is_group_installed(pkg)
|
installed = is_group_env_installed(pkg)
|
||||||
else:
|
else:
|
||||||
installed = is_installed(module, repoq, pkg, conf_file, en_repos=en_repos, dis_repos=dis_repos, installroot=installroot)
|
installed = is_installed(module, repoq, pkg, conf_file, en_repos=en_repos, dis_repos=dis_repos, installroot=installroot)
|
||||||
|
|
||||||
|
@ -879,7 +893,7 @@ def remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos, in
|
||||||
# at this point we check to see if the pkg is no longer present
|
# at this point we check to see if the pkg is no longer present
|
||||||
for pkg in pkgs:
|
for pkg in pkgs:
|
||||||
if pkg.startswith('@'):
|
if pkg.startswith('@'):
|
||||||
installed = is_group_installed(pkg)
|
installed = is_group_env_installed(pkg)
|
||||||
else:
|
else:
|
||||||
installed = is_installed(module, repoq, pkg, conf_file, en_repos=en_repos, dis_repos=dis_repos, installroot=installroot)
|
installed = is_installed(module, repoq, pkg, conf_file, en_repos=en_repos, dis_repos=dis_repos, installroot=installroot)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue