无法通过可见的snap模块安装包



我只是想通过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

我能够使用UbuntuUbuntu 20.04.1 LTS上的snapansible模块安装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

我检查了机器日志,当我尝试在我的情况下安装snap时,有一个步骤内存不足

给将来犯同样错误的人。似乎错误与snap模块或任何其他模块无关。输出将在stdout/stderr上打印,新行(n)将被转义为\n。流模块将尝试在内容中找到b'n',但由于新行被转义,它将无法找到它。因此会引发错误。

正如问题中提到的,错误的来源是asyncio/streams.py模块,而不是它自己。

克服这个问题的一种方法是通过对任务使用no_log: true来限制可见输出。

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

最新更新