1.group_vars/all
#php packages
packages:
- nginx
- php71w
- php71w-cli
- php71w-common
- php71w-devel
- php71w-embedded
- php71w-gd
- php71w-mbstring
- php71w-pdo
- php71w-xml
- php71w-fpm
- php71w-mysqlnd
- php71w-opcache
- php71w-mcrypt
- php71w-pecl-memcached
- php71w-pecl-mongodb
- php71w-pecl-redis
- php71w-pecl-zip
- php71w-bcmath
#web
redis_server_ip: 172.16.1.51
redis_server_port: 6379
web_process_user: www
web_process_group: www
cloud_server_name: ansible.oldxu.com
cloud_server_port: 80
cloud_code_path: /code/ansible
#proxy
cloud_proxy_port: 80
2.kodcloud-proxy
(1)handlers
main.yml
- name: Restart Nginx Server
systemd:
name: nginx
state: restarted
(2)mets
main.yml
dependencies:
- nginx-web
(3)tasks
main.yml
- name: Create Nginx Proxy VirtHost Configure
template:
src: “{ { item.src }}”
dest: “{ { item.dest }}”
loop:- { src: proxy_params.j2 , dest: /etc/nginx/proxy_params }
- { src: proxy_ansible.oldxu.com.conf.j2 , dest: /etc/nginx/conf.d/proxy_ansible.oldxu.com.conf }
notify: Restart Nginx Server
(4)templates
proxy_ansible.xxx.com.comf.j2
upstream {
{ cloud_server_name }} {
{% for host in groups[‘web’] %}
server {
{ host }}:{
{ cloud_server_port }};
{% endfor %}
}
server {
listen {
{ cloud_proxy_port }};
server_name {
{ cloud_server_name }};
location / {