---
- name: Disable 118.190.49.243 Backend 443 & 8080 Port
  vars:
    java_backend_upstream: |
        upstream java_443_backend {
        # server 10.30.149.41:50443 weight=30; # 165
        # server 10.30.148.149:50443 weight=30;  # 243
        server 10.31.74.200:50443 weight=30;   # 106
        }
        
        upstream java_8080_backend {
        # server 10.30.149.41:58080 weight=30; # 165
        # server 10.30.148.149:58080 weight=30;  # 243
        server 10.31.74.200:58080 weight=30;   # 106
        }
  template: src=nginx.conf dest=/usr/local/openresty/nginx/conf/nginx.conf  owner=root group=root mode=0644
  when: close_243_javabackend is defined
  tags: java_upstream

- name: Disable 118.190.137.106 Backend 443 & 8080 Port
  vars:
    java_backend_upstream: |
        upstream java_443_backend {
        # server 10.30.149.41:50443 weight=30; # 165
        server 10.30.148.149:50443 weight=30;  # 243
        # server 10.31.74.200:50443 weight=30;   # 106
        }
        
        upstream java_8080_backend {
        # server 10.30.149.41:58080 weight=30; # 165
        server 10.30.148.149:58080 weight=30;  # 243
        # server 10.31.74.200:58080 weight=30;   # 106
        }
  template: src=nginx.conf dest=/usr/local/openresty/nginx/conf/nginx.conf  owner=root group=root mode=0644
  when: close_106_javabackend is defined
  tags: java_upstream

- name: Enable 118.190.49.243 Backend 443 & 8080 Port
  vars:
    java_backend_upstream: |
        upstream java_443_backend {
        # server 10.30.149.41:50443 weight=30; # 165
        server 10.30.148.149:50443 weight=30;  # 243
        # server 10.31.74.200:50443 weight=30;   # 106
        }

        upstream java_8080_backend {
        # server 10.30.149.41:58080 weight=30; # 165
        server 10.30.148.149:58080 weight=30;  # 243
        # server 10.31.74.200:58080 weight=30;   # 106
        }
  template: src=nginx.conf dest=/usr/local/openresty/nginx/conf/nginx.conf  owner=root group=root mode=0644
  when: open_243_javabackend is defined
  tags: java_upstream

- name: Enable 118.190.137.106 Backend 443 & 8080 Port
  vars:
    java_backend_upstream: |
        upstream java_443_backend {
        # server 10.30.149.41:50443 weight=30; # 165
        # server 10.30.148.149:50443 weight=30;  # 243
        server 10.31.74.200:50443 weight=30;   # 106
        }

        upstream java_8080_backend {
        # server 10.30.149.41:58080 weight=30; # 165
        # server 10.30.148.149:58080 weight=30;  # 243
        server 10.31.74.200:58080 weight=30;   # 106
        }
  template: src=nginx.conf dest=/usr/local/openresty/nginx/conf/nginx.conf  owner=root group=root mode=0644
  when: open_106_javabackend is defined
  tags: java_upstream

- name: Enable 118.190.50.165 Backend 443 & 8080 Port
  vars:
    java_backend_upstream: |
        upstream java_443_backend {
        server 10.30.149.41:50443 weight=30; # 165
        # server 10.30.148.149:50443 weight=30;  # 243
        # server 10.31.74.200:50443 weight=30;   # 106
        }

        upstream java_8080_backend {
        server 10.30.149.41:58080 weight=30; # 165
        # server 10.30.148.149:58080 weight=30;  # 243
        # server 10.31.74.200:58080 weight=30;   # 106
        }
  template: src=nginx.conf dest=/usr/local/openresty/nginx/conf/nginx.conf  owner=root group=root mode=0644
  when: open_165_javabackend is defined
  tags: java_upstream

- name: Disable 118.190.50.165 Backend 443 & 8080 Port
  vars:
    java_backend_upstream: |
        upstream java_443_backend {
        # server 10.30.149.41:50443 weight=30; # 165
        server 10.30.148.149:50443 weight=30;  # 243
        server 10.31.74.200:50443 weight=30;   # 106
        }

        upstream java_8080_backend {
        # server 10.30.149.41:58080 weight=30; # 165
        server 10.30.148.149:58080 weight=30;  # 243
        server 10.31.74.200:58080 weight=30;   # 106
        }
  template: src=nginx.conf dest=/usr/local/openresty/nginx/conf/nginx.conf  owner=root group=root mode=0644
  when: close_165_javabackend is defined
  tags: java_upstream


- name: Check Configuration
  shell: /usr/local/openresty/nginx/sbin/nginx -t
  tags: java_upstream

- name: Reload /usr/local/openresty/nginx/
  shell: /usr/local/openresty/nginx/sbin/nginx -s reload
  tags: java_upstream


