mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
galaxy-cli: selective install roles in requirements file (#21412)
* galaxy-cli: force install selected roles in requirements file * only when requirements file but also handle uninstalled roles
This commit is contained in:
parent
d95fd7414a
commit
13dec9259f
1 changed files with 8 additions and 5 deletions
|
@ -311,9 +311,6 @@ class GalaxyCLI(CLI):
|
||||||
if len(self.args) == 0 and role_file is None:
|
if len(self.args) == 0 and role_file is None:
|
||||||
# the user needs to specify one of either --role-file or specify a single user/role name
|
# the user needs to specify one of either --role-file or specify a single user/role name
|
||||||
raise AnsibleOptionsError("- you must specify a user/role name or a roles file")
|
raise AnsibleOptionsError("- you must specify a user/role name or a roles file")
|
||||||
elif len(self.args) == 1 and role_file is not None:
|
|
||||||
# using a role file is mutually exclusive of specifying the role name on the command line
|
|
||||||
raise AnsibleOptionsError("- please specify a user/role name, or a roles file, but not both")
|
|
||||||
|
|
||||||
no_deps = self.options.no_deps
|
no_deps = self.options.no_deps
|
||||||
force = self.options.force
|
force = self.options.force
|
||||||
|
@ -368,11 +365,17 @@ class GalaxyCLI(CLI):
|
||||||
roles_left.append(GalaxyRole(self.galaxy, **role))
|
roles_left.append(GalaxyRole(self.galaxy, **role))
|
||||||
|
|
||||||
for role in roles_left:
|
for role in roles_left:
|
||||||
display.vvv('Installing role %s ' % role.name)
|
# only process roles in roles files when names matches if given
|
||||||
|
if role_file and self.args and role.name not in self.args:
|
||||||
|
display.vvv('Skipping role %s' % role.name)
|
||||||
|
continue
|
||||||
|
|
||||||
|
display.vvv('Processing role %s ' % role.name)
|
||||||
|
|
||||||
# query the galaxy API for the role data
|
# query the galaxy API for the role data
|
||||||
|
|
||||||
if role.install_info is not None:
|
if role.install_info is not None:
|
||||||
if role.install_info['version'] != role.version:
|
if role.install_info['version'] != role.version or force:
|
||||||
if force:
|
if force:
|
||||||
display.display('- changing role %s from %s to %s' %
|
display.display('- changing role %s from %s to %s' %
|
||||||
(role.name, role.install_info['version'], role.version or "unspecified"))
|
(role.name, role.install_info['version'], role.version or "unspecified"))
|
||||||
|
|
Loading…
Add table
Reference in a new issue