mirror of https://github.com/kewlfft/ansible-aur
Simplify error reporting
parent
5ac7c0ef86
commit
1f09b94fbb
|
@ -35,7 +35,6 @@ options:
|
||||||
description:
|
description:
|
||||||
- Whether or not to upgrade whole system.
|
- Whether or not to upgrade whole system.
|
||||||
type: bool
|
type: bool
|
||||||
default: no
|
|
||||||
|
|
||||||
use:
|
use:
|
||||||
description:
|
description:
|
||||||
|
@ -61,6 +60,8 @@ options:
|
||||||
aur_only:
|
aur_only:
|
||||||
description:
|
description:
|
||||||
- Limit helper operation to the AUR.
|
- Limit helper operation to the AUR.
|
||||||
|
type: bool
|
||||||
|
default: no
|
||||||
notes:
|
notes:
|
||||||
- When used with a `loop:` each package will be processed individually,
|
- When used with a `loop:` each package will be processed individually,
|
||||||
it is much more efficient to pass the list directly to the `name` option.
|
it is much more efficient to pass the list directly to the `name` option.
|
||||||
|
@ -80,7 +81,6 @@ EXAMPLES = '''
|
||||||
become_user: aur_builder
|
become_user: aur_builder
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
def_lang = ['env', 'LC_ALL=C']
|
def_lang = ['env', 'LC_ALL=C']
|
||||||
|
|
||||||
use_cmd = {
|
use_cmd = {
|
||||||
|
@ -213,12 +213,7 @@ def main():
|
||||||
'default': 'present',
|
'default': 'present',
|
||||||
'choices': ['present', 'latest'],
|
'choices': ['present', 'latest'],
|
||||||
},
|
},
|
||||||
'ignore_arch': {
|
|
||||||
'default': False,
|
|
||||||
'type': 'bool',
|
|
||||||
},
|
|
||||||
'upgrade': {
|
'upgrade': {
|
||||||
'default': False,
|
|
||||||
'type': 'bool',
|
'type': 'bool',
|
||||||
},
|
},
|
||||||
'use': {
|
'use': {
|
||||||
|
@ -229,19 +224,27 @@ def main():
|
||||||
'default': False,
|
'default': False,
|
||||||
'type': 'bool',
|
'type': 'bool',
|
||||||
},
|
},
|
||||||
|
'ignore_arch': {
|
||||||
|
'default': False,
|
||||||
|
'type': 'bool',
|
||||||
|
},
|
||||||
'aur_only': {
|
'aur_only': {
|
||||||
'default': False,
|
'default': False,
|
||||||
'type': 'bool',
|
'type': 'bool',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
mutually_exclusive=[['name', 'upgrade']],
|
||||||
required_one_of=[['name', 'upgrade']],
|
required_one_of=[['name', 'upgrade']],
|
||||||
|
required_by={'use': ['skip_pgp_check', 'ignore_arch']},
|
||||||
supports_check_mode=True
|
supports_check_mode=True
|
||||||
)
|
)
|
||||||
|
|
||||||
params = module.params
|
params = module.params
|
||||||
|
|
||||||
if module.check_mode:
|
if params['use'] != 'makepkg' and params['skip_pgp_check']:
|
||||||
check_packages(module, params['name'])
|
module.fail_json(msg="You must use 'makepkg' to use the 'skip_pgp_check' option.")
|
||||||
|
if params['use'] != 'makepkg' and params['ignore_arch']:
|
||||||
|
module.fail_json(msg="You must use 'makepkg' to use the 'ignore_arch' option.")
|
||||||
|
|
||||||
if params['use'] == 'auto':
|
if params['use'] == 'auto':
|
||||||
use = 'makepkg'
|
use = 'makepkg'
|
||||||
|
@ -253,13 +256,15 @@ def main():
|
||||||
else:
|
else:
|
||||||
use = params['use']
|
use = params['use']
|
||||||
|
|
||||||
if params['upgrade'] and (params['name'] or use == 'makepkg'):
|
if params.get('upgrade', False) and use == 'makepkg':
|
||||||
module.fail_json(msg="Upgrade cannot be used with this option.")
|
module.fail_json(msg="Upgrade cannot be used with the helper 'makepkg'.")
|
||||||
|
|
||||||
|
if module.check_mode:
|
||||||
|
check_packages(module, params['name'])
|
||||||
|
elif params.get('upgrade', False):
|
||||||
|
upgrade(module, use, params['aur_only'])
|
||||||
else:
|
else:
|
||||||
if params['upgrade']:
|
install_packages(module, params['name'], use, params['state'], params['aur_only'])
|
||||||
upgrade(module, use, params['aur_only'])
|
|
||||||
else:
|
|
||||||
install_packages(module, params['name'], use, params['state'], params['aur_only'])
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue