14 Commits

Author SHA1 Message Date
kewl fft
fe050018db galaxy version updated to 0.11.1 2023-07-08 19:37:19 +01:00
kewl fft
326836ddbe galaxy version updated 2023-07-08 19:36:22 +01:00
kewl fft
583c7597a9 minor optimizations 2023-07-08 19:20:32 +01:00
kewl fft
cbf843e1db Replaced the changed_iter = changed_iter or ... statement with the changed_iter |= ... compound assignment operator for brevity 2023-07-08 18:56:02 +01:00
kewl fft
2a076dc6a0 optimize check_packages lists construction 2023-07-08 18:51:35 +01:00
kewl
8d177a7550 Merge pull request #78 from jp1995/master
fix for issue #77
2023-07-08 18:40:26 +01:00
kewl
b469b5a641 Merge pull request #73 from LorenzoBettini/LorenzoBettini-patch-1
"mode: 0644" in the README example
2023-07-08 18:30:26 +01:00
jp1995
63d3056a82 fix for issue #77 2023-07-07 18:15:52 +03:00
Lorenzo Bettini
91c6d70184 "mode: 0644" in the README example
When using ansible-lint it would complain about "risky-file-permissions: File permissions unset or incorrect".
Making the `mode` explicit avoids the problem
2022-05-24 14:29:56 +02:00
kewl
9b25b11cea Merge pull request #66 from gotmax23/master
Remove unnecessary files from collection tarball
2021-11-08 11:03:48 +00:00
kewl
2c090a49a8 Merge pull request #67 from LorenzoBettini/patch-1
Use become: yes in the example for creating aur_builder
2021-11-08 08:18:34 +00:00
Lorenzo Bettini
07e5fe301f Use become: yes in the example for creating aur_builder
It is my understanding that for creating the `aur_builder` you have to become root; maybe that's something one does in the whole playbook, but if one wants to specify that only when it's needed, the example could be improved as suggested, so that it's self-contained and can be simply copied and pasted.
2021-11-07 13:08:56 +01:00
Maxwell G
49a077790e Remove unnecessary files from collection tarball 2021-11-04 16:55:37 -05:00
kewl fft
87a15853fa proper version bump 2021-11-04 21:44:50 +00:00
4 changed files with 18 additions and 25 deletions

View File

@@ -25,10 +25,10 @@ jobs:
[ "$(cat galaxy.yml | grep version: | awk '{print $2}')" = $(awk -F '/' '{print substr($3, 2)}' <<< ${GITHUB_REF}) ] || exit 1 [ "$(cat galaxy.yml | grep version: | awk '{print $2}')" = $(awk -F '/' '{print substr($3, 2)}' <<< ${GITHUB_REF}) ] || exit 1
echo ::set-output name=version::$(awk -F '/' '{print substr($3, 2)}' <<< ${GITHUB_REF}) echo ::set-output name=version::$(awk -F '/' '{print substr($3, 2)}' <<< ${GITHUB_REF})
- name: "Set up Python 3.9" - name: "Set up Python"
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
python-version: "3.9" python-version: "3.11"
- name: Generate cache keys - name: Generate cache keys
id: keys id: keys

View File

@@ -97,16 +97,19 @@ This user can be created in an Ansible task with the following actions:
```yaml ```yaml
- name: Create the `aur_builder` user - name: Create the `aur_builder` user
become: yes
ansible.builtin.user: ansible.builtin.user:
name: aur_builder name: aur_builder
create_home: yes create_home: yes
group: wheel group: wheel
- name: Allow the `aur_builder` user to run `sudo pacman` without a password - name: Allow the `aur_builder` user to run `sudo pacman` without a password
become: yes
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: /etc/sudoers.d/11-install-aur_builder path: /etc/sudoers.d/11-install-aur_builder
line: 'aur_builder ALL=(ALL) NOPASSWD: /usr/bin/pacman' line: 'aur_builder ALL=(ALL) NOPASSWD: /usr/bin/pacman'
create: yes create: yes
mode: 0644
validate: 'visudo -cf %s' validate: 'visudo -cf %s'
``` ```

View File

@@ -8,7 +8,7 @@ namespace: kewlfft
name: aur name: aur
# The version of the collection. Must be compatible with semantic versioning # The version of the collection. Must be compatible with semantic versioning
version: 0.9.3 version: 0.11.1
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection # The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md readme: README.md
@@ -65,4 +65,6 @@ issues: https://github.com/kewlfft/ansible-aur/issues
# artifact. A pattern is matched from the relative path of the file or directory of the collection directory. This # artifact. A pattern is matched from the relative path of the file or directory of the collection directory. This
# uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry', # uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry',
# and '.git' are always filtered # and '.git' are always filtered
build_ignore: [] build_ignore:
- .github
- .gitignore

View File

@@ -138,18 +138,8 @@ def check_packages(module, packages):
""" """
Inform the user what would change if the module were run Inform the user what would change if the module were run
""" """
would_be_changed = [] would_be_changed = [package for package in packages if not package_installed(module, package)]
diff = { diff = {'before': '', 'after': '\n'.join(package for package in would_be_changed if module._diff)}
'before': '',
'after': '',
}
for package in packages:
installed = package_installed(module, package)
if not installed:
would_be_changed.append(package)
if module._diff:
diff['after'] += package + "\n"
if would_be_changed: if would_be_changed:
status = True status = True
@@ -231,11 +221,10 @@ def check_upgrade(module, use):
Inform user how many packages would be upgraded Inform user how many packages would be upgraded
""" """
rc, stdout, stderr = module.run_command([use, '-Qu'], check_rc=True) rc, stdout, stderr = module.run_command([use, '-Qu'], check_rc=True)
data = stdout.split('\n') num_packages = sum(1 for line in stdout.splitlines() if line.strip())
data.remove('')
module.exit_json( module.exit_json(
changed=len(data) > 0, changed=num_packages > 0,
msg="{} package(s) would be upgraded".format(len(data)), msg=f"{num_packages} package(s) would be upgraded",
helper=use, helper=use,
) )
@@ -270,8 +259,7 @@ def install_packages(module, packages, use, extra_args, state, skip_pgp_check, i
changed_iter = False changed_iter = False
for package in packages: for package in packages:
if state == 'present': if state == 'present' and package_installed(module, package):
if package_installed(module, package):
rc = 0 rc = 0
continue continue
if use == 'makepkg': if use == 'makepkg':
@@ -283,7 +271,7 @@ def install_packages(module, packages, use, extra_args, state, skip_pgp_check, i
command.append(package) command.append(package)
rc, out, err = module.run_command(command, check_rc=True) rc, out, err = module.run_command(command, check_rc=True)
changed_iter = changed_iter or not (out == '' or '-- skipping' in out or 'nothing to do' in out.lower()) changed_iter |= not (out == '' or 'up-to-date -- skipping' in out or 'nothing to do' in out.lower())
message = 'installed package(s)' if changed_iter else 'package(s) already installed' message = 'installed package(s)' if changed_iter else 'package(s) already installed'