Devops
ansible 조건 예제
세모데
2018. 2. 12. 13:44
1. when
- name : check
yum:
name: mariadb-server
state: latest
with_items: "{{ ansible_mounts }}"
when: item.mount == "/" and item.size_availabe > 300000
2. 조건 판단
- hosts : all
tasks:
- name :
command: /usr/bin/systemctl is-active postfix
ignore_errors: yes
register: result (결과저장)
- name:
service:
name: httpd
state: restarted
when: result.rc == 0
postfix가 활성화 되어 있으면 httpd를 restart