Ansible 학습 03 - handlers
일부 프로필 을 수정 하려 면 다시 불 러 오 거나 서 비 스 를 다시 시작 해 야 합 니 다. 예 를 들 어 nginx 의 listen 80 을 수정 해 야 합 니 다.listen 8080 으로 변경 하기;nginx 를 다시 불 러 와 야 합 니 다.
meta 작업 의 매개 변수 값 은 flushhandlers, "meta: flush handlers" 는 이전의 task 에 대응 하 는 handler 를 즉시 실행 하 는 것 을 의미 합 니 다. 무슨 뜻 입 니까?즉, 현재 meta 작업 전에 모두 두 개의 작업 이 있 습 니 다. task 1 과 task 2 는 모두 대응 하 는 handler 가 있 습 니 다. task 1 과 task 2 를 실행 한 후에 대응 하 는 handler 를 즉시 실행 합 니 다. 기본 적 인 상황 처럼 모든 작업 을 수행 한 후에 야 각 handler 를 실행 할 수 있 습 니 다.
- hosts: docker
remote_user: root
vars:
epic: true
tasks:
- name: gouuradd erp
group: name=erp gid=1008
notify:
useradd erp
- meta: flush_handlers
- name: nginx.conf
lineinfile:
dest=/data/sh/nginx.conf
regexp="listen 9080"
line="listen 8081\;"
backrefs=yes
backup=yes
tags: hanye3
notify:
restart nginx
handlers:
- name: restart nginx
service: name=nginx state=restarted
- name: useradd erp
user: name=erp uid=1008 group=erp password="$6$O9KDopiuPgvkrb4z$ee7/lfljSe79zQLIvDROsFM23hAJRRvVc.JoBWPGW/erp shell=/bin/bash"
여러 handlers 호출
하나의 task 가 여러 개의 handler 를 호출 하려 고 할 때 가장 먼저 생각 하 는 것 은 하나의 handler 가 여러 개의 name 을 써 서 이 루어 질 수 있다 는 것 입 니 다. 그러나 이것 은 통 하지 않 습 니 다. 하나의 handler 는 하나의 handler name 만 정의 할 수 있 습 니 다. 여러 개의 handler 를 호출 하려 면 여러 개 를 한 그룹 (listen) 으로 나 누 어야 합 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
IBM Cloud Virtual Server for Classic에서 Red Hat Enterprise Linux 8에 Ansible 설치IBM Cloud Virtual Server for Classic에서 Red Hat Enterprise Linux 8이 2020년 7월 26일에 출시되었습니다. 프로비저닝한 결과 위에서 설명한 대로 버전이 8.2로 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.