Ansible Module 활용 - Service Facts > Ansible 자료실

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

Ansible 자료실

실습 Ansible Module 활용 - Service Facts

페이지 정보

profile_image
작성자 AnsibleM
댓글 0건 조회 8,689회 작성일 21-07-29 16:21

본문

Service Facts 모듈은 대상 서버의 서비스 상태 정보를 facts 데이터로 반환하는 Ansible 모듈입니다.

1. Servie Facts 모듈 활용 예시

1
2
3
4
5
6
7
8
9
10
11
12
$ cat service_fact_test.yml
---
- name: service fact test
  hosts: all
  gather_facts: false
  tasks:
  - name: service test
    service_facts:
 
  - name: debug
    debug:
      msg: "{{ ansible_facts.services }}"
cs



2. 활용 가능한 Service Facts 결과 예시

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
$ ansible-playbook -i inventory service_test.yml
(. . . 중 략 . . .)
TASK [debug] ********************************************
    "msg": {
        "NetworkManager-dispatcher.service": {
            "name""NetworkManager-dispatcher.service",
            "source""systemd",
            "state""inactive",
            "status""enabled"
        },
        "NetworkManager-wait-online.service": {
            "name""NetworkManager-wait-online.service",
            "source""systemd",
            "state""stopped",
            "status""enabled"
        },
        "NetworkManager.service": {
            "name""NetworkManager.service",
            "source""systemd",
            "state""running",
            "status""enabled"
        },
        "arp-ethers.service": {
            "name""arp-ethers.service",
            "source""systemd",
            "state""inactive",
            "status""disabled"
        },
        "auditd.service": {
            "name""auditd.service",
            "source""systemd",
            "state""running",
            "status""enabled"
        },
 
 
PLAY RECAP **********************************************
test                     : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
cs



3. 특정 서비스 상태 확인 예시

1
2
3
4
5
6
7
8
9
10
11
---
- name: service facts test
  hosts: all
  gather_facts: false
  tasks:
  - name: service test
    service_facts:
 
  - name: debug
    debug:
      msg: "{{ ansible_facts.services.kdump }}"
cs
> kdump 서비스 상태 확인 ( 예시 )


4. 특정 서비스 상태 확인 결과 예시

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ ansible-playbook -i inventory service_facts_test.yml
( . . . 중 략 . . .)
TASK [debug] ************************************
ok: [test] => {
    "msg": {
        "name""kdump",
        "source""sysv",
        "state""stopped",
        "status""enabled"
    }
}
 
PLAY RECAP **************************************
test                     : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
cs

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

사이트 정보

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

접속자집계

오늘
618
어제
1,598
최대
3,935
전체
803,365
Copyright © www.linuxdata.org All rights reserved.