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
# Last updated at 2019/01/07 14:30 by tiexin.yang@yoho.cn
# Sync and apply java nginx config file
# How to Run:
# Use the default settings:
# ansible-playbook -i inventories/$REGION/hosts playbooks/java.restart-service.v2.yml
# Apply the specified java_gateway ip addresses:
# ansible-playbook -i inventories/aws/hosts playbooks/java-nginx.yml -e '{"java_gateway_ips":['IP_BLOCK1','IP_BLOCK2']}'
- hosts: java-nginx
pre_tasks:
- shell: cat /proc/cpuinfo | grep processor | wc -l
... ... @@ -8,6 +18,8 @@
- name: "confirmation"
prompt: "Sync and reload java nginx. Please Enter YES to continue."
private: no
vars:
java_gateway_ips: "{{ groups['java-gateway'] }}"
remote_user: root
roles:
- openresty
... ...
... ... @@ -128,7 +128,7 @@ http
#apigatewaystart
upstream apigateway {
{% for i in groups['java-gateway'] %}
{% for i in java_gateway_ips %}
server {{ i }}:8080 max_fails=5 fail_timeout=3s;
{% endfor %}
... ...