- hosts: web1
tasks:
- service:
name: httpd
state: started
Make changes in the playbook so that httpd server reloads after copying the file, make sure it does not restart the httpd server.
- hosts: all
gather_facts: no
tasks:
- name: Copy Apache welcome file
copy:
src: index.html
dest: /var/www/html/index.html
- name: reload
service:
name: httpd
state: reloaded
port: 80. → 443 변경 후 httpf 서비스 재시작
- hosts: all
gather_facts: no
tasks:
- name: Make changes in Apache config
replace:
path: /etc/httpd/conf/httpd.conf
regexp: "^Listen 80"
replace: "Listen 443"
- name: Restart Apache
service:
name: httpd
state: restarted
Nginx를 설치하고 재부팅 때마다 자동 실행
---
- name: nginx
gather_facts: no
hosts: web1
tasks:
- name: install nginx
yum:
name: nginx
state: installed
- name: restart
service:
name: nginx
state: started
enabled: yes