mirror of https://github.com/kewlfft/ansible-aur
replace skip_installed by state
parent
dff3cfb450
commit
08c4dd6fbd
|
@ -15,16 +15,15 @@ The following helpers are supported and automatically selected, if present, in t
|
||||||
|parameter |required |default |choices |comments|
|
|parameter |required |default |choices |comments|
|
||||||
|--- |--- |--- |--- |---|
|
|--- |--- |--- |--- |---|
|
||||||
|name |no | | |Name or list of names of the package(s) to install or upgrade.|
|
|name |no | | |Name or list of names of the package(s) to install or upgrade.|
|
||||||
|
|state |no |present |present, latest |Present skips operations if the package is present.|
|
||||||
|upgrade |no |no |yes, no |Whether or not to upgrade whole system.|
|
|upgrade |no |no |yes, no |Whether or not to upgrade whole system.|
|
||||||
|use |no |auto |auto, yay, pacaur, trizen, pikaur, aurman, makepkg |The helper to use, 'auto' uses the first known helper found and makepkg as a fallback.|
|
|use |no |auto |auto, yay, pacaur, trizen, pikaur, aurman, makepkg |The helper to use, 'auto' uses the first known helper found and makepkg as a fallback.|
|
||||||
|skip_installed |no |no |yes, no |Skip operations if the package is present.|
|
|
||||||
|aur_only |no |no |yes, no |Limit operation to the AUR. Compatible with yay, pacaur, aurman and trizen.|
|
|aur_only |no |no |yes, no |Limit operation to the AUR. Compatible with yay, pacaur, aurman and trizen.|
|
||||||
|skip_pgp_check |no |no |yes, no |Only valid with makepkg. Skip PGP signatures verification of source file, useful when installing packages without GnuPG properly configured.|
|
|skip_pgp_check |no |no |yes, no |Only valid with makepkg. Skip PGP signatures verification of source file, useful when installing packages without GnuPG properly configured.|
|
||||||
|ignore_arch |no |no |yes, no |Only valid with makepkg. Ignore a missing or incomplete arch field, useful when the PKGBUILD does not have the arch=('yourarch') field.|
|
|ignore_arch |no |no |yes, no |Only valid with makepkg. Ignore a missing or incomplete arch field, useful when the PKGBUILD does not have the arch=('yourarch') field.|
|
||||||
|
|
||||||
### Note
|
### Note
|
||||||
* Either *name* or *upgrade* is required, both cannot be used together.
|
* Either *name* or *upgrade* is required, both cannot be used together.
|
||||||
* *skip_installed* cannot be used with *upgrade*.
|
|
||||||
* In the *use*=*auto* mode, makepkg is used as a fallback if no known helper is found.
|
* In the *use*=*auto* mode, makepkg is used as a fallback if no known helper is found.
|
||||||
|
|
||||||
## Installing
|
## Installing
|
||||||
|
@ -75,7 +74,7 @@ dependencies:
|
||||||
Use it in a task, as in the following examples:
|
Use it in a task, as in the following examples:
|
||||||
```
|
```
|
||||||
# Install trizen using makepkg, skip if trizen is already installed
|
# Install trizen using makepkg, skip if trizen is already installed
|
||||||
- aur: name=trizen use=makepkg skip_installed=true
|
- aur: name=trizen use=makepkg state=present
|
||||||
become: yes
|
become: yes
|
||||||
become_user: aur_builder
|
become_user: aur_builder
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,12 @@ options:
|
||||||
description:
|
description:
|
||||||
- Name or list of names of the package(s) to install or upgrade.
|
- Name or list of names of the package(s) to install or upgrade.
|
||||||
|
|
||||||
|
state:
|
||||||
|
description:
|
||||||
|
- Desired state of the package.
|
||||||
|
default: present
|
||||||
|
choices: [ present, latest ]
|
||||||
|
|
||||||
upgrade:
|
upgrade:
|
||||||
description:
|
description:
|
||||||
- Whether or not to upgrade whole system.
|
- Whether or not to upgrade whole system.
|
||||||
|
@ -37,12 +43,6 @@ options:
|
||||||
default: auto
|
default: auto
|
||||||
choices: [ auto, yay, pacaur, trizen, pikaur, aurman, makepkg ]
|
choices: [ auto, yay, pacaur, trizen, pikaur, aurman, makepkg ]
|
||||||
|
|
||||||
skip_installed:
|
|
||||||
description:
|
|
||||||
- Skip operations if the package is present.
|
|
||||||
type: bool
|
|
||||||
default: no
|
|
||||||
|
|
||||||
skip_pgp_check:
|
skip_pgp_check:
|
||||||
description:
|
description:
|
||||||
- Only valid with makepkg.
|
- Only valid with makepkg.
|
||||||
|
@ -75,7 +75,7 @@ helper:
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
- name: Install trizen using makepkg, skip if trizen is already installed
|
- name: Install trizen using makepkg, skip if trizen is already installed
|
||||||
aur: name=trizen use=makepkg skip_installed=true
|
aur: name=trizen use=makepkg state=present
|
||||||
become: yes
|
become: yes
|
||||||
become_user: aur_builder
|
become_user: aur_builder
|
||||||
'''
|
'''
|
||||||
|
@ -173,7 +173,7 @@ def upgrade(module, use, aur_only):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def install_packages(module, packages, use, skip_installed, aur_only):
|
def install_packages(module, packages, use, state, aur_only):
|
||||||
"""
|
"""
|
||||||
Install the specified packages
|
Install the specified packages
|
||||||
"""
|
"""
|
||||||
|
@ -182,7 +182,7 @@ def install_packages(module, packages, use, skip_installed, aur_only):
|
||||||
changed_iter = False
|
changed_iter = False
|
||||||
|
|
||||||
for package in packages:
|
for package in packages:
|
||||||
if skip_installed:
|
if state == "present":
|
||||||
if package_installed(module, package):
|
if package_installed(module, package):
|
||||||
rc = 0
|
rc = 0
|
||||||
continue
|
continue
|
||||||
|
@ -209,6 +209,10 @@ def main():
|
||||||
'name': {
|
'name': {
|
||||||
'type': 'list',
|
'type': 'list',
|
||||||
},
|
},
|
||||||
|
'state': {
|
||||||
|
'default': 'present',
|
||||||
|
'choices': ['present', 'latest'],
|
||||||
|
},
|
||||||
'ignore_arch': {
|
'ignore_arch': {
|
||||||
'default': False,
|
'default': False,
|
||||||
'type': 'bool',
|
'type': 'bool',
|
||||||
|
@ -221,10 +225,6 @@ def main():
|
||||||
'default': 'auto',
|
'default': 'auto',
|
||||||
'choices': ['auto'] + list(use_cmd.keys()),
|
'choices': ['auto'] + list(use_cmd.keys()),
|
||||||
},
|
},
|
||||||
'skip_installed': {
|
|
||||||
'default': False,
|
|
||||||
'type': 'bool',
|
|
||||||
},
|
|
||||||
'skip_pgp_check': {
|
'skip_pgp_check': {
|
||||||
'default': False,
|
'default': False,
|
||||||
'type': 'bool',
|
'type': 'bool',
|
||||||
|
@ -253,13 +253,13 @@ def main():
|
||||||
else:
|
else:
|
||||||
use = params['use']
|
use = params['use']
|
||||||
|
|
||||||
if params['upgrade'] and (params['name'] or params['skip_installed'] or use == 'makepkg'):
|
if params['upgrade'] and (params['name'] or use == 'makepkg'):
|
||||||
module.fail_json(msg="Upgrade cannot be used with this option.")
|
module.fail_json(msg="Upgrade cannot be used with this option.")
|
||||||
else:
|
else:
|
||||||
if params['upgrade']:
|
if params['upgrade']:
|
||||||
upgrade(module, use, params['aur_only'])
|
upgrade(module, use, params['aur_only'])
|
||||||
else:
|
else:
|
||||||
install_packages(module, params['name'], use, params['skip_installed'], params['aur_only'])
|
install_packages(module, params['name'], use, params['state'], params['aur_only'])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue