i would like please to know if there is a way in a loop with_item.
чтобы проверить и пропустить установку зависимостей apt
если уже установлено с условием «когда»
if im adding the "when" condition in the end of the with_item list , its look like the condition check all the list instead of checking just the relevant - in this example python2
- name: check if python already installed
shell: dpkg-query -W python2.7
register: check_python2
ignore_errors: True
- name: Install apt dependencies
apt:
name: "{{item.name}}{{item.version}}"
state: present
allow_unauthenticated: yes
force: yes
with_items:
- { name: 'python2.7', version: '' }
- { name: 'ruby', version: '' }
- { name: 'postgresql-9.5', version: '' }
- { name: 'postgresql-contrib-9.5', version: '' }
- { name: 'libpq-dev', version: '' }
- { name: 'nodejs', version: '=9.*' }
- { name: 'python-setuptools', version: '' }
- { name: 'python-pip', version: '' }
- { name: 'python-pkg-resources', version: '' }
- { name: 'sshpass', version: '' }
- { name: 'zip', version: '' }
- { name: 'mongodb-org', version: '=4.0.0' }
- { name: 'libfontconfig', version: '' }
- { name: 'ntp', version: '' }
- { name: 'fio', version: '' }
when: check_python2.rc != 0
when: check_ruby.rc != 0
как добавить условие "когда", чтобы проверить только правильные зависимости
Я хотел бы проверить все зависимости:
и если один из них не установлен, установите его, иначе пропустите