1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

make: allow multiple targets to be specified (#6882)

* make: allow multiple targets to be specified

* add changelog frag

* Update changelogs/fragments/6882-make-multiple-targets.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* change to extra param

* adjust changelog frag

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Alexei Znamensky 2023-07-13 05:37:37 +12:00 committed by GitHub
parent 7609cebae9
commit 0ae8f9d631
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 4 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- make - add new ``targets`` parameter allowing multiple targets to be used with ``make`` (https://github.com/ansible-collections/community.general/pull/6882, https://github.com/ansible-collections/community.general/issues/4919).

View file

@ -54,7 +54,16 @@ options:
description:
- The target to run.
- Typically this would be something like V(install), V(test), or V(all).
- O(target) and O(targets) are mutually exclusive.
type: str
targets:
description:
- The list of targets to run.
- Typically this would be something like V(install), V(test), or V(all).
- O(target) and O(targets) are mutually exclusive.
type: list
elements: str
version_added: 7.2.0
'''
EXAMPLES = r'''
@ -115,6 +124,12 @@ target:
- The value of the module parameter O(target).
type: str
returned: success
targets:
description:
- The value of the module parameter O(targets).
type: str
returned: success
version_added: 7.2.0
'''
from ansible.module_utils.six import iteritems
@ -155,12 +170,14 @@ def main():
module = AnsibleModule(
argument_spec=dict(
target=dict(type='str'),
targets=dict(type='list', elements='str'),
params=dict(type='dict'),
chdir=dict(type='path', required=True),
file=dict(type='path'),
make=dict(type='path'),
jobs=dict(type='int'),
),
mutually_exclusive=[('target', 'targets')],
supports_check_mode=True,
)
@ -172,7 +189,6 @@ def main():
if not make_path:
# Fall back to system make
make_path = module.get_bin_path('make', required=True)
make_target = module.params['target']
if module.params['params'] is not None:
make_parameters = [k + '=' + str(v) for k, v in iteritems(module.params['params'])]
else:
@ -188,7 +204,10 @@ def main():
base_command.extend(["-f", module.params['file']])
# add make target
base_command.append(make_target)
if module.params['target']:
base_command.append(module.params['target'])
elif module.params['targets']:
base_command.extend(module.params['targets'])
# add makefile parameters
base_command.extend(make_parameters)
@ -206,8 +225,7 @@ def main():
changed = False
else:
# The target isn't up to date, so we need to run it
rc, out, err = run_command(base_command, module,
check_rc=True)
rc, out, err = run_command(base_command, module, check_rc=True)
changed = True
# We don't report the return code, as if this module failed
@ -221,6 +239,7 @@ def main():
stdout=out,
stderr=err,
target=module.params['target'],
targets=module.params['targets'],
params=module.params['params'],
chdir=module.params['chdir'],
file=module.params['file'],