<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>41494</bug_id>
          
          <creation_ts>2021-12-02 19:31:35 +0300</creation_ts>
          <short_desc>При наличии perl-Package ansible модуль package пытается использовать pkg5</short_desc>
          <delta_ts>2021-12-07 14:49:27 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>ansible</component>
          <version>unstable</version>
          <rep_platform>x86_64</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Slava Aseev">ptrnine</reporter>
          <assigned_to name="Andrey Cherepanov">cas</assigned_to>
          <cc>cas</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>205637</commentid>
    <comment_count>0</comment_count>
    <who name="Slava Aseev">ptrnine</who>
    <bug_when>2021-12-02 19:31:35 +0300</bug_when>
    <thetext>Если в системе установлен perl-Package (со своим /usr/bin/pkg), то модуль package пытается использовать pkg5 вместо apt_rpm.

Убедиться можно просто, вот такой плейбук при повторном запуске выдаст ошибку (при первом же сначала установит пакет perl-Package):
---
- name: &quot;Test&quot;
  hosts: somehost

  tasks:
  - name: test
    package:
      state: present
      name: perl-Package

Сама ошибка:
FAILED! =&gt; {
    &quot;changed&quot;: false,
    &quot;module_stderr&quot;: &quot;Shared connection to 10.88.15.103 closed.\r\n&quot;,
    &quot;module_stdout&quot;: &quot;...&quot;,
    &quot;msg&quot;: &quot;MODULE FAILURE\nSee stdout/stderr for the exact error&quot;,
    &quot;rc&quot;: 1
}

module_stdout в более-менее читабельном виде:

Traceback (most recent call last):
  File &quot;/root/.ansible/tmp/ansible-tmp-1638461393.9872942-13059-89818530951856/AnsiballZ_pkg5.py&quot;, line 102, in &lt;module&gt;
    _ansiballz_main()
  File &quot;/root/.ansible/tmp/ansible-tmp-1638461393.9872942-13059-89818530951856/AnsiballZ_pkg5.py&quot;, line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File &quot;/root/.ansible/tmp/ansible-tmp-1638461393.9872942-13059-89818530951856/AnsiballZ_pkg5.py&quot;, line 40, in invoke_module
    runpy.run_module(mod_name=&apos;ansible.modules.packaging.os.pkg5&apos;, init_globals=None, run_name=&apos;__main__&apos;, alter_sys=True)
  File &quot;/usr/lib64/python3.9/runpy.py&quot;, line 210, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File &quot;/usr/lib64/python3.9/runpy.py&quot;, line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File &quot;/usr/lib64/python3.9/runpy.py&quot;, line 87, in _run_code
    exec(code, run_globals)
  File &quot;/tmp/.private/root/ansible_pkg5_payload_a4h3htv4/ansible_pkg5_payload.zip/ansible/modules/packaging/os/pkg5.py&quot;, line 182, in &lt;module&gt;
  File &quot;/tmp/.private/root/ansible_pkg5_payload_a4h3htv4/ansible_pkg5_payload.zip/ansible/modules/packaging/os/pkg5.py&quot;, line 106, in main
  File &quot;/tmp/.private/root/ansible_pkg5_payload_a4h3htv4/ansible_pkg5_payload.zip/ansible/modules/packaging/os/pkg5.py&quot;, line 157, in ensure
TypeError: can only concatenate list (not &quot;filter&quot;) to list

Судя по lib/ansible/module_utils/facts/system/pkg_mgr.py причина тут в том, что последний найденный package manager оказывается в приоритете. Потому и получаем pkg5 вместо apt.
http://git.altlinux.org/gears/a/ansible.git?p=ansible.git;a=blob;f=lib/ansible/module_utils/facts/system/pkg_mgr.py;h=4fe36ff7aadb8a540b988670c7f5ca862aa47a84;hb=8c37018a689fba2462f5f972616b256b0ef804b1#l13</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>205693</commentid>
    <comment_count>1</comment_count>
    <who name="Slava Aseev">ptrnine</who>
    <bug_when>2021-12-03 19:10:42 +0300</bug_when>
    <thetext>Сделал PR: https://github.com/ansible/ansible/pull/76457
В принципе, могу пока сделать патч у нас. Непонятно, пройдет ли в апстрим.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>205694</commentid>
    <comment_count>2</comment_count>
    <who name="Andrey Cherepanov">cas</who>
    <bug_when>2021-12-03 19:14:23 +0300</bug_when>
    <thetext>(Ответ для Slava Aseev на комментарий #1)
&gt; Сделал PR: https://github.com/ansible/ansible/pull/76457
&gt; В принципе, могу пока сделать патч у нас. Непонятно, пройдет ли в апстрим.

Я сейчас собираю ansible на stable-2.9 и ansible-core на master. Можно и туда и туда. Спасибо за патч.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>205814</commentid>
    <comment_count>3</comment_count>
    <who name="Repository Robot">repository-robot</who>
    <bug_when>2021-12-07 14:49:27 +0300</bug_when>
    <thetext>ansible-2.9.26-alt3 -&gt; sisyphus:

 Tue Dec 07 2021 Slava Aseev &lt;ptrnine@altlinux&gt; 2.9.26-alt3
 - Prohibit pkg5 usage (closes: #41494)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>