簡體   English   中英

無法通過 ansible 卡扣模塊安裝 package

[英]Cant install package via ansible snap module

我只想通過ansible使用分子做一個簡單的任務。 下面的代碼:

- name: Continue to install applications
  snap:
    name: "{{ item }}"
    classic: true
  loop:
    - bitwarden
    - clion

但我收到以下錯誤。 使用 --debug 選項我沒有得到更多信息

Task exception was never retrieved
future: <Task finished name='Task-19' coro=<_read_stream() done, defined at /home/vlad/.local/lib/python3.8/site-packages/subprocess_tee/__init__.py:21> exception=ValueError('Separator is found, but chunk is longer than limit')>
Traceback (most recent call last):
  File "/usr/lib/python3.8/asyncio/streams.py", line 540, in readline
    line = await self.readuntil(sep)
  File "/usr/lib/python3.8/asyncio/streams.py", line 635, in readuntil
    raise exceptions.LimitOverrunError(
asyncio.exceptions.LimitOverrunError: Separator is found, but chunk is longer than limit

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/vlad/.local/lib/python3.8/site-packages/subprocess_tee/__init__.py", line 23, in _read_stream
    line = await stream.readline()
  File "/usr/lib/python3.8/asyncio/streams.py", line 549, in readline
    raise ValueError(e.args[0])
ValueError: Separator is found, but chunk is longer than limit
CRITICAL Ansible return code was 2, command was: ansible-playbook --diff --inventory....

Ansible 版本:

ansible 2.10.4
  config file = None
  configured module search path = ['/home/vlad/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/vlad/.local/lib/python3.8/site-packages/ansible
  executable location = /home/vlad/.local/bin/ansible
  python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]

分子版:

molecule 3.2.2 using python 3.8 
    ansible:2.10.4
    delegated:3.2.2 from molecule
    vagrant:0.6.1 from molecule_vagrant

我可以在 Ubuntu Ubuntu 20.04.1 LTS上使用snap ansible 模塊安裝 snap 包

代碼:

---

- name: Playbook for installing required packages
  hosts: localhost
  gather_facts: True
  connection: local
  become: yes
  become_user: root

  tasks:

  - name: Install required packages
    snap:
      classic: yes
      state: present
      name:
        - bitwarden
        - clion

我檢查了機器日志,當 ansible 嘗試在我的情況下安裝 snap 時,memory 已用完

對於將來遇到同樣錯誤的人。 該錯誤似乎與 snap 模塊或任何其他模塊無關。 output 將打印在 stdout/stderr 上,新行 (\n) 將轉義到 \\n。 stream 模塊會嘗試在內容中查找 b'\n' ,但是由於新行被轉義,所以無法找到。 所以會引發錯誤。

如問題中所述,錯誤來源是 asyncio/streams.py 模塊,而不是 ansible 本身。

解決此問題的一種方法是通過對任務使用 no_log: true 來限制 ansible output。

ansible 將打印合理的錯誤信息,而不是拋出 python 的錯誤。

- name: Check hbase regionserver jmx exporter
  hosts: hbase_regionservers
  tasks:
    - name: Check 'num regions' item
      uri:
        url: "http://{{ inventory_hostname }}:26010/metrics"
        return_content: true
      register: metrics
      no_log: true
      failed_when: metrics.content.find('hbase_regionserver_tables_num_tables 2.0') == -1

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM