Ansible - Playbook 에러 처리 > Ansible 자료실

본문 바로가기
사이트 내 전체검색

Ansible 자료실

운영 Ansible - Playbook 에러 처리

페이지 정보

profile_image
작성자 AnsibleM
댓글 0건 조회 11,336회 작성일 21-04-14 14:13

본문

Ansible 은 0이 아닌 return code 를 수신하거나 모듈에서 오류를 수신하면 해당 호스트에서 실행을 중지하고 다른 호스트로 넘어가게 됩니다.
때로는 특정 호스트의 오류로 인해 모든 호스트에서 실행이 중지되기를 원합니다.
Ansible 은 이러한 상황을 처리하고 원하는 동작, 출력 및 보고를 얻는 데 도움이 되는 설정을 제공합니다.


1. ignore_errors

기본적으로 Ansible 은 특정 호스트에서 작업이 실패하면 해당 호스트에서 작업 실행을 중지합니다.
ignore_errors : 오류가 발생하더라도, 작업 실행을 계속 진행하는 옵션으로, return 값이 'failed' 일 때만 수행 가능

1
2
3
- name: Do not count this as a failure
  command: /bin/false
  ignore_errors: yes
cs



2. ignore_unreachable

ignore_unreachable : 대상 호스트가 unreachable 일 경우 이로 인한 작업 실패를 무시할 수 있으며, 연결할 수 없는 호스트에 대해 향후 작업을 계속 실행

1
2
3
4
5
6
- name: This executes, fails, and the failure is ignored
  command: /bin/true
  ignore_unreachable: yes
 
- name: This executes, fails, and ends the play for this host
  command: /bin/true
cs


1
2
3
4
5
6
7
8
9
- hosts: all
  ignore_unreachable: yes
  tasks:
  - name: This executes, fails, and the failure is ignored
    command: /bin/true
 
  - name: This executes, fails, and ends the play for this host
    command: /bin/true
    ignore_unreachable: no
cs



3. clear_host_errors

Ansible이 특정 호스트에 연결할 수 없는 경우 해당 호스트를 'UNREACHABLE'로 표시하고 활성 호스트 목록에서 제거합니다.
clear_host_errors : 모든 호스트를 다시 활성화 할 수 있는 옵션으로, 후속 작업에서 다시 연결할 수 있음

1
2
3
4
5
6
7
8
# Example showing how to continue using a failed target
- name: Bring host back to play after failure
  copy:
    src: file
    dest: /etc/file
  remote_user: imightnothavepermission
 
- meta: clear_host_errors
cs

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

사이트 정보

회사명 : (주)리눅스데이타시스템 / 대표 : 정정모
서울본사 : 서울특별시 강남구 봉은사로 114길 40 홍선빌딩 2층 / tel : 02-6207-1160
대전지사 : 대전광역시 유성구 노은로174 도원프라자 5층 / tel : 042-331-1161

접속자집계

오늘
275
어제
1,612
최대
3,935
전체
794,746
Copyright © www.linuxdata.org All rights reserved.