java.restart-service.v2.yml 7.71 KB
# Last updated at 2018/12/18 17:54 by tiexin.yang@yoho.cn

# Restart multipal java services
# How to Run:
#       ansible-playbook -i inventories/$REGION/hosts  playbooks/java.restart-service.v2.yml -e '{"restart_services":[$JAVA_SERVICE01,$JAVA_SERVICE02...]}'

# Demo:
#       ansible-playbook -i inventories/aws/hosts playbooks/java.restart-service.v2.yml -e '{"restart_services":['yoho-message','yoho-sns']}'  

# stop
#  ansible-playbook -i inventories/t6/hosts playbooks/java.restart-service.v2.yml -e '{"restart_services":['yoho-message', 'yohobuy-product', 'yoho-sns'], "start": "no"}'
#  ansible-playbook -i inventories/t6/hosts playbooks/java.restart-service.v2.yml -e '{"restart_services":['yohobuy-order', 'yohobuy-promotion'], "start": "no"}'
#  ansible-playbook -i inventories/t6/hosts playbooks/java.restart-service.v2.yml -e '{"restart_services":['yoho-users', 'yohobuy-resources'], "start": "no"}'
#  ansible-playbook -i inventories/t6/hosts playbooks/java.restart-service.v2.yml -e '{"restart_services":['yohobuy-bigdata', 'yohobuy-activity', 'yohobuy-risk'], "start": "no"}'
#  ansible-playbook -i inventories/t6/hosts playbooks/java.restart-service.v2.yml -e '{"restart_services":['uic', 'wechat', 'erpgateway', 'yohobuy-brower'], "start": "no"}'


# Accepet JAVA_SERVICES:
#       - yoho-users
#       - yohoufo-fore
#       - yoho-social
#       - yoho-sns
#       - yoho-message
#       - yoho-gateway
#       - yohobuy-wechat
#       - yohobuy-union
#       - yohobuy-risk
#       - yohobuy-resources
#       - yohobuy-promotion
#       - yohobuy-product
#       - yohobuy-order
#       - yohobuy-brower
#       - yohobuy-bigdata
#       - yohobuy-activity
#       - uic
#       - yohoufo-fore
#       - ufo-platform
#       - platform-cms
#       - erpgateway

# yoho services
- hosts: java-gateway
  serial: "50%"
  vars:
    deploy_path: 'yoho-gateway'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - debug:
        msg: "{{ restart_services }}"
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

- hosts: java-message
  serial: "50%"
  vars:
    deploy_path: 'yoho-message'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

- hosts: java-sns
  serial: "50%"
  vars:
    deploy_path: 'yoho-sns'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services


- hosts: java-users
  serial: "50%"
  vars:
    deploy_path: 'yoho-users'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

- hosts: java-social
  serial: "50%"
  vars:
    deploy_path: 'yoho-social'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

# yohobuy services
- hosts: java-activity
  serial: "50%"
  vars:
    deploy_path: 'yohobuy-activity'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

- hosts: java-bigdata
  serial: "50%"
  vars:
    deploy_path: 'yohobuy-bigdata'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

- hosts: java-brower
  serial: "50%"
  vars:
    deploy_path: 'yohobuy-brower'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

- hosts: java-order
  serial: "50%"
  vars:
    deploy_path: 'yohobuy-order'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

- hosts: java-product
  serial: "50%"
  vars:
    deploy_path: 'yohobuy-product'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

- hosts: java-promotion
  serial: "50%"
  vars:
    deploy_path: 'yohobuy-promotion'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

- hosts: java-resources
  serial: "50%"
  vars:
    deploy_path: 'yohobuy-resources'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

- hosts: java-risk
  serial: "50%"
  vars:
    deploy_path: 'yohobuy-risk'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

- hosts: java-union
  serial: "50%"
  vars:
    deploy_path: 'yohobuy-union'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

- hosts: java-wechat
  serial: "50%"
  vars:
    deploy_path: 'yohobuy-wechat'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

# uniq services
- hosts: java-uic
  serial: "50%"
  vars:
    deploy_path: 'uic'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

- hosts: java-platform-cms
  serial: "50%"
  vars:
    deploy_path: 'platform-cms'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

# special services
- hosts: java-erpgateway
  serial: "50%"
  vars:
    deploy_path: 'yoho-erp-gateway'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: ('erpgateway' in restart_services)

# ufo services
- hosts: java-ufo-fore
  serial: "50%"
  vars:
    deploy_path: 'yohoufo-fore'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

- hosts: java-ufo-platform
  serial: "50%"
  vars:
    deploy_path: 'ufo-platform'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services


# shops service
- hosts: java-shops
  serial: "50%"
  vars:
    deploy_path: 'yohobuy-shops'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

- hosts: java-extendstore
  serial: "50%"
  vars:
    deploy_path: 'yohobuy-extendstore'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services

- hosts: java-portal-gateway
  serial: "50%"
  vars:
    deploy_path: 'yohobuy-portal-gateway'
  remote_user: root
  become: true
  become_method: sudo
  become_user: master
  tasks:
    - import_role:
        name: java.restart
      when: deploy_path in restart_services