반응형
---
- name: "Change Service State "
hosts: all
become: true
tasks:
- name: "Change Service State "
service:
name: "{{ service_name }}"
# state : reloaded|restarted|started|stopped
state: "{{ service_state }}"
# enabled : yes|no
enabled: "{{ service_enable }}"
# 조건 : centos 6 or 7 인 경우만
when:
- ansible_facts['distribution'] == "CentOS"
- ( ansible_facts['distribution_major_version'] == "6" or ansible_facts['distribution_major_version'] == "7" )
- name: "Change Service State "
service:
name: "{{ service_name }}"
# 서비스 바이너리 경로 ex)/usr/bin/name
pattern: "{{ service_path }}"
state: "{{ service_state }}"
enabled: "{{ service_enable }}"
when:
- ansible_facts['distribution'] != "CentOS"
반응형
'Automation Tools > Ansible' 카테고리의 다른 글
8.4 ansible | [playbook] nodejs, npm 설치 (0) | 2021.03.16 |
---|---|
8.3 ansible | [playbook] centos6 yum repository 변경 (0) | 2021.03.16 |
8.1 ansible | [playbook] Linux user 추가 (0) | 2021.03.16 |
7. ansible inventory 설정 과 playbook 실행 (0) | 2021.03.16 |
6. ansible | Docker jenkins 설치 (0) | 2021.03.16 |