Ansible安装Nginx

  • Post author:
  • Post category:Ansible
  • Page Views 471 阅读

1.deploy_nginx.yml

---
- hosts: webservers
  become: yes
  become_method: sudo
  vars:
    worker_processes: 4
    worker_connections: 1000
    max_open_files: 1000
  tasks:
    - name: install nginx
      yum: name=nginx state=latest
 
    - name: copy nginx config file
      template: src=/root/nginx.conf.j2 dest=/etc/nginx/nginx.conf
      notify: restart nginx
 
  handlers:
    - name: restart nginx
      service: name=nginx state=restarted

2.nginx.conf.j2

worker_processes {{ worker_processes }};
worker_rlimit_nofile {{ max_open_files }};
 
events {
    worker_connections {{ worker_connections }};
}
 
http{
    ......
}


「 文章如果对你有帮助,请点个赞哦^^ 」 

1+