Advertisement
Guest User

Untitled

a guest
Jan 14th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. ---
  2. - hosts: Control
  3. gather_facts: no
  4. vars_files:
  5. - ../../vault/{{ tower_user_name|default(lookup('env','USER')) }}.yml
  6. tasks:
  7. - name: Find the sterling hosts
  8. sterling_agent_ctrl:
  9. env: "{{ target_env }}"
  10. AD_PASSWORD: "{{ AD_PASSWORD }}"
  11. AD_USER: "{{ AD_USER }}"
  12. agent: '{{ agent|default(None) }}'
  13. register: sterling_h
  14. - name: Adding the sterling hosts to dynamic inventory
  15. add_host: name={{ item }} group='sterling_hosts' ansible_ssh_user={{ AD_USER }} ansible_ssh_pass={{ AD_PASSWORD }}
  16. with_items: sterling_h.hosts
  17. when: sterling_h.changed
  18.  
  19.  
  20. - hosts: sterling_hosts
  21. gather_facts: no
  22. vars_files:
  23. - ../../vault/{{ tower_user_name|default(lookup('env','USER')) }}.yml
  24. tasks:
  25. - name: Sterling Agent Control
  26. # command: "disown -a && sudo -u app /cust/app/sterling-agent/bin/agentctrl -a {{ action_type }}"
  27. async: 240
  28. poll: 10
  29. command: "sudo -u app /cust/app/sterling-agent/bin/agentctrl -a {{ action_type }}"
  30. register: sterling_control
  31. when: action_type == 'start-all' or action_type == 'status-all' or action_type == 'stop-all'
  32.  
  33. - name: Sterling GET Status
  34. shell: "sudo -u app /cust/app/sterling-agent/bin/agentctrl -a status-all | grep pid | wc -l"
  35. async: 200
  36. poll: 5
  37. register: sterling_check
  38. changed_when: sterling.check.stdout != 0
  39. when: action_type == 'stop-all'
  40. # - name: WTF
  41. # debug: msg={{ sterling_check.stdout }}
  42.  
  43. - name: Sterling add FORCE_STOP inventory
  44. async: 240
  45. poll: 10
  46. command: "sudo -u app /cust/app/sterling-agent/bin/agentctrl -a force-stop"
  47. register: sterling_control
  48. when: sterling_check.changed and action_type == 'stop-all'
  49.  
  50. # this command is used to clean the log files when they are taking up too much space
  51. # sudo -u app /cust/app/sterling-agent/bin/agentctrl -j StoreInvPickUpServer-0 -a clean-logs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement