Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pacman: diff output is wrong when VerbosePkgLists is enabled #3783

Closed
1 task done
jraby opened this issue Nov 24, 2021 · 4 comments
Closed
1 task done

pacman: diff output is wrong when VerbosePkgLists is enabled #3783

jraby opened this issue Nov 24, 2021 · 4 comments
Labels
bug This issue/PR relates to a bug module module os packaging plugins plugin (any type)

Comments

@jraby
Copy link
Contributor

jraby commented Nov 24, 2021

Summary

If VerbosePkgLists is present in pacman.conf, the diff output generated by the pacman plugin is broken:

TASK [common : workstation pkgs] *************************************************************************************************************
--- before
+++ after
@@ -0,0 +1,4 @@
+New
+Version
+Net
+Change

Issue Type

Bug Report

Component Name

pacman

Ansible Version

$ ansible --version
ansible [core 2.12.0]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/jean/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/jean/.ansible/collections:/usr/share/ansible/collections
  executable location = /bin/ansible
  python version = 3.9.7 (default, Oct 10 2021, 15:13:22) [GCC 11.1.0]
  jinja version = 3.0.3
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
Collection        Version
----------------- -------
community.general 3.8.1

Configuration

$ ansible-config dump --only-changed

OS / Environment

Arch

Steps to Reproduce

Add VerbosePkgLists to /etc/pacman.conf and run a task that installs a pkg via pacman.

Expected Results

TASK [common : workstation pkgs] ************************************************************************************************************ 
--- before
+++ after
@@ -0,0 +1 @@
+plasma-firewall-5.23.3-1

changed: [localhost]

Actual Results

TASK [common : workstation pkgs] *************************************************************************************************************
--- before
+++ after
@@ -0,0 +1,4 @@
+New
+Version
+Net
+Change

changed: [localhost]

The module expects the default output from pacman and cannot currently cope with the verbose output.

Since it is not possible to turn off the verbose output from pacman's cli, I ended up adding a simple wrapper script that uses pacman-conf to grep out the verbose output option and using that as pacman's executable:

    - name: pacman-noverbosepkglist                                                                                                                                                                                                                                                        
      copy:                                                                                                                                                                                                                                                                                
        content: |                                                                                                                                                                                                                                                                         
            #!/bin/sh                                                                                                                                                                                                                                                                      
            /usr/bin/pacman-conf | /bin/grep -v '^VerbosePkgLists$' | /usr/bin/pacman --config /dev/stdin "$@"                                                                                                                                                                             
        dest:  /usr/local/bin/pacman-noverbosepkglists
        owner: root                                                                                                                                                                                                                                                                        
        group: root                                                                                                                                                                                                                                                                        
        mode: 0555 
    - name: workstation pkgs                                                                                                                                                                                                                                                               
      community.general.pacman:                                                                                                                                                                                                                                                            
        executable: /usr/local/bin/pacman-noverbosepkglists
        name:                                                                                                                                                                                                                                                                              
          - plasma-firewall                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

I feel like the pacman module should work regardless of what display options are used in the system config file, but at the same time I'm not sure how to fix this properly.
Relying on the human readable output of the tool feels brittle and adding a new parser for the verbose output wouldn't help in the long run if that format ever changes.
I kinda wish pacman could output in a stable format, like json or something like that.

In any case, maybe the above will help other people who like the Verbose format :-)

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module os packaging plugins plugin (any type) labels Nov 24, 2021
@felixfontein
Copy link
Collaborator

I kinda wish pacman could output in a stable format, like json or something like that.

Fully agree! This is something that so many package managers (and other programs) do wrong, and which every time leads to the same hassles :)

@jraby
Copy link
Contributor Author

jraby commented Feb 24, 2022

fixed in #3907

@jraby jraby closed this as completed Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module os packaging plugins plugin (any type)
Projects
None yet
Development

No branches or pull requests

3 participants