0
私は以下のようなプレイブックを持っています。式の値を変数として定義できますか?
- name: ensure crm service is exist
shell: crm resource status {{item.service}}
register: is_service_exist
with_items: "{{crm_services}}"
run_once: true
delegate_to: "{{controller_master}}"
when: crm_services is defined
ignore_errors: True
- name: msg
vars:
service_is_exist: var[{{is_service_exist.results[0].stderr.find('not found')}}==-1]
debug: msg={{service_is_exist}}]
- name: stop crm service
shell: crm resource stop {{item.service}}
with_items: "{{crm_services}}"
run_once: true
delegate_to: "{{controller_master}}"
when: crm_services is defined and is_service_exist.results[0].stderr.find('not found')==-1
- name: uninstall current rpm packages
shell: rpm -e --nodeps {{item.package}}
with_items: "{{packages}}"
ignore_errors: True
crm_serviceが存在するかどうか、crm_serviceが存在するかどうかを知りたい場合は、サービスを停止し、現在のrpmパッケージをアンインストールします。 私はis_service_exist.results[0].stderr.find('not found')==-1
が読みやすいとは思いませんので、私は変数として式を設定したいと思いますか?
私はvar[{{is_service_exist.results[0].stderr.find('not found')}}==-1]
を試してみましたが、出力は、この "MSG" のようなものです: "のvar [-1 == - 1]" だから
、変数と式の値を定義ansibleことができますか?