mirror of
				https://github.com/kewlfft/ansible-aur.git
				synced 2025-11-04 10:02:30 +03:00 
			
		
		
		
	support name type list
This commit is contained in:
		
							
								
								
									
										44
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										44
									
								
								README.md
									
									
									
									
									
								
							@@ -13,7 +13,7 @@
 | 
				
			|||||||
## Options
 | 
					## Options
 | 
				
			||||||
|parameter|required |default |choices                     |comments|
 | 
					|parameter|required |default |choices                     |comments|
 | 
				
			||||||
|---      |---      |---     |---                         |---|
 | 
					|---      |---      |---     |---                         |---|
 | 
				
			||||||
|name     |no       |        |                            |Name of the package to install or upgrade.|
 | 
					|name     |no       |        |                            |Name or list of names of the package(s) to install or upgrade.|
 | 
				
			||||||
|upgrade  |no       |no      |yes, no                     |Whether or not to upgrade whole system.|
 | 
					|upgrade  |no       |no      |yes, no                     |Whether or not to upgrade whole system.|
 | 
				
			||||||
|helper   |no       |pacaur  |pacaur, trizen, yaourt, yay |Helper to use.|
 | 
					|helper   |no       |pacaur  |pacaur, trizen, yaourt, yay |Helper to use.|
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -21,28 +21,32 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
## Usage
 | 
					## Usage
 | 
				
			||||||
1. Add as a submodule in your playbook:
 | 
					1. Add as a submodule in your playbook:
 | 
				
			||||||
   ```
 | 
					  ```
 | 
				
			||||||
   mkdir -p library/external_modules
 | 
					  mkdir -p library/external_modules
 | 
				
			||||||
   git submodule add git://github.com/kewlfft/ansible-aur.git library/external_modules/ansible-aur
 | 
					  git submodule add git://github.com/kewlfft/ansible-aur.git library/external_modules/ansible-aur
 | 
				
			||||||
   ```
 | 
					  ```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
2. Link the binary to the base of `library/`:
 | 
					2. Link the binary to the base of `library/`:
 | 
				
			||||||
   ```
 | 
					  ```
 | 
				
			||||||
   ln -s external_modules/ansible-aur/aur library/aur
 | 
					  ln -s external_modules/ansible-aur/aur library/aur
 | 
				
			||||||
   ```
 | 
					  ```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
3. Use it in a task, as in the following examples:
 | 
					3. Use it in a task, as in the following examples:
 | 
				
			||||||
   ```
 | 
					  ```
 | 
				
			||||||
   # Install (using pacaur)
 | 
					  # Install (using pacaur)
 | 
				
			||||||
   - aur: name=package_name
 | 
					  - aur: name=package_name
 | 
				
			||||||
     become: yes
 | 
					    become: yes
 | 
				
			||||||
     become_user: user_that_has_nopasswd_in_sudoers_for_pacman_use
 | 
					    become_user: user_that_has_nopasswd_in_sudoers_for_pacman_use
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   # Install (using trizen)
 | 
					  # Install (using trizen)
 | 
				
			||||||
   - aur: name=package_name helper=trizen
 | 
					  - aur:
 | 
				
			||||||
     [...]
 | 
					      helper: trizen
 | 
				
			||||||
 | 
					      name:
 | 
				
			||||||
 | 
					        - package_name_1
 | 
				
			||||||
 | 
					        - package_name_2 
 | 
				
			||||||
 | 
					    [...]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   # Upgrade (using pacaur)
 | 
					  # Upgrade (using pacaur)
 | 
				
			||||||
   - aur: upgrade=yes
 | 
					  - aur: upgrade=yes
 | 
				
			||||||
     [...]
 | 
					    [...]
 | 
				
			||||||
   ```
 | 
					  ```
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										16
									
								
								aur.py
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								aur.py
									
									
									
									
									
								
							@@ -24,18 +24,18 @@ def upgrade(module, helper):
 | 
				
			|||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def install_packages(module, package_name, helper):
 | 
					def install_packages(module, packages, helper):
 | 
				
			||||||
    assert helper in helper_cmd
 | 
					    assert helper in helper_cmd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    cmd = helper_cmd[helper] + [package_name]
 | 
					    changed_iter = False
 | 
				
			||||||
 | 
					    for package in packages:
 | 
				
			||||||
 | 
					        cmd = helper_cmd[helper] + [package]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if upgrade:
 | 
					        rc, out, err = module.run_command(cmd, check_rc=True)
 | 
				
			||||||
        cmd += ['-u']
 | 
					        changed_iter = changed_iter or not (out == '' or '-- skipping' in out)
 | 
				
			||||||
 | 
					 | 
				
			||||||
    rc, out, err = module.run_command(cmd, check_rc=True)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    module.exit_json(
 | 
					    module.exit_json(
 | 
				
			||||||
        changed=not (out == '' or '-- skipping' in out),
 | 
					        changed=changed_iter,
 | 
				
			||||||
        msg='installed package',
 | 
					        msg='installed package',
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -44,7 +44,7 @@ def main():
 | 
				
			|||||||
    module = AnsibleModule(
 | 
					    module = AnsibleModule(
 | 
				
			||||||
        argument_spec={
 | 
					        argument_spec={
 | 
				
			||||||
            'name': {
 | 
					            'name': {
 | 
				
			||||||
                'required': False,
 | 
					                'type': 'list',
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            'upgrade': {
 | 
					            'upgrade': {
 | 
				
			||||||
                'default': False,
 | 
					                'default': False,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user