Created
January 14, 2016 16:54
-
-
Save lindsm/5c148763dc14b90ed48c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: Control | |
gather_facts: no | |
vars_files: | |
- ../../vault/{{ tower_user_name|default(lookup('env','USER')) }}.yml | |
tasks: | |
- name: Find the sterling hosts | |
sterling_agent_ctrl: | |
env: "{{ target_env }}" | |
AD_PASSWORD: "{{ AD_PASSWORD }}" | |
AD_USER: "{{ AD_USER }}" | |
agent: '{{ agent|default(None) }}' | |
register: sterling_h | |
- name: Adding the sterling hosts to dynamic inventory | |
add_host: name={{ item }} group='sterling_hosts' ansible_ssh_user={{ AD_USER }} ansible_ssh_pass={{ AD_PASSWORD }} | |
with_items: sterling_h.hosts | |
when: sterling_h.changed | |
- hosts: sterling_hosts | |
gather_facts: no | |
vars_files: | |
- ../../vault/{{ tower_user_name|default(lookup('env','USER')) }}.yml | |
tasks: | |
- name: Sterling Agent Control | |
# command: "disown -a && sudo -u app /cust/app/sterling-agent/bin/agentctrl -a {{ action_type }}" | |
async: 240 | |
poll: 10 | |
command: "sudo -u app /cust/app/sterling-agent/bin/agentctrl -a {{ action_type }}" | |
register: sterling_control | |
when: action_type == 'start-all' or action_type == 'status-all' or action_type == 'stop-all' | |
- name: Sterling GET Status | |
shell: "sudo -u app /cust/app/sterling-agent/bin/agentctrl -a status-all | grep pid | wc -l" | |
async: 200 | |
poll: 5 | |
register: sterling_check | |
changed_when: sterling.check.stdout != 0 | |
when: action_type == 'stop-all' | |
# - name: WTF | |
# debug: msg={{ sterling_check.stdout }} | |
- name: Sterling add FORCE_STOP inventory | |
async: 240 | |
poll: 10 | |
command: "sudo -u app /cust/app/sterling-agent/bin/agentctrl -a force-stop" | |
register: sterling_control | |
when: sterling_check.changed and action_type == 'stop-all' | |
# this command is used to clean the log files when they are taking up too much space | |
# sudo -u app /cust/app/sterling-agent/bin/agentctrl -j StoreInvPickUpServer-0 -a clean-logs | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment