Dosyalar
ansible-deploy/playbooks/deploy-nginx.yml
T

54 satır
1.1 KiB
YAML

---
# 部署Nginx
- name: Deploy Nginx
hosts: "{{ target_hosts | default('all') }}"
become: yes
vars:
nginx_worker_processes: auto
nginx_worker_connections: 1024
server_name: localhost
tasks:
- name: Install Nginx
apt:
name: nginx
state: present
when: ansible_os_family == "Debian"
- name: Install Nginx
yum:
name: nginx
state: present
when: ansible_os_family == "RedHat"
- name: Configure Nginx
template:
src: templates/nginx.conf.j2
dest: /etc/nginx/nginx.conf
mode: '0644'
notify: Restart Nginx
- name: Create site configuration
template:
src: templates/site.conf.j2
dest: /etc/nginx/conf.d/{{ server_name }}.conf
mode: '0644'
notify: Reload Nginx
- name: Start Nginx
service:
name: nginx
state: started
enabled: yes
handlers:
- name: Restart Nginx
service:
name: nginx
state: restarted
- name: Reload Nginx
service:
name: nginx
state: reloaded