mirror of https://github.com/kewlfft/ansible-aur
Split main into testable functions
parent
cc5012c5af
commit
43f8736f76
|
@ -218,7 +218,7 @@ def install_packages(module, packages, use, state, aur_only):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def make_module():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec={
|
argument_spec={
|
||||||
'name': {
|
'name': {
|
||||||
|
@ -274,6 +274,12 @@ def main():
|
||||||
if params.get('upgrade', False) and use == 'makepkg':
|
if params.get('upgrade', False) and use == 'makepkg':
|
||||||
module.fail_json(msg="Upgrade cannot be used with the helper 'makepkg'.")
|
module.fail_json(msg="Upgrade cannot be used with the helper 'makepkg'.")
|
||||||
|
|
||||||
|
return module, use
|
||||||
|
|
||||||
|
|
||||||
|
def apply_module(module, use):
|
||||||
|
params = module.params
|
||||||
|
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
check_packages(module, params['name'])
|
check_packages(module, params['name'])
|
||||||
elif params.get('upgrade', False):
|
elif params.get('upgrade', False):
|
||||||
|
@ -282,5 +288,10 @@ def main():
|
||||||
install_packages(module, params['name'], use, params['state'], params['aur_only'])
|
install_packages(module, params['name'], use, params['state'], params['aur_only'])
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
module, use = make_module()
|
||||||
|
apply_module(module, use)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue