Authored by chunhua.zhang

Merge branch 'tiexin.yang' into 'master'

java-nginx支持参数传递java-gateway ip

## 支持通过参数传递java gateway ip列表进行nginx配置文件同步

> 已通过线下环境测试,是否传递参数 apigateway upstream都可以正常获取到默认/指定 java-gateway ip列表并应用配置文件

> 修改role openresty不影响java-nginx以外其他playbook
>> [root@ip-172-31-2-77 playbooks]# grep -ir openresty .

>> ./java-nginx.yml:    - openresty



See merge request !10
  1 +# Last updated at 2019/01/07 14:30 by tiexin.yang@yoho.cn
  2 +
  3 +# Sync and apply java nginx config file
  4 +# How to Run:
  5 +# Use the default settings:
  6 +# ansible-playbook -i inventories/$REGION/hosts playbooks/java.restart-service.v2.yml
  7 +# Apply the specified java_gateway ip addresses:
  8 +# ansible-playbook -i inventories/aws/hosts playbooks/java-nginx.yml -e '{"java_gateway_ips":['IP_BLOCK1','IP_BLOCK2']}'
  9 +
  10 +
1 - hosts: java-nginx 11 - hosts: java-nginx
2 pre_tasks: 12 pre_tasks:
3 - shell: cat /proc/cpuinfo | grep processor | wc -l 13 - shell: cat /proc/cpuinfo | grep processor | wc -l
@@ -8,6 +18,8 @@ @@ -8,6 +18,8 @@
8 - name: "confirmation" 18 - name: "confirmation"
9 prompt: "Sync and reload java nginx. Please Enter YES to continue." 19 prompt: "Sync and reload java nginx. Please Enter YES to continue."
10 private: no 20 private: no
  21 + vars:
  22 + java_gateway_ips: "{{ groups['java-gateway'] }}"
11 remote_user: root 23 remote_user: root
12 roles: 24 roles:
13 - openresty 25 - openresty
@@ -128,7 +128,7 @@ http @@ -128,7 +128,7 @@ http
128 #apigatewaystart 128 #apigatewaystart
129 upstream apigateway { 129 upstream apigateway {
130 130
131 - {% for i in groups['java-gateway'] %} 131 + {% for i in java_gateway_ips %}
132 server {{ i }}:8080 max_fails=5 fail_timeout=3s; 132 server {{ i }}:8080 max_fails=5 fail_timeout=3s;
133 {% endfor %} 133 {% endfor %}
134 134