Używam ansibl wdrożyć mojego projektu i próbuje sprawdzić, czy zainstalowany jest określony pakiet, ale mam problem z tym zadaniem, oto zadanie:Moduł Ansible Command mówi, że '|' jest nielegalny charakter
- name: Check if python-apt is installed
command: dpkg -l | grep python-apt
register: python_apt_installed
ignore_errors: True
I tu jest problem:
$ ansible-playbook -i hosts idempotent.yml
PLAY [lxc-host] ***************************************************************
GATHERING FACTS ***************************************************************
ok: [10.0.3.240]
TASK: [idempotent | Check if python-apt is installed] *************************
failed: [10.0.3.240] => {"changed": true, "cmd": ["dpkg", "-l", "|", "grep", "python-apt"], "delta": "0:00:00.015524", "end": "2014-07-10 14:41:35.207971", "rc": 2, "start": "2014-07-10 14:41:35.192447"}
stderr: dpkg-query: error: package name in specifier '|' is illegal: must start with an alphanumeric character
...ignoring
PLAY RECAP ********************************************************************
10.0.3.240 : ok=2 changed=1 unreachable=0 failed=0
Dlaczego ta postać jest nielegalna? "|".
Btw, według https://github.com/ansible/ansible/pull/4617 'python-apt' powinny być instalowane automatycznie podczas korzystania' apt 'mo dule, więc nie powinieneś ręcznie ładować go. – Mxx
użyj modułu 'shell' jeśli chcesz użyć' pipe' – deepdive