From b923dd90bf6410e651d6be3d21e7f17f03273697 Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Mon, 30 Jul 2018 12:58:15 -0700 Subject: [PATCH 01/21] Add action tags --- .travis/secrets.tar.enc | Bin 6672 -> 0 bytes .../elasticsearch/tasks/rolling_restart.yml | 8 ++++++++ 2 files changed, 8 insertions(+) diff --git a/.travis/secrets.tar.enc b/.travis/secrets.tar.enc index b3e53c3a0debef3bea5c477122eece63b33c1a7d..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 GIT binary patch literal 0 HcmV?d00001 literal 6672 zcmV+r8t>%>=rv84=@dO}6dMe{{|RJye@NMFFD5q~EsbcFykJhe`ACne_xCo{GawYJ7IIDb0qO4FvhIdbxxA-LsjAYanCavCK)%o!(Bgw5j&M1uGSVCxkN zoEJA&VHK*2O=xR{{EF~2eOshJIt2=d8Y)33$KW#crtRB2&Q`Pe9u2{8MI>3i=f}kO z0*O%pk@=^*A=s_N(J2UofzWD}Ir?zbLd!RoZe9TZbx_k<>SQ!?kjee0mLIsW_n`Mc z>DAeNCCN&xr@u+YUA{va``e#rFW&_YLYMI1Cm4>iY!$YrudWsOlrFJjO2EBTiAXghBs4hHv9|FS$}9zINeF$ zS*rKhb%#S0W*2COwkL0qO+I3DO#d6JQSr7Fm63DCXZ8j=&)fz(OEXJNXgVwV=OxGM zqnAd0QZ=4*)An79r%1kWn+$H=1gZfuK*VcIF{#X@CNiwY1LexEuQOv$r+s2i!!%d6 z-MFo0s9f%UEj2KZmJ>KPZ;&bHq;tOoD81OrSbtClt=2WvXlzbF8}0UBvGLF~@go;z zax@llohZ#s@rZ)Xr~k(;NKTMZRZv-|Q~=wFMe=o@`@c;>3ERpm^H=Cw{cA!~@~Zv< zi7@*XqM0@%f5Ak%OlW{w6k_)_qGkF0`awC>ehUD2XF6K3`~ zDOiI7(VWaCLLAP|`N)HKmHD`j9~RA9Z>ecv*(YTuC%pG%dvib5F*SE2!TA#Bh1+{R zq6xQ0my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S2-ucoh3~Q$rFl1&&>z2&tU$(9O537#83lAX>bBl zoVkcw5;2O+SHM;x=doHt=O*aoZT(K;5w1*#JEo|YPqUXeoe?CkPJ${h0IY=e5)q!S aT-^PPd>lPFLnhdkNVkP;fcL7S@@4Vl?%nGE diff --git a/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml b/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml index ebf7a6bfd3..828293a98e 100644 --- a/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml +++ b/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml @@ -6,19 +6,24 @@ retries: 20 delay: 3 changed_when: result.stdout.find('"acknowledged":true') != -1 + tag: action_stop - name: stop node become: true service: name=elasticsearch state=stopped + tag: action_stop - name: wait for a few seconds for ES to stop pause: seconds=10 + tag: action_stop - name: start node become: true service: name=elasticsearch state=started + tag: action_start - debug: msg="Sometimes we try to start the node too soon. If hung start node manually" + tag: action_start - name: wait for node to restart shell: "curl -I -s -m 2 http://{{es_host}}:9200 | head -n 1" @@ -26,6 +31,7 @@ until: result.stdout == "HTTP/1.1 200 OK" retries: 200 delay: 3 + tag: action_start - name: enable cluster routing shell: "curl -XPUT {{es_host}}:9200/_cluster/settings -d '{\"transient\" : {\"cluster.routing.allocation.enable\" : \"all\" }}'" @@ -34,6 +40,7 @@ retries: 20 delay: 3 changed_when: result.stdout.find('"acknowledged":true') != -1 + tag: action_start - name: wait for cluster to stabilize shell: "curl -s -m 2 {{es_host}}:9200/_cat/health | cut -d ' ' -f 4" @@ -41,3 +48,4 @@ until: result.stdout.find("green") != -1 retries: 200 delay: 30 + tag: action_start From 54ddeacd5e05cf36fbf06931b3fa0fb7c81e2ffa Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Mon, 30 Jul 2018 12:59:39 -0700 Subject: [PATCH 02/21] Create framework for new elasticsearch commands --- .../commands/ansible/service.py | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/commcare_cloud/commands/ansible/service.py b/src/commcare_cloud/commands/ansible/service.py index a6704cf57b..2a26d8ac49 100644 --- a/src/commcare_cloud/commands/ansible/service.py +++ b/src/commcare_cloud/commands/ansible/service.py @@ -2,6 +2,7 @@ from abc import ABCMeta, abstractmethod, abstractproperty from collections import defaultdict, OrderedDict from itertools import groupby +import subprocess import attr import six @@ -274,10 +275,36 @@ class Nginx(AnsibleService): inventory_groups = ['proxy'] -class Elasticsearch(AnsibleService): +class ElasticsearchClassic(AnsibleService): + name = 'elasticsearch-classic' + service_name = 'elasticsearch' + inventory_groups = ['elasticsearch'] + + +class Elasticsearch(ServiceBase): name = 'elasticsearch' + service_name = 'elasticsearch' inventory_groups = ['elasticsearch'] + def execute_action(self, action, host_pattern=None, process_pattern=None): + if action == 'stop' or action == 'restart': + self._run_rolling_restart_yml(tags='action_stop') + # Find remaining es processes and kill them + es_processes_to_kill = subprocess.check_output('ps aux | pgrep "elasticsearc[h]" | awk "{print $2}"') + subprocess.call('pkill', es_processes_to_kill) + if action == 'start' or action == 'restart': + self._run_rolling_restart_yml(tags='action_start') + elif action == 'status': + return ElasticsearchClassic(self.environment, self.ansible_context).execute_action(action, host_pattern, process_pattern) + + def _run_rolling_restart_yml(self, tags): + from commcare_cloud.commands.ansible.ansible_playbook import run_ansible_playbook + run_ansible_playbook(environment=self.environment, + playbook='rolling_restart.yml', + ansible_context=AnsibleContext(args=None), + unknown_args=['--tags={}'.format(tags)]) + # return self._run_ansible_module(host_pattern, module='rolling_restart.yml', module_args='tags={}'.format(tags)) + class Couchdb(AnsibleService): name = 'couchdb' @@ -491,6 +518,7 @@ def get_processes_by_host(all_hosts, process_descriptors, process_pattern=None): Couchdb2, RabbitMq, Elasticsearch, + ElasticsearchClassic, Redis, Riakcs, Kafka, From d8ef759e3de9ca15ea5a9004246a2ef6c0ec2419 Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Mon, 30 Jul 2018 14:51:02 -0700 Subject: [PATCH 03/21] Move everything into plays, call the play instead of the module directly --- .../elasticsearch/tasks/rolling_restart.yml | 10 ++++++++++ src/commcare_cloud/commands/ansible/service.py | 18 ++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml b/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml index 828293a98e..54304c8dca 100644 --- a/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml +++ b/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml @@ -17,6 +17,16 @@ pause: seconds=10 tag: action_stop +- name: get es instances to kill + shell: "ps aux | pgrep 'elasticsearc[h]' | awk '{print $2}'" + register: es_instances + tag: action_stop + +- name: kill elasticsearch instances + shell: "pkill {{item}}" + with_items: es_instances.stdout + when: es_instances.stdout + - name: start node become: true service: name=elasticsearch state=started diff --git a/src/commcare_cloud/commands/ansible/service.py b/src/commcare_cloud/commands/ansible/service.py index 2a26d8ac49..61956ca174 100644 --- a/src/commcare_cloud/commands/ansible/service.py +++ b/src/commcare_cloud/commands/ansible/service.py @@ -287,23 +287,21 @@ class Elasticsearch(ServiceBase): inventory_groups = ['elasticsearch'] def execute_action(self, action, host_pattern=None, process_pattern=None): - if action == 'stop' or action == 'restart': - self._run_rolling_restart_yml(tags='action_stop') - # Find remaining es processes and kill them - es_processes_to_kill = subprocess.check_output('ps aux | pgrep "elasticsearc[h]" | awk "{print $2}"') - subprocess.call('pkill', es_processes_to_kill) - if action == 'start' or action == 'restart': - self._run_rolling_restart_yml(tags='action_start') - elif action == 'status': + if action == 'status': return ElasticsearchClassic(self.environment, self.ansible_context).execute_action(action, host_pattern, process_pattern) + elif action == 'start' or action == 'restart': + print("PV: At start") + self._run_rolling_restart_yml(tags='action_start') + elif action == 'stop' or action == 'restart': + print("PV: At stop") + self._run_rolling_restart_yml(tags='action_stop') def _run_rolling_restart_yml(self, tags): from commcare_cloud.commands.ansible.ansible_playbook import run_ansible_playbook run_ansible_playbook(environment=self.environment, - playbook='rolling_restart.yml', + playbook='es_rolling_restart.yml', ansible_context=AnsibleContext(args=None), unknown_args=['--tags={}'.format(tags)]) - # return self._run_ansible_module(host_pattern, module='rolling_restart.yml', module_args='tags={}'.format(tags)) class Couchdb(AnsibleService): From c02a11424b84e80f30cb53b14eaa185dfe80e8bc Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Mon, 30 Jul 2018 15:41:14 -0700 Subject: [PATCH 04/21] Call es_rolling_restart when elasticsearch service command is called --- .../elasticsearch/tasks/rolling_restart.yml | 28 +++++++++++-------- .../commands/ansible/service.py | 9 +++--- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml b/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml index 54304c8dca..e41c537685 100644 --- a/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml +++ b/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml @@ -6,34 +6,40 @@ retries: 20 delay: 3 changed_when: result.stdout.find('"acknowledged":true') != -1 - tag: action_stop + tags: action_stop + +- debug: msg="{{ result }}" + tags: action_stop + - name: stop node become: true service: name=elasticsearch state=stopped - tag: action_stop + tags: action_stop - name: wait for a few seconds for ES to stop pause: seconds=10 - tag: action_stop + tags: action_stop - name: get es instances to kill shell: "ps aux | pgrep 'elasticsearc[h]' | awk '{print $2}'" register: es_instances - tag: action_stop + tags: action_stop + +- debug: msg="HI! {{ es_instances }}" - name: kill elasticsearch instances shell: "pkill {{item}}" - with_items: es_instances.stdout - when: es_instances.stdout + with_items: es_instances + when: es_instances - name: start node become: true service: name=elasticsearch state=started - tag: action_start + tags: action_start - debug: msg="Sometimes we try to start the node too soon. If hung start node manually" - tag: action_start + tags: action_start - name: wait for node to restart shell: "curl -I -s -m 2 http://{{es_host}}:9200 | head -n 1" @@ -41,7 +47,7 @@ until: result.stdout == "HTTP/1.1 200 OK" retries: 200 delay: 3 - tag: action_start + tags: action_start - name: enable cluster routing shell: "curl -XPUT {{es_host}}:9200/_cluster/settings -d '{\"transient\" : {\"cluster.routing.allocation.enable\" : \"all\" }}'" @@ -50,7 +56,7 @@ retries: 20 delay: 3 changed_when: result.stdout.find('"acknowledged":true') != -1 - tag: action_start + tags: action_start - name: wait for cluster to stabilize shell: "curl -s -m 2 {{es_host}}:9200/_cat/health | cut -d ' ' -f 4" @@ -58,4 +64,4 @@ until: result.stdout.find("green") != -1 retries: 200 delay: 30 - tag: action_start + tags: action_start diff --git a/src/commcare_cloud/commands/ansible/service.py b/src/commcare_cloud/commands/ansible/service.py index 61956ca174..0d716295c0 100644 --- a/src/commcare_cloud/commands/ansible/service.py +++ b/src/commcare_cloud/commands/ansible/service.py @@ -289,19 +289,18 @@ class Elasticsearch(ServiceBase): def execute_action(self, action, host_pattern=None, process_pattern=None): if action == 'status': return ElasticsearchClassic(self.environment, self.ansible_context).execute_action(action, host_pattern, process_pattern) - elif action == 'start' or action == 'restart': - print("PV: At start") - self._run_rolling_restart_yml(tags='action_start') elif action == 'stop' or action == 'restart': - print("PV: At stop") self._run_rolling_restart_yml(tags='action_stop') + elif action == 'start' or action == 'restart': + self._run_rolling_restart_yml(tags='action_start') def _run_rolling_restart_yml(self, tags): from commcare_cloud.commands.ansible.ansible_playbook import run_ansible_playbook run_ansible_playbook(environment=self.environment, playbook='es_rolling_restart.yml', ansible_context=AnsibleContext(args=None), - unknown_args=['--tags={}'.format(tags)]) + unknown_args=['--tags={}'.format(tags)], + skip_check=True) class Couchdb(AnsibleService): From 5cd16e9f7d5009ccc11af0d5288819a6e4c4d1e8 Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Mon, 30 Jul 2018 16:02:44 -0700 Subject: [PATCH 05/21] [pv-deploy] Created new encrypted secrets file --- .travis/secrets.tar.enc | Bin 0 -> 5648 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.travis/secrets.tar.enc b/.travis/secrets.tar.enc index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..fc722695c6edcee4b933c52c34c564f17aba5e61 100644 GIT binary patch literal 5648 zcmV+r7Vqh`J!VqO?iHNEDGOBZCykaJ_PX(DwyL+Px$&Q5z%jCY|K`p8<-&)r)h;)T zDh-U^`Z@X2aE2w=8trSz3{T4%o+=3t4cB<_>&1H^Q?Nk$DjORc^n?ETtE0KbW#9^> zUDf3QZ0ymJSTccyOc}A9IG8$MhaTq=3oMf!VZO4iWDFA=&2WATVJ}^_{^B~2Qx7?fWqM6c3Ou58B0|b=PT=`(}Fs2vD+zpuvlXd z2Mo~ycFy)f2L|Dul%jjFGapRw%tf_(V&QGo+)nH5R=tL2N;3U57xR9UUmtd0C_kHLlRJjiD#b!odi6?2uO?mM~qgQqyml zIQz`h>TjcQquXVRqQ!bKz#@}QvbdMS*Dr($k772p?vyH2U+W~?f<-4|a>Yke1)J8{ zXt3dInca(4xNziy;%P7*hVnaQzc*~%vz$8A=;NTDPIovPq`|rk>JhUoc5$bzA zHNJI%it0>N4!*N67fHb%wRIhhdmAL(5H=_W%cvV+G0#tDZ_$BA)Qg*ouiZN+*D{gk zr?ojmqdZFiFS;!d9372@&D^lv?N;*4B1Aj2O@g?lMTfZ1=JYhf0N9CKA{IU14$meX6Eo0vr|W<@-)W9V4lB3E&W@$yvV*s00H-hu1XcvQ4`hyFW!lgD&6ZO5}6Zrcb+Af zo>>Qi#S>2|AjO;&-tiZFGU8ryA7v0$`ej66%$11e?!(C=fpe0(Lffl>rqE~$ z1Ok~8md!kYUITAw?Ey5E_kM^?SYUZguk=H;RXl;2Vwy1v7pcy^2KFx%TBa+o!oXRg z|I6neGQgWCaSj)SI91_p8H3`%hh6^RlTHaNmNOh6y~uc2)wrQ5)T!Aa=i5yk@)HvP zsA6IqYCQFxDi}Fs^bp^!_kr6H8rvI(`!!i>W7Szkt;sPc-4n-e7I%_8jH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}zu#x9#FG&dzbjs`ybU%dDhcifdZ|4~HE$M`4u^5=Stt8;9gE#e)eH)yd} zxenRAjQI5|{`jHxyKe+puxtRxHiYzoCYrVyGB=%H^1$O_rsojja~> zG0z7Sdj+E;+VE8_B+P&R1&$?}Z)pYdY3??HCtkJ_1}^CtkR=DG>_LM<^J;XK_5b<& zM))rm7vs)$Ck!qUidlyq_f-j%MM8PE=R*k6qqLK&0L6T8V}3x#JJJ2G+Yf}N zIIOGMxTEGRwmsWBi0UqgZ2KN+(jxhTBWX&lnMyDYxiO?hwRoLNrpA*biPzOu1W9xH z+fg6Fb&e1%vQIl{jFjDgn`u7P6E`a{drlO|rPsdl^ba0#2UV|PyC!wlo4)ezEs`Aq z(*42ji2gub9aKiB$asIfGZtt9_Yt8odTkBLDa$LRJ(`8ixT*(SMs*;iPO*|VRvq2h qd{)eb!mmchcyMYpzjAw~^)Gi7%>!0W5f{saGn)|5bcLn(G`@Qc{^+0p literal 0 HcmV?d00001 From aeb21b2ccbb66518c8e2a85a921745c4d775bb69 Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Tue, 31 Jul 2018 10:54:21 -0700 Subject: [PATCH 06/21] Stop and start pillows along with es --- src/commcare_cloud/commands/ansible/service.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/commcare_cloud/commands/ansible/service.py b/src/commcare_cloud/commands/ansible/service.py index 0d716295c0..67e861e29f 100644 --- a/src/commcare_cloud/commands/ansible/service.py +++ b/src/commcare_cloud/commands/ansible/service.py @@ -290,10 +290,20 @@ def execute_action(self, action, host_pattern=None, process_pattern=None): if action == 'status': return ElasticsearchClassic(self.environment, self.ansible_context).execute_action(action, host_pattern, process_pattern) elif action == 'stop' or action == 'restart': + exit_code = self._act_on_pillows(action=action) self._run_rolling_restart_yml(tags='action_stop') elif action == 'start' or action == 'restart': + exit_code = self._act_on_pillows(action=action) self._run_rolling_restart_yml(tags='action_start') + def _act_on_pillows(self, action): + # Used to stop or start pillows + ansible_context = AnsibleContext(None) + service_cls = SERVICES_BY_NAME['pillowtop'] + service = service_cls(self.environment, ansible_context) + exit_code = service.run(action=action) + return exit_code + def _run_rolling_restart_yml(self, tags): from commcare_cloud.commands.ansible.ansible_playbook import run_ansible_playbook run_ansible_playbook(environment=self.environment, From 5a25dc631363ebdd903f6329c8234f04b96ba338 Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Tue, 31 Jul 2018 11:17:58 -0700 Subject: [PATCH 07/21] Exit if error in stopping/starting pillows --- .../commands/ansible/service.py | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/commcare_cloud/commands/ansible/service.py b/src/commcare_cloud/commands/ansible/service.py index 67e861e29f..e123cc47c1 100644 --- a/src/commcare_cloud/commands/ansible/service.py +++ b/src/commcare_cloud/commands/ansible/service.py @@ -2,7 +2,7 @@ from abc import ABCMeta, abstractmethod, abstractproperty from collections import defaultdict, OrderedDict from itertools import groupby -import subprocess +import sys import attr import six @@ -289,12 +289,30 @@ class Elasticsearch(ServiceBase): def execute_action(self, action, host_pattern=None, process_pattern=None): if action == 'status': return ElasticsearchClassic(self.environment, self.ansible_context).execute_action(action, host_pattern, process_pattern) - elif action == 'stop' or action == 'restart': - exit_code = self._act_on_pillows(action=action) - self._run_rolling_restart_yml(tags='action_stop') - elif action == 'start' or action == 'restart': - exit_code = self._act_on_pillows(action=action) - self._run_rolling_restart_yml(tags='action_start') + else: + response = six.moves.input("This function does more than stop and start the elasticsearch service. For that, use elasticsearch-classic." + "\nStop will: stop pillows, stop es, and kill -9 if any processes still exist after a period of time. " + "\nStart will start pillows and start elasticsearch " + "\nRestart is a stop followed by a start.\n Continue? [y/n]: ") + if response.lower() == "n": + print("Exiting.") + sys.exit(1) + elif not response.lower == 'y': + print("Unknown response. Exiting.") + sys.exit(1) + + if action == 'stop' or action == 'restart': + exit_code = self._act_on_pillows(action=action) + if not exit_code == 0: + print("ERROR while stopping pillows. Exiting.") + sys.exit(1) + self._run_rolling_restart_yml(tags='action_stop') + elif action == 'start' or action == 'restart': + exit_code = self._act_on_pillows(action=action) + if not exit_code == 0: + print("ERROR while starting pillows. Exiting.") + sys.exit(1) + self._run_rolling_restart_yml(tags='action_start') def _act_on_pillows(self, action): # Used to stop or start pillows From 7ec1c42180f68073a1594313e9f516e5786c660a Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Tue, 31 Jul 2018 13:11:06 -0700 Subject: [PATCH 08/21] Cleanup --- .../ansible/roles/elasticsearch/tasks/rolling_restart.yml | 2 -- src/commcare_cloud/commands/ansible/service.py | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml b/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml index e41c537685..912f77b64b 100644 --- a/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml +++ b/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml @@ -26,8 +26,6 @@ register: es_instances tags: action_stop -- debug: msg="HI! {{ es_instances }}" - - name: kill elasticsearch instances shell: "pkill {{item}}" with_items: es_instances diff --git a/src/commcare_cloud/commands/ansible/service.py b/src/commcare_cloud/commands/ansible/service.py index e123cc47c1..2589e9a637 100644 --- a/src/commcare_cloud/commands/ansible/service.py +++ b/src/commcare_cloud/commands/ansible/service.py @@ -297,7 +297,7 @@ def execute_action(self, action, host_pattern=None, process_pattern=None): if response.lower() == "n": print("Exiting.") sys.exit(1) - elif not response.lower == 'y': + elif not response.lower() == 'y': print("Unknown response. Exiting.") sys.exit(1) @@ -317,8 +317,7 @@ def execute_action(self, action, host_pattern=None, process_pattern=None): def _act_on_pillows(self, action): # Used to stop or start pillows ansible_context = AnsibleContext(None) - service_cls = SERVICES_BY_NAME['pillowtop'] - service = service_cls(self.environment, ansible_context) + service = SERVICES_BY_NAME['pillowtop'](self.environment, ansible_context) exit_code = service.run(action=action) return exit_code From 80d21becf069ed42949ddaafbd14ee922cffd37f Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Wed, 1 Aug 2018 08:23:32 -0700 Subject: [PATCH 09/21] Remove debug statement --- .../ansible/roles/elasticsearch/tasks/rolling_restart.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml b/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml index 912f77b64b..bbcfb94653 100644 --- a/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml +++ b/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml @@ -8,10 +8,6 @@ changed_when: result.stdout.find('"acknowledged":true') != -1 tags: action_stop -- debug: msg="{{ result }}" - tags: action_stop - - - name: stop node become: true service: name=elasticsearch state=stopped From 9fa7e23df03ff73d05498d20000db3e4a62f7922 Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Wed, 1 Aug 2018 08:23:54 -0700 Subject: [PATCH 10/21] Rename es_instances to es_pids --- .../ansible/roles/elasticsearch/tasks/rolling_restart.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml b/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml index bbcfb94653..e8a4556779 100644 --- a/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml +++ b/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml @@ -19,13 +19,13 @@ - name: get es instances to kill shell: "ps aux | pgrep 'elasticsearc[h]' | awk '{print $2}'" - register: es_instances + register: es_pids tags: action_stop - name: kill elasticsearch instances shell: "pkill {{item}}" - with_items: es_instances - when: es_instances + with_items: es_pids + when: es_pids - name: start node become: true From bed03233686c862186427cafe6a71b06d95705c2 Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Wed, 1 Aug 2018 08:58:51 -0700 Subject: [PATCH 11/21] Use the cli ask function --- .../commands/ansible/service.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/commcare_cloud/commands/ansible/service.py b/src/commcare_cloud/commands/ansible/service.py index 2589e9a637..196466f92a 100644 --- a/src/commcare_cloud/commands/ansible/service.py +++ b/src/commcare_cloud/commands/ansible/service.py @@ -15,6 +15,7 @@ get_celery_workers, get_pillowtop_processes ) +from commcare_cloud.cli_utils import ask from commcare_cloud.commands.ansible.run_module import run_ansible_module from commcare_cloud.commands.command_base import CommandBase, Argument from commcare_cloud.environment.main import get_environment @@ -290,17 +291,13 @@ def execute_action(self, action, host_pattern=None, process_pattern=None): if action == 'status': return ElasticsearchClassic(self.environment, self.ansible_context).execute_action(action, host_pattern, process_pattern) else: - response = six.moves.input("This function does more than stop and start the elasticsearch service. For that, use elasticsearch-classic." - "\nStop will: stop pillows, stop es, and kill -9 if any processes still exist after a period of time. " - "\nStart will start pillows and start elasticsearch " - "\nRestart is a stop followed by a start.\n Continue? [y/n]: ") - if response.lower() == "n": - print("Exiting.") - sys.exit(1) - elif not response.lower() == 'y': - print("Unknown response. Exiting.") - sys.exit(1) - + if not ask("This function does more than stop and start the elasticsearch service. " + "For that, use elasticsearch-classic." + "\nStop will: stop pillows, stop es, and kill -9 if any processes still exist " + "after a period of time. " + "\nStart will start pillows and start elasticsearch " + "\nRestart is a stop followed by a start.\n Continue?", strict=False): + return 0 # exit code if action == 'stop' or action == 'restart': exit_code = self._act_on_pillows(action=action) if not exit_code == 0: From e9e172408cd85f6bcaa0806532a23a604b43c308 Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Wed, 1 Aug 2018 08:59:57 -0700 Subject: [PATCH 12/21] Change indentation level of ask prompt --- src/commcare_cloud/commands/ansible/service.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/commcare_cloud/commands/ansible/service.py b/src/commcare_cloud/commands/ansible/service.py index 196466f92a..a3f6ab45c1 100644 --- a/src/commcare_cloud/commands/ansible/service.py +++ b/src/commcare_cloud/commands/ansible/service.py @@ -291,12 +291,13 @@ def execute_action(self, action, host_pattern=None, process_pattern=None): if action == 'status': return ElasticsearchClassic(self.environment, self.ansible_context).execute_action(action, host_pattern, process_pattern) else: - if not ask("This function does more than stop and start the elasticsearch service. " - "For that, use elasticsearch-classic." - "\nStop will: stop pillows, stop es, and kill -9 if any processes still exist " - "after a period of time. " - "\nStart will start pillows and start elasticsearch " - "\nRestart is a stop followed by a start.\n Continue?", strict=False): + if not ask( + "This function does more than stop and start the elasticsearch service. " + "For that, use elasticsearch-classic." + "\nStop will: stop pillows, stop es, and kill -9 if any processes still exist " + "after a period of time. " + "\nStart will start pillows and start elasticsearch " + "\nRestart is a stop followed by a start.\n Continue?", strict=False): return 0 # exit code if action == 'stop' or action == 'restart': exit_code = self._act_on_pillows(action=action) From 786e8392e9fea77e2f8ebe48395837fcad3be8ed Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Wed, 1 Aug 2018 10:32:02 -0700 Subject: [PATCH 13/21] Change elif to if so that both get hit for restarts --- src/commcare_cloud/commands/ansible/service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commcare_cloud/commands/ansible/service.py b/src/commcare_cloud/commands/ansible/service.py index a3f6ab45c1..fbc77b82b8 100644 --- a/src/commcare_cloud/commands/ansible/service.py +++ b/src/commcare_cloud/commands/ansible/service.py @@ -305,7 +305,7 @@ def execute_action(self, action, host_pattern=None, process_pattern=None): print("ERROR while stopping pillows. Exiting.") sys.exit(1) self._run_rolling_restart_yml(tags='action_stop') - elif action == 'start' or action == 'restart': + if action == 'start' or action == 'restart': exit_code = self._act_on_pillows(action=action) if not exit_code == 0: print("ERROR while starting pillows. Exiting.") From 9328828602a703ee1aee357628c85c6e886c9433 Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Wed, 1 Aug 2018 12:28:58 -0700 Subject: [PATCH 14/21] Fix process killing --- .../roles/elasticsearch/tasks/rolling_restart.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml b/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml index e8a4556779..500f9a58e0 100644 --- a/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml +++ b/src/commcare_cloud/ansible/roles/elasticsearch/tasks/rolling_restart.yml @@ -18,14 +18,15 @@ tags: action_stop - name: get es instances to kill - shell: "ps aux | pgrep 'elasticsearc[h]' | awk '{print $2}'" + shell: "ps aux | pgrep -f 'elasticsearc[h]'" register: es_pids + failed_when: es_pids.rc != 0 and es_pids.rc != 1 tags: action_stop - name: kill elasticsearch instances - shell: "pkill {{item}}" - with_items: es_pids - when: es_pids + shell: "pkill -f 'elasticsearc[h]'" + when: es_pids.rc != 0 and es_pids.rc != 1 + tags: action_stop - name: start node become: true From 4de9d7b95a56211c682d21ced56064549fa8d185 Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Wed, 1 Aug 2018 12:29:53 -0700 Subject: [PATCH 15/21] Remove .travis/secrets.tar.enc --- .travis/secrets.tar.enc | Bin 5648 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .travis/secrets.tar.enc diff --git a/.travis/secrets.tar.enc b/.travis/secrets.tar.enc deleted file mode 100644 index fc722695c6edcee4b933c52c34c564f17aba5e61..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5648 zcmV+r7Vqh`J!VqO?iHNEDGOBZCykaJ_PX(DwyL+Px$&Q5z%jCY|K`p8<-&)r)h;)T zDh-U^`Z@X2aE2w=8trSz3{T4%o+=3t4cB<_>&1H^Q?Nk$DjORc^n?ETtE0KbW#9^> zUDf3QZ0ymJSTccyOc}A9IG8$MhaTq=3oMf!VZO4iWDFA=&2WATVJ}^_{^B~2Qx7?fWqM6c3Ou58B0|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|rPsdl^ba0#2UV|PyC!wlo4)ezEs`Aq z(*42ji2gub9aKiB$asIfGZtt9_Yt8odTkBLDa$LRJ(`8ixT*(SMs*;iPO*|VRvq2h qd{)eb!mmchcyMYpzjAw~^)Gi7%>!0W5f{saGn)|5bcLn(G`@Qc{^+0p From 22227199893d3b1d5295f3322ee8283c93c59053 Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Wed, 1 Aug 2018 12:30:40 -0700 Subject: [PATCH 16/21] Remove restart-elasticsearch --- docs/changelog/index.md | 27 - docs/commcare-cloud/commands/index.md | 1026 ----------------- .../commands/ansible/ansible_playbook.py | 26 - src/commcare_cloud/commcare_cloud.py | 3 +- 4 files changed, 1 insertion(+), 1081 deletions(-) delete mode 100644 docs/changelog/index.md diff --git a/docs/changelog/index.md b/docs/changelog/index.md deleted file mode 100644 index c0893c1b17..0000000000 --- a/docs/changelog/index.md +++ /dev/null @@ -1,27 +0,0 @@ -# About this changelog - -The following changes to `commcare-cloud` that require your attention, -newest first. - -Changes that will require an action from anyone choosing -to update on or after the date listed will be maked "_action required_". -Those which are worth taking a look at but which may or may not require -an action on your part will be marked "_action optional_". - - -## Changelog - -### **2018-07-25** [Update Supervisor](0003-update-supervisor.md) -Ubuntu 14.04 `apt-get install supervisor` installs supervisor 3.0b. -We occasionally have issues that could be related to supervisor, -such as processes not stopping correctly. -To rule it out as a possible cause, -we decided it was better to be on a later version of supervisor, -and one that's not in beta. - -### **2018-07-13** [Update supervisor service definitions](0002-supervisor-service-definitions.md) (_action required_) -There are several CommCare specific processes that are defined in supervisor -configuration files. This change decouples the process definitions from code. - -### **2018-06-11** [Added encrypted temporary directory](0001-add-encrypted-tmp.md) (_action required_) -Some of the CommCare processes make use of temporary files to store client data (such as data exports) so in order to keep that data protected we have modified the setup to use an encrypted temporary directory. diff --git a/docs/commcare-cloud/commands/index.md b/docs/commcare-cloud/commands/index.md index 6aa5b9ea5f..e69de29bb2 100644 --- a/docs/commcare-cloud/commands/index.md +++ b/docs/commcare-cloud/commands/index.md @@ -1,1026 +0,0 @@ -# Commands - -* TOC -{:toc} - -## Running Commands with `commcare-cloud` - -All `commcare-cloud` commands take the following form: - -``` -commcare-cloud [--control] - - {bootstrap-users,ansible-playbook,django-manage,aps,tmux,ap,validate-environment-settings,restart-elasticsearch,deploy-stack,service,update-supervisor-confs,update-users,ping,migrate_couchdb,lookup,run-module,update-config,copy-files,mosh,after-reboot,ssh,downtime,fab,update-local-known-hosts,list-dbs,migrate-couchdb,run-shell-command} - ... -``` - -## Positional Arguments - -### `` - -server environment to run against - -## Optional Arguments - -### `--control` - -Run command remotely on the control machine. - -You can add `--control` _directly after_ `commcare-cloud` to any command -in order to run the command not from the local machine -using the local code, -but from from the control machine for that environment, -using the latest version of `commcare-cloud` available. - -It works by issuing a command to ssh into the control machine, -update the code, and run the same command entered locally but with -`--control` removed. For long-running commands, -you will have to remain connected to the the control machine -for the entirety of the run. - - -## `cchq` alias - -Additionally, `commcare-cloud` is aliased to the easier-to-type `cchq` -(short for "CommCare HQ"), so any command you see here can also be run -as - -``` -cchq -``` - -## Underlying tools and common arguments - -The `commcare-cloud` command line tool is by and large a relatively -thin wrapper around the other tools it uses: `ansible`, `ansible-playbook`, -`ssh`, `fab`, etc. For every command you run using `commcare-cloud`, -it will print out the underlying command that it is running, -a faint blue / cyan color. -In each case, if you copy and paste the printed command directly, -it will have essentially the same affect. -(Note too that some commands run -multiple underlying commands in sequence, -and that each command will be printed.) - -Where possible, `commcare-cloud` is set up to pass any unknown arguments -to the underlying tool. In addition, there are a number of common -arguments that are recognized by many `commcare-cloud` commands, -and have similar behavior on across them. Rather than include these -on every command they apply to, we will list upfront -these common arguments and when they can be used. - -To verify availability on any given command, you can always run the -command with `-h`. - -### Ansible-backed commands - -For most ansible-backed commands `commcare-cloud` -will run in check mode first, and then ask you to confirm -before applying the changes. Since check mode does not make sense -for all commands, there are some that do not follow this pattern -and apply the changes directly. - -### `--skip-check` - -When this argument is included, -the "check, ask, apply" behavior described above is circumvented, -and the command is instead applied directly - -### `--quiet` - -Run the command without every prompting for permission to continue. -At each point, the affirmative response is assumed. - -### `--branch ` - -In the specific case that `commcare-cloud` has been installed from -git source in egg mode (i.e. using `pip install -e .`), it will always -check that the checked-out git branch matches the `` -that is thus passed in. If this arg is not specified, -it defaults to `master`. As a consequence, when running from git branch -`master`, there is no need to use the `--branch` arg explicitly. - -### `--output [actionable|minimal]` - -The callback plugin to use for generating output. See -ansible-doc -t callback -l and ansible-doc -t callback. - -## Available Commands - -### Internal Housekeeping for your `commcare-cloud` environments - - -#### `validate-environment-settings` - -Validate your environment's configuration files - -``` -commcare-cloud validate-environment-settings -``` - -As you make changes to your environment files, you can use this -command to check for validation errors or incompatibilities. - - -#### `update-local-known-hosts` - -Update the local known_hosts file of the environment configuration. - -``` -commcare-cloud update-local-known-hosts [--use-factory-auth] -``` - -You can run this on a regular basis to avoid having to `yes` through -the ssh prompts. Note that when you run this, you are implicitly -trusting that at the moment you run it, there is no man-in-the-middle -attack going on, the type of security breech that the SSH prompt -is meant to mitigate against in the first place. - -##### Optional Arguments - -###### `--use-factory-auth` - -authenticate using the pem file (or prompt for root password if there is no pem file) - -### Ad-hoc - - -#### `lookup` - -Lookup remote hostname or IP address - -``` -commcare-cloud lookup [server] -``` - -##### Positional Arguments - -###### `server` - -Server name/group: postgresql, proxy, webworkers, ... The server -name/group may be prefixed with 'username@' to login as a -specific user and may be terminated with ':' to choose one of -multiple servers if there is more than one in the group. For -example: webworkers:0 will pick the first webworker. May also be -omitted for environments with only a single server. - - -#### `ssh` - -Connect to a remote host with ssh. - -``` -commcare-cloud ssh [server] -``` - -This will also automatically add the ssh argument `-A` -when `` is `control`. - -All trailing arguments are passed directly to `ssh`. - -##### Positional Arguments - -###### `server` - -Server name/group: postgresql, proxy, webworkers, ... The server -name/group may be prefixed with 'username@' to login as a -specific user and may be terminated with ':' to choose one of -multiple servers if there is more than one in the group. For -example: webworkers:0 will pick the first webworker. May also be -omitted for environments with only a single server. - - -#### `mosh` - -Connect to a remote host with mosh. - -``` -commcare-cloud mosh [server] -``` - -This will also automatically switch to using ssh with `-A` -when `` is `control` (because `mosh` doesn't support `-A`). - -All trailing arguments are passed directly to `mosh` -(or `ssh` in the edge case described above). - -##### Positional Arguments - -###### `server` - -Server name/group: postgresql, proxy, webworkers, ... The server -name/group may be prefixed with 'username@' to login as a -specific user and may be terminated with ':' to choose one of -multiple servers if there is more than one in the group. For -example: webworkers:0 will pick the first webworker. May also be -omitted for environments with only a single server. - - -#### `run-module` - -Run an arbitrary Ansible module. - -``` -commcare-cloud run-module [--use-factory-auth] inventory_group module module_args -``` - -#### Example - -To print out the `inventory_hostname` ansible variable for each machine, run -``` -commcare-cloud run-module all debug "msg={{ '{{' }} inventory_hostname }}" -``` - -##### Positional Arguments - -###### `inventory_group` - -Machines to run on. Is anything that could be used in as a value for -`hosts` in an playbook "play", e.g. -`all` for all machines, -`webworkers` for a single group, -`celery:pillowtop` for multiple groups, etc. -See the description in [this blog](http://goinbigdata.com/understanding-ansible-patterns/) -for more detail in what can go here. - -###### `module` - -The name of the ansible module to run. Complete list of built-in modules -can be found at [Module Index](http://docs.ansible.com/ansible/latest/modules/modules_by_category.html). - -###### `module_args` - -Args for the module, formatted as a single string. -(Tip: put quotes around it, as it will likely contain spaces.) -Both `arg1=value1 arg2=value2` syntax -and `{"arg1": "value1", "arg2": "value2"}` syntax are accepted. - -##### Optional Arguments - -###### `--use-factory-auth` - -authenticate using the pem file (or prompt for root password if there is no pem file) - -##### The ansible options below are available as well -``` - -B SECONDS, --background=SECONDS - run asynchronously, failing after X seconds - (default=N/A) - -e EXTRA_VARS, --extra-vars=EXTRA_VARS - set additional variables as key=value or YAML/JSON, if - filename prepend with @ - -f FORKS, --forks=FORKS - specify number of parallel processes to use - (default=5) - -l SUBSET, --limit=SUBSET - further limit selected hosts to an additional pattern - --list-hosts outputs a list of matching hosts; does not execute - anything else - -M MODULE_PATH, --module-path=MODULE_PATH - prepend colon-separated path(s) to module library - (default=[u'~/.ansible/plugins/modules', - u'/usr/share/ansible/plugins/modules']) - -o, --one-line condense output - -P POLL_INTERVAL, --poll=POLL_INTERVAL - set the poll interval if using -B (default=15) - --syntax-check perform a syntax check on the playbook, but do not - execute it - -t TREE, --tree=TREE log output to this directory - --vault-id=VAULT_IDS the vault identity to use - -v, --verbose verbose mode (-vvv for more, -vvvv to enable - connection debugging) - --version show program's version number and exit - -``` -##### Connection Options -``` - control as whom and how to connect to hosts - - -k, --ask-pass ask for connection password - --private-key=PRIVATE_KEY_FILE, --key-file=PRIVATE_KEY_FILE - use this file to authenticate the connection - -u REMOTE_USER, --user=REMOTE_USER - connect as this user (default=None) - -c CONNECTION, --connection=CONNECTION - connection type to use (default=smart) - -T TIMEOUT, --timeout=TIMEOUT - override the connection timeout in seconds - (default=10) - --ssh-common-args=SSH_COMMON_ARGS - specify common arguments to pass to sftp/scp/ssh (e.g. - ProxyCommand) - --sftp-extra-args=SFTP_EXTRA_ARGS - specify extra arguments to pass to sftp only (e.g. -f, - -l) - --scp-extra-args=SCP_EXTRA_ARGS - specify extra arguments to pass to scp only (e.g. -l) - --ssh-extra-args=SSH_EXTRA_ARGS - specify extra arguments to pass to ssh only (e.g. -R) - -``` -##### Privilege Escalation Options -``` - control how and which user you become as on target hosts - - --become-method=BECOME_METHOD - privilege escalation method to use (default=sudo), - valid choices: [ sudo | su | pbrun | pfexec | doas | - dzdo | ksu | runas | pmrun ] - -K, --ask-become-pass - ask for privilege escalation password -``` - - -#### `run-shell-command` - -Run an arbitrary command via the Ansible shell module. - -``` -commcare-cloud run-shell-command [--silence-warnings] [--use-factory-auth] inventory_group shell_command -``` - -#### Example - -``` -commcare-cloud run-shell-command all 'df -h | grep /opt/data' -``` - -to get disk usage stats for `/opt/data` on every machine. - -##### Positional Arguments - -###### `inventory_group` - -Machines to run on. Is anything that could be used in as a value for -`hosts` in an playbook "play", e.g. -`all` for all machines, -`webworkers` for a single group, -`celery:pillowtop` for multiple groups, etc. -See the description in [this blog](http://goinbigdata.com/understanding-ansible-patterns/) -for more detail in what can go here. - -###### `shell_command` - -Command to run remotely. -(Tip: put quotes around it, as it will likely contain spaces.) -Cannot being with `sudo`; to do that use the ansible `--become` option. - -##### Optional Arguments - -###### `--silence-warnings` - -Silence shell warnings (such as to use another module instead). - -###### `--use-factory-auth` - -authenticate using the pem file (or prompt for root password if there is no pem file) - -##### The ansible options below are available as well -``` - -B SECONDS, --background=SECONDS - run asynchronously, failing after X seconds - (default=N/A) - -e EXTRA_VARS, --extra-vars=EXTRA_VARS - set additional variables as key=value or YAML/JSON, if - filename prepend with @ - -f FORKS, --forks=FORKS - specify number of parallel processes to use - (default=5) - -l SUBSET, --limit=SUBSET - further limit selected hosts to an additional pattern - --list-hosts outputs a list of matching hosts; does not execute - anything else - -M MODULE_PATH, --module-path=MODULE_PATH - prepend colon-separated path(s) to module library - (default=[u'~/.ansible/plugins/modules', - u'/usr/share/ansible/plugins/modules']) - -o, --one-line condense output - -P POLL_INTERVAL, --poll=POLL_INTERVAL - set the poll interval if using -B (default=15) - --syntax-check perform a syntax check on the playbook, but do not - execute it - -t TREE, --tree=TREE log output to this directory - --vault-id=VAULT_IDS the vault identity to use - -v, --verbose verbose mode (-vvv for more, -vvvv to enable - connection debugging) - --version show program's version number and exit - -``` -##### Connection Options -``` - control as whom and how to connect to hosts - - -k, --ask-pass ask for connection password - --private-key=PRIVATE_KEY_FILE, --key-file=PRIVATE_KEY_FILE - use this file to authenticate the connection - -u REMOTE_USER, --user=REMOTE_USER - connect as this user (default=None) - -c CONNECTION, --connection=CONNECTION - connection type to use (default=smart) - -T TIMEOUT, --timeout=TIMEOUT - override the connection timeout in seconds - (default=10) - --ssh-common-args=SSH_COMMON_ARGS - specify common arguments to pass to sftp/scp/ssh (e.g. - ProxyCommand) - --sftp-extra-args=SFTP_EXTRA_ARGS - specify extra arguments to pass to sftp only (e.g. -f, - -l) - --scp-extra-args=SCP_EXTRA_ARGS - specify extra arguments to pass to scp only (e.g. -l) - --ssh-extra-args=SSH_EXTRA_ARGS - specify extra arguments to pass to ssh only (e.g. -R) - -``` -##### Privilege Escalation Options -``` - control how and which user you become as on target hosts - - --become-method=BECOME_METHOD - privilege escalation method to use (default=sudo), - valid choices: [ sudo | su | pbrun | pfexec | doas | - dzdo | ksu | runas | pmrun ] - -K, --ask-become-pass - ask for privilege escalation password -``` - - -#### `django-manage` - -Run a django management command. - -``` -commcare-cloud django-manage [--tmux] [--release RELEASE] -``` - -`commcare-cloud django-manage ...` -runs `./manage.py ...` on the first webworker of <env>. -Omit <command> to see a full list of possible commands. - -#### Example - -To open a django shell in a tmux window using the `2018-04-13_18.16` release. - -``` -commcare-cloud django-manage --tmux --release 2018-04-13_18.16 shell -``` - -##### Optional Arguments - -###### `--tmux` - -If this option is included, the management command will be -run in a new tmux window under the `cchq` user. You may then exit using -the customary tmux command `^b` `d`, and resume the session later. -This is especially useful for long-running commands. - -###### `--release RELEASE` - -Name of release to run under. -E.g. '2018-04-13_18.16'. -If none is specified, the `current` release will be used. - - -#### `tmux` - -Connect to a remote host with ssh and open a tmux session. - -``` -commcare-cloud tmux server [remote_command] -``` - -#### Example - -Rejoin last open tmux window. - -``` -commcare-cloud tmux - -``` - -##### Positional Arguments - -###### `server` - -Server to run tmux session on. -Use '-' for default (django_manage:0) - -###### `remote_command` - -Command to run in the tmux. -If a command specified, then it will always run in a new window. -If a command is *not* specified, then a it will rejoin the most -recently visited tmux window; only if there are no currently open -tmux windows will a new one be opened. - -### Operational - - -#### `ping` - -Ping specified or all machines to see if they have been provisioned yet. - -``` -commcare-cloud ping [--use-factory-auth] inventory_group -``` - -##### Positional Arguments - -###### `inventory_group` - -Machines to run on. Is anything that could be used in as a value for -`hosts` in an playbook "play", e.g. -`all` for all machines, -`webworkers` for a single group, -`celery:pillowtop` for multiple groups, etc. -See the description in [this blog](http://goinbigdata.com/understanding-ansible-patterns/) -for more detail in what can go here. - -##### Optional Arguments - -###### `--use-factory-auth` - -authenticate using the pem file (or prompt for root password if there is no pem file) - - -#### `ansible-playbook` -(Alias `ap`) - -Run a playbook as you would with ansible-playbook - -``` -commcare-cloud ansible-playbook [--use-factory-auth] playbook -``` - -By default, you will see --check output and then asked whether to apply. - -#### Example - -``` -commcare-cloud ansible-playbook deploy_proxy.yml --limit=proxy -``` - -##### Positional Arguments - -###### `playbook` - -The ansible playbook .yml file to run. -Options are the `*.yml` files located under `commcare_cloud/ansible` -which is under `src` for an egg install and under -`/lib/python2.7/site-packages` for a wheel install. - -##### Optional Arguments - -###### `--use-factory-auth` - -authenticate using the pem file (or prompt for root password if there is no pem file) - -##### The ansible-playbook options below are available as well -``` - -e EXTRA_VARS, --extra-vars=EXTRA_VARS - set additional variables as key=value or YAML/JSON, if - filename prepend with @ - --flush-cache clear the fact cache - --force-handlers run handlers even if a task fails - -f FORKS, --forks=FORKS - specify number of parallel processes to use - (default=5) - --list-hosts outputs a list of matching hosts; does not execute - anything else - --list-tags list all available tags - --list-tasks list all tasks that would be executed - -M MODULE_PATH, --module-path=MODULE_PATH - prepend colon-separated path(s) to module library - (default=[u'~/.ansible/plugins/modules', - u'/usr/share/ansible/plugins/modules']) - --skip-tags=SKIP_TAGS - only run plays and tasks whose tags do not match these - values - --start-at-task=START_AT_TASK - start the playbook at the task matching this name - --step one-step-at-a-time: confirm each task before running - --syntax-check perform a syntax check on the playbook, but do not - execute it - -t TAGS, --tags=TAGS only run plays and tasks tagged with these values - --vault-id=VAULT_IDS the vault identity to use - -v, --verbose verbose mode (-vvv for more, -vvvv to enable - connection debugging) - --version show program's version number and exit - -``` -##### Connection Options -``` - control as whom and how to connect to hosts - - -k, --ask-pass ask for connection password - --private-key=PRIVATE_KEY_FILE, --key-file=PRIVATE_KEY_FILE - use this file to authenticate the connection - -u REMOTE_USER, --user=REMOTE_USER - connect as this user (default=None) - -c CONNECTION, --connection=CONNECTION - connection type to use (default=smart) - -T TIMEOUT, --timeout=TIMEOUT - override the connection timeout in seconds - (default=10) - --ssh-common-args=SSH_COMMON_ARGS - specify common arguments to pass to sftp/scp/ssh (e.g. - ProxyCommand) - --sftp-extra-args=SFTP_EXTRA_ARGS - specify extra arguments to pass to sftp only (e.g. -f, - -l) - --scp-extra-args=SCP_EXTRA_ARGS - specify extra arguments to pass to scp only (e.g. -l) - --ssh-extra-args=SSH_EXTRA_ARGS - specify extra arguments to pass to ssh only (e.g. -R) - -``` -##### Privilege Escalation Options -``` - control how and which user you become as on target hosts - - -b, --become run operations with become (does not imply password - prompting) - --become-method=BECOME_METHOD - privilege escalation method to use (default=sudo), - valid choices: [ sudo | su | pbrun | pfexec | doas | - dzdo | ksu | runas | pmrun ] - --become-user=BECOME_USER - run operations as this user (default=root) - -K, --ask-become-pass - ask for privilege escalation password -``` - - -#### `deploy-stack` -(Alias `aps`) - -Run the ansible playbook for deploying the entire stack. - -``` -commcare-cloud deploy-stack [--use-factory-auth] -``` - -Often used in conjunction with --limit and/or --tag -for a more specific update. - -##### Optional Arguments - -###### `--use-factory-auth` - -authenticate using the pem file (or prompt for root password if there is no pem file) - - -#### `update-config` - -Run the ansible playbook for updating app config. - -``` -commcare-cloud update-config [--use-factory-auth] -``` - -This includes django `localsettings.py` and formplayer `application.properties`. - -##### Optional Arguments - -###### `--use-factory-auth` - -authenticate using the pem file (or prompt for root password if there is no pem file) - - -#### `after-reboot` - -Bring a just-rebooted machine back into operation. - -``` -commcare-cloud after-reboot [--use-factory-auth] inventory_group -``` - -Includes mounting the encrypted drive. -This command never runs in check mode. - -##### Positional Arguments - -###### `inventory_group` - -Machines to run on. Is anything that could be used in as a value for -`hosts` in an playbook "play", e.g. -`all` for all machines, -`webworkers` for a single group, -`celery:pillowtop` for multiple groups, etc. -See the description in [this blog](http://goinbigdata.com/understanding-ansible-patterns/) -for more detail in what can go here. - -##### Optional Arguments - -###### `--use-factory-auth` - -authenticate using the pem file (or prompt for root password if there is no pem file) - - -#### `restart-elasticsearch` - -Do a rolling restart of elasticsearch. - -``` -commcare-cloud restart-elasticsearch [--use-factory-auth] -``` - -**This command is deprecated.** Use - -``` -commcare-cloud service elasticsearch restart -``` - -instead. - -##### Optional Arguments - -###### `--use-factory-auth` - -authenticate using the pem file (or prompt for root password if there is no pem file) - - -#### `bootstrap-users` - -Add users to a set of new machines as root. - -``` -commcare-cloud bootstrap-users [--use-factory-auth] -``` - -This must be done before any other user can log in. - -This will set up machines to reject root login and require -password-less logins based on the usernames and public keys -you have specified in your environment. This can only be run once -per machine; if after running it you would like to run it again, -you have to use `update-users` below instead. - -##### Optional Arguments - -###### `--use-factory-auth` - -authenticate using the pem file (or prompt for root password if there is no pem file) - - -#### `update-users` - -Bring users up to date with the current CommCare Cloud settings. - -``` -commcare-cloud update-users [--use-factory-auth] -``` - -In steady state this command (and not `bootstrap-users`) should be used -to keep machine user accounts, permissions, and login information -up to date. - -##### Optional Arguments - -###### `--use-factory-auth` - -authenticate using the pem file (or prompt for root password if there is no pem file) - - -#### `update-supervisor-confs` - -Updates the supervisor configuration files for services required by CommCare. - -``` -commcare-cloud update-supervisor-confs [--use-factory-auth] -``` - -These services are defined in app-processes.yml. - -##### Optional Arguments - -###### `--use-factory-auth` - -authenticate using the pem file (or prompt for root password if there is no pem file) - - -#### `fab` - -Run a fab command as you would with fab - -``` -commcare-cloud fab [-l] [fab_command] -``` - -##### Positional Arguments - -###### `fab_command` - -The name of the fab task to run. It and all following arguments -will be passed on without modification to `fab`, so all normal `fab` -syntax rules apply. - -##### Optional Arguments - -###### `-l` - -Use `-l` instead of a command to see the full list of commands. - -##### Available commands -``` - - apply_patch Used to apply a git patch created via `git for... - awesome_deploy Preindex and deploy if it completes quickly en... - check_status - clean_offline_releases Cleans all releases in home directory - clean_releases Cleans old and failed deploys from the ~/www/<... - deploy Preindex and deploy if it completes quickly en... - deploy_airflow - deploy_formplayer - force_update_static - hotfix_deploy deploy ONLY the code with no extra cleanup or ... - kill_stale_celery_workers Kills celery workers that failed to properly g... - manage run a management command - offline_setup_release - perform_system_checks - pillowtop - preindex_views Creates a new release that runs preindex_every... - prepare_offline_deploy - reset_mvp_pillows - restart_services - reverse_patch Used to reverse a git patch created via `git f... - rollback Rolls back the servers to the previous release... - rollback_formplayer - setup_limited_release Sets up a release on a single machine - setup_release Sets up a full release across the cluster - start_celery - start_pillows - stop_celery - stop_pillows - supervisorctl - unlink_current Unlinks the current code directory. Use with c... - update_current - webworkers -``` - - -#### `service` - -Manage services. - -``` -commcare-cloud service [--only PROCESS_PATTERN] - - {celery,commcare,couchdb,couchdb2,elasticsearch,formplayer,kafka,nginx,pillowtop,postgresql,rabbitmq,redis,riakcs,touchforms,webworker} - [{celery,commcare,couchdb,couchdb2,elasticsearch,formplayer,kafka,nginx,pillowtop,postgresql,rabbitmq,redis,riakcs,touchforms,webworker} ...] - {start,stop,restart,status,help} -``` - -#### Example - -``` -cchq service postgresql status -cchq service riakcs restart --only riak,riakcs -cchq service celery help -cchq service celery restart --limit -cchq service celery restart --only ,: -cchq service pillowtop restart --limit --only -``` - -Services are grouped together to form conceptual service groups. -Thus the `postgresql` service group applies to both the `postgresql` -service and the `pgbouncer` service. We'll call the actual services -"subservices" here. - -##### Positional Arguments - -###### `{celery,commcare,couchdb,couchdb2,elasticsearch,formplayer,kafka,nginx,pillowtop,postgresql,rabbitmq,redis,riakcs,touchforms,webworker}` - -The name of the service group(s) to apply the action to. -There is a preset list of service groups that are supported. -More than one service may be supplied as separate arguments in a row. - -###### `{start,stop,restart,status,help}` - -Action can be `status`, `start`, `stop`, or `restart`. -This action is applied to every matching service. - -##### Optional Arguments - -###### `--only PROCESS_PATTERN` - -Sub-service name to limit action to. -Format as 'name' or 'name:number'. -Use 'help' action to list all options. - - -#### `migrate-couchdb` -(Alias `migrate_couchdb`) - -Perform a CouchDB migration - -``` -commcare-cloud migrate-couchdb migration_plan {describe,plan,migrate,commit,clean} -``` - -This is a recent and advanced addition to the capabilities, -and is not yet ready for widespread use. At such a time as it is -ready, it will be more thoroughly documented. - -##### Positional Arguments - -###### `migration_plan` - -Path to migration plan file - -###### `{describe,plan,migrate,commit,clean}` - -Action to perform - -- describe: Print out cluster info -- plan: generate plan details from migration plan -- migrate: stop nodes and copy shard data according to plan -- commit: update database docs with new shard allocation -- clean: remove shard files from hosts where they aren't needed - - -#### `downtime` - -Manage downtime for the selected environment. - -``` -commcare-cloud downtime [-m MESSAGE] {start,end} -``` - -This notifies Datadog of the planned downtime so that is is recorded -in the history, and so that during it service alerts are silenced. - -##### Positional Arguments - -###### `{start,end}` - -##### Optional Arguments - -###### `-m MESSAGE, --message MESSAGE` - -Optional message to set on Datadog. - - -#### `copy-files` - -Copy files from multiple sources to targets. - -``` -commcare-cloud copy-files plan {prepare,copy,cleanup} -``` - -This is a general purpose command that can be used to copy files between -hosts in the cluster. - -Files are copied using `rsync` from the target host. This tool assumes that the -specified user on the source host has permissions to read the files being copied. - -The plan file must be formatted as follows: - -```yml -copy_files: - - : - - source_host: - source_user: - source_dir: - target_dir: - files: - - test/ - - test1/test-file.txt - exclude: - - logs/* - - test/temp.txt -``` -- **copy_files**: Multiple target hosts can be listed. -- **target-host**: Hostname or IP of the target host. Multiple source definitions can be -listed for each target host. -- **source-host**: Hostname or IP of the source host. -- **source-user**: (optional) User to ssh as from target to source. Defaults to 'ansible'. This user must have permissions -to read the files being copied. -- **source-dir**: The base directory from which all source files referenced. -- **target-dir**: Directory on the target host to copy the files to. -- **files**: List of files to copy. File paths are relative to `source-dir`. Directories can be included and must -end with a `/`. -- **exclude**: (optional) List of relative paths to exclude from the *source-dir*. Supports wildcards e.g. "logs/*". - -##### Positional Arguments - -###### `plan` - -Path to plan file - -###### `{prepare,copy,cleanup}` - -Action to perform - -- prepare: generate the scripts and push them to the target servers -- migrate: execute the scripts -- cleanup: remove temporary files and remote auth - - -#### `list-dbs` - -List out databases by host - -``` -commcare-cloud list-dbs -``` diff --git a/src/commcare_cloud/commands/ansible/ansible_playbook.py b/src/commcare_cloud/commands/ansible/ansible_playbook.py index 2e5a881049..aeea99e863 100644 --- a/src/commcare_cloud/commands/ansible/ansible_playbook.py +++ b/src/commcare_cloud/commands/ansible/ansible_playbook.py @@ -210,32 +210,6 @@ def run(self, args, unknown_args): return AnsiblePlaybook(self.parser).run(args, unknown_args, always_skip_check=True) -class RestartElasticsearch(_AnsiblePlaybookAlias): - command = 'restart-elasticsearch' - help = """ - Do a rolling restart of elasticsearch. - - **This command is deprecated.** Use - - ``` - commcare-cloud service elasticsearch restart - ``` - - instead. - """ - - def run(self, args, unknown_args): - args.playbook = 'es_rolling_restart.yml' - if not ask('Have you stopped all the elastic pillows?', strict=True, quiet=args.quiet): - return 0 # exit code - puts(colored.yellow( - "This will cause downtime on the order of seconds to minutes,\n" - "except in a few cases where an index is replicated across multiple nodes.")) - if not ask('Do a rolling restart of the ES cluster?', strict=True, quiet=args.quiet): - return 0 # exit code - return AnsiblePlaybook(self.parser).run(args, unknown_args) - - class BootstrapUsers(_AnsiblePlaybookAlias): command = 'bootstrap-users' help = """ diff --git a/src/commcare_cloud/commcare_cloud.py b/src/commcare_cloud/commcare_cloud.py index 4779ea4f57..834f7f3fde 100644 --- a/src/commcare_cloud/commcare_cloud.py +++ b/src/commcare_cloud/commcare_cloud.py @@ -19,7 +19,7 @@ from .commands.ansible.ansible_playbook import ( AnsiblePlaybook, - UpdateConfig, AfterReboot, RestartElasticsearch, BootstrapUsers, DeployStack, + UpdateConfig, AfterReboot, BootstrapUsers, DeployStack, UpdateUsers, UpdateSupervisorConfs, UpdateLocalKnownHosts, ) from commcare_cloud.commands.ansible.service import Service @@ -53,7 +53,6 @@ DeployStack, UpdateConfig, AfterReboot, - RestartElasticsearch, BootstrapUsers, UpdateUsers, UpdateSupervisorConfs, From ecdfce5dd2cd8f71ead921d1a5af71da0c563a8b Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Wed, 1 Aug 2018 12:32:47 -0700 Subject: [PATCH 17/21] Update docs --- docs/basics/0002-installation.md | 2 +- docs/commcare-cloud/commands/index.md | 1003 +++++++++++++++++++++++++ 2 files changed, 1004 insertions(+), 1 deletion(-) diff --git a/docs/basics/0002-installation.md b/docs/basics/0002-installation.md index f4de2d1d0b..73fcfbcdfb 100644 --- a/docs/basics/0002-installation.md +++ b/docs/basics/0002-installation.md @@ -78,7 +78,7 @@ admin@control.example.com:~$ commcare-cloud -h usage: commcare-cloud [-h] [--control] {64-test,development,echis,icds,icds-new,pna,production,softlayer,staging,swiss} - {bootstrap-users,ansible-playbook,django-manage,aps,tmux,ap,validate-environment-settings,restart-elasticsearch,deploy-stack,service,update-supervisor-confs,update-users,ping,migrate_couchdb,lookup,run-module,update-config,mosh,after-reboot,ssh,downtime,fab,update-local-known-hosts,migrate-couchdb,run-shell-command} + {bootstrap-users,ansible-playbook,django-manage,aps,tmux,ap,validate-environment-settings,deploy-stack,service,update-supervisor-confs,update-users,ping,migrate_couchdb,lookup,run-module,update-config,mosh,after-reboot,ssh,downtime,fab,update-local-known-hosts,migrate-couchdb,run-shell-command} ... ``` diff --git a/docs/commcare-cloud/commands/index.md b/docs/commcare-cloud/commands/index.md index e69de29bb2..be7f339986 100644 --- a/docs/commcare-cloud/commands/index.md +++ b/docs/commcare-cloud/commands/index.md @@ -0,0 +1,1003 @@ +# Commands + +* TOC +{:toc} + +## Running Commands with `commcare-cloud` + +All `commcare-cloud` commands take the following form: + +``` +commcare-cloud [--control] + + {bootstrap-users,ansible-playbook,django-manage,aps,tmux,ap,validate-environment-settings,deploy-stack,service,update-supervisor-confs,update-users,ping,migrate_couchdb,lookup,run-module,update-config,copy-files,mosh,after-reboot,ssh,downtime,fab,update-local-known-hosts,list-dbs,migrate-couchdb,run-shell-command} + ... +``` + +## Positional Arguments + +### `` + +server environment to run against + +## Optional Arguments + +### `--control` + +Run command remotely on the control machine. + +You can add `--control` _directly after_ `commcare-cloud` to any command +in order to run the command not from the local machine +using the local code, +but from from the control machine for that environment, +using the latest version of `commcare-cloud` available. + +It works by issuing a command to ssh into the control machine, +update the code, and run the same command entered locally but with +`--control` removed. For long-running commands, +you will have to remain connected to the the control machine +for the entirety of the run. + + +## `cchq` alias + +Additionally, `commcare-cloud` is aliased to the easier-to-type `cchq` +(short for "CommCare HQ"), so any command you see here can also be run +as + +``` +cchq +``` + +## Underlying tools and common arguments + +The `commcare-cloud` command line tool is by and large a relatively +thin wrapper around the other tools it uses: `ansible`, `ansible-playbook`, +`ssh`, `fab`, etc. For every command you run using `commcare-cloud`, +it will print out the underlying command that it is running, +a faint blue / cyan color. +In each case, if you copy and paste the printed command directly, +it will have essentially the same affect. +(Note too that some commands run +multiple underlying commands in sequence, +and that each command will be printed.) + +Where possible, `commcare-cloud` is set up to pass any unknown arguments +to the underlying tool. In addition, there are a number of common +arguments that are recognized by many `commcare-cloud` commands, +and have similar behavior on across them. Rather than include these +on every command they apply to, we will list upfront +these common arguments and when they can be used. + +To verify availability on any given command, you can always run the +command with `-h`. + +### Ansible-backed commands + +For most ansible-backed commands `commcare-cloud` +will run in check mode first, and then ask you to confirm +before applying the changes. Since check mode does not make sense +for all commands, there are some that do not follow this pattern +and apply the changes directly. + +### `--skip-check` + +When this argument is included, +the "check, ask, apply" behavior described above is circumvented, +and the command is instead applied directly + +### `--quiet` + +Run the command without every prompting for permission to continue. +At each point, the affirmative response is assumed. + +### `--branch ` + +In the specific case that `commcare-cloud` has been installed from +git source in egg mode (i.e. using `pip install -e .`), it will always +check that the checked-out git branch matches the `` +that is thus passed in. If this arg is not specified, +it defaults to `master`. As a consequence, when running from git branch +`master`, there is no need to use the `--branch` arg explicitly. + +### `--output [actionable|minimal]` + +The callback plugin to use for generating output. See +ansible-doc -t callback -l and ansible-doc -t callback. + +## Available Commands + +### Internal Housekeeping for your `commcare-cloud` environments + + +#### `validate-environment-settings` + +Validate your environment's configuration files + +``` +commcare-cloud validate-environment-settings +``` + +As you make changes to your environment files, you can use this +command to check for validation errors or incompatibilities. + + +#### `update-local-known-hosts` + +Update the local known_hosts file of the environment configuration. + +``` +commcare-cloud update-local-known-hosts [--use-factory-auth] +``` + +You can run this on a regular basis to avoid having to `yes` through +the ssh prompts. Note that when you run this, you are implicitly +trusting that at the moment you run it, there is no man-in-the-middle +attack going on, the type of security breech that the SSH prompt +is meant to mitigate against in the first place. + +##### Optional Arguments + +###### `--use-factory-auth` + +authenticate using the pem file (or prompt for root password if there is no pem file) + +### Ad-hoc + + +#### `lookup` + +Lookup remote hostname or IP address + +``` +commcare-cloud lookup [server] +``` + +##### Positional Arguments + +###### `server` + +Server name/group: postgresql, proxy, webworkers, ... The server +name/group may be prefixed with 'username@' to login as a +specific user and may be terminated with ':' to choose one of +multiple servers if there is more than one in the group. For +example: webworkers:0 will pick the first webworker. May also be +omitted for environments with only a single server. + + +#### `ssh` + +Connect to a remote host with ssh. + +``` +commcare-cloud ssh [server] +``` + +This will also automatically add the ssh argument `-A` +when `` is `control`. + +All trailing arguments are passed directly to `ssh`. + +##### Positional Arguments + +###### `server` + +Server name/group: postgresql, proxy, webworkers, ... The server +name/group may be prefixed with 'username@' to login as a +specific user and may be terminated with ':' to choose one of +multiple servers if there is more than one in the group. For +example: webworkers:0 will pick the first webworker. May also be +omitted for environments with only a single server. + + +#### `mosh` + +Connect to a remote host with mosh. + +``` +commcare-cloud mosh [server] +``` + +This will also automatically switch to using ssh with `-A` +when `` is `control` (because `mosh` doesn't support `-A`). + +All trailing arguments are passed directly to `mosh` +(or `ssh` in the edge case described above). + +##### Positional Arguments + +###### `server` + +Server name/group: postgresql, proxy, webworkers, ... The server +name/group may be prefixed with 'username@' to login as a +specific user and may be terminated with ':' to choose one of +multiple servers if there is more than one in the group. For +example: webworkers:0 will pick the first webworker. May also be +omitted for environments with only a single server. + + +#### `run-module` + +Run an arbitrary Ansible module. + +``` +commcare-cloud run-module [--use-factory-auth] inventory_group module module_args +``` + +#### Example + +To print out the `inventory_hostname` ansible variable for each machine, run +``` +commcare-cloud run-module all debug "msg={{ '{{' }} inventory_hostname }}" +``` + +##### Positional Arguments + +###### `inventory_group` + +Machines to run on. Is anything that could be used in as a value for +`hosts` in an playbook "play", e.g. +`all` for all machines, +`webworkers` for a single group, +`celery:pillowtop` for multiple groups, etc. +See the description in [this blog](http://goinbigdata.com/understanding-ansible-patterns/) +for more detail in what can go here. + +###### `module` + +The name of the ansible module to run. Complete list of built-in modules +can be found at [Module Index](http://docs.ansible.com/ansible/latest/modules/modules_by_category.html). + +###### `module_args` + +Args for the module, formatted as a single string. +(Tip: put quotes around it, as it will likely contain spaces.) +Both `arg1=value1 arg2=value2` syntax +and `{"arg1": "value1", "arg2": "value2"}` syntax are accepted. + +##### Optional Arguments + +###### `--use-factory-auth` + +authenticate using the pem file (or prompt for root password if there is no pem file) + +##### The ansible options below are available as well +``` + -B SECONDS, --background=SECONDS + run asynchronously, failing after X seconds + (default=N/A) + -e EXTRA_VARS, --extra-vars=EXTRA_VARS + set additional variables as key=value or YAML/JSON, if + filename prepend with @ + -f FORKS, --forks=FORKS + specify number of parallel processes to use + (default=5) + -l SUBSET, --limit=SUBSET + further limit selected hosts to an additional pattern + --list-hosts outputs a list of matching hosts; does not execute + anything else + -M MODULE_PATH, --module-path=MODULE_PATH + prepend colon-separated path(s) to module library + (default=[u'~/.ansible/plugins/modules', + u'/usr/share/ansible/plugins/modules']) + -o, --one-line condense output + -P POLL_INTERVAL, --poll=POLL_INTERVAL + set the poll interval if using -B (default=15) + --syntax-check perform a syntax check on the playbook, but do not + execute it + -t TREE, --tree=TREE log output to this directory + --vault-id=VAULT_IDS the vault identity to use + -v, --verbose verbose mode (-vvv for more, -vvvv to enable + connection debugging) + --version show program's version number and exit + +``` +##### Connection Options +``` + control as whom and how to connect to hosts + + -k, --ask-pass ask for connection password + --private-key=PRIVATE_KEY_FILE, --key-file=PRIVATE_KEY_FILE + use this file to authenticate the connection + -u REMOTE_USER, --user=REMOTE_USER + connect as this user (default=None) + -c CONNECTION, --connection=CONNECTION + connection type to use (default=smart) + -T TIMEOUT, --timeout=TIMEOUT + override the connection timeout in seconds + (default=10) + --ssh-common-args=SSH_COMMON_ARGS + specify common arguments to pass to sftp/scp/ssh (e.g. + ProxyCommand) + --sftp-extra-args=SFTP_EXTRA_ARGS + specify extra arguments to pass to sftp only (e.g. -f, + -l) + --scp-extra-args=SCP_EXTRA_ARGS + specify extra arguments to pass to scp only (e.g. -l) + --ssh-extra-args=SSH_EXTRA_ARGS + specify extra arguments to pass to ssh only (e.g. -R) + +``` +##### Privilege Escalation Options +``` + control how and which user you become as on target hosts + + --become-method=BECOME_METHOD + privilege escalation method to use (default=sudo), + valid choices: [ sudo | su | pbrun | pfexec | doas | + dzdo | ksu | runas | pmrun ] + -K, --ask-become-pass + ask for privilege escalation password +``` + + +#### `run-shell-command` + +Run an arbitrary command via the Ansible shell module. + +``` +commcare-cloud run-shell-command [--silence-warnings] [--use-factory-auth] inventory_group shell_command +``` + +#### Example + +``` +commcare-cloud run-shell-command all 'df -h | grep /opt/data' +``` + +to get disk usage stats for `/opt/data` on every machine. + +##### Positional Arguments + +###### `inventory_group` + +Machines to run on. Is anything that could be used in as a value for +`hosts` in an playbook "play", e.g. +`all` for all machines, +`webworkers` for a single group, +`celery:pillowtop` for multiple groups, etc. +See the description in [this blog](http://goinbigdata.com/understanding-ansible-patterns/) +for more detail in what can go here. + +###### `shell_command` + +Command to run remotely. +(Tip: put quotes around it, as it will likely contain spaces.) +Cannot being with `sudo`; to do that use the ansible `--become` option. + +##### Optional Arguments + +###### `--silence-warnings` + +Silence shell warnings (such as to use another module instead). + +###### `--use-factory-auth` + +authenticate using the pem file (or prompt for root password if there is no pem file) + +##### The ansible options below are available as well +``` + -B SECONDS, --background=SECONDS + run asynchronously, failing after X seconds + (default=N/A) + -e EXTRA_VARS, --extra-vars=EXTRA_VARS + set additional variables as key=value or YAML/JSON, if + filename prepend with @ + -f FORKS, --forks=FORKS + specify number of parallel processes to use + (default=5) + -l SUBSET, --limit=SUBSET + further limit selected hosts to an additional pattern + --list-hosts outputs a list of matching hosts; does not execute + anything else + -M MODULE_PATH, --module-path=MODULE_PATH + prepend colon-separated path(s) to module library + (default=[u'~/.ansible/plugins/modules', + u'/usr/share/ansible/plugins/modules']) + -o, --one-line condense output + -P POLL_INTERVAL, --poll=POLL_INTERVAL + set the poll interval if using -B (default=15) + --syntax-check perform a syntax check on the playbook, but do not + execute it + -t TREE, --tree=TREE log output to this directory + --vault-id=VAULT_IDS the vault identity to use + -v, --verbose verbose mode (-vvv for more, -vvvv to enable + connection debugging) + --version show program's version number and exit + +``` +##### Connection Options +``` + control as whom and how to connect to hosts + + -k, --ask-pass ask for connection password + --private-key=PRIVATE_KEY_FILE, --key-file=PRIVATE_KEY_FILE + use this file to authenticate the connection + -u REMOTE_USER, --user=REMOTE_USER + connect as this user (default=None) + -c CONNECTION, --connection=CONNECTION + connection type to use (default=smart) + -T TIMEOUT, --timeout=TIMEOUT + override the connection timeout in seconds + (default=10) + --ssh-common-args=SSH_COMMON_ARGS + specify common arguments to pass to sftp/scp/ssh (e.g. + ProxyCommand) + --sftp-extra-args=SFTP_EXTRA_ARGS + specify extra arguments to pass to sftp only (e.g. -f, + -l) + --scp-extra-args=SCP_EXTRA_ARGS + specify extra arguments to pass to scp only (e.g. -l) + --ssh-extra-args=SSH_EXTRA_ARGS + specify extra arguments to pass to ssh only (e.g. -R) + +``` +##### Privilege Escalation Options +``` + control how and which user you become as on target hosts + + --become-method=BECOME_METHOD + privilege escalation method to use (default=sudo), + valid choices: [ sudo | su | pbrun | pfexec | doas | + dzdo | ksu | runas | pmrun ] + -K, --ask-become-pass + ask for privilege escalation password +``` + + +#### `django-manage` + +Run a django management command. + +``` +commcare-cloud django-manage [--tmux] [--release RELEASE] +``` + +`commcare-cloud django-manage ...` +runs `./manage.py ...` on the first webworker of <env>. +Omit <command> to see a full list of possible commands. + +#### Example + +To open a django shell in a tmux window using the `2018-04-13_18.16` release. + +``` +commcare-cloud django-manage --tmux --release 2018-04-13_18.16 shell +``` + +##### Optional Arguments + +###### `--tmux` + +If this option is included, the management command will be +run in a new tmux window under the `cchq` user. You may then exit using +the customary tmux command `^b` `d`, and resume the session later. +This is especially useful for long-running commands. + +###### `--release RELEASE` + +Name of release to run under. +E.g. '2018-04-13_18.16'. +If none is specified, the `current` release will be used. + + +#### `tmux` + +Connect to a remote host with ssh and open a tmux session. + +``` +commcare-cloud tmux server [remote_command] +``` + +#### Example + +Rejoin last open tmux window. + +``` +commcare-cloud tmux - +``` + +##### Positional Arguments + +###### `server` + +Server to run tmux session on. +Use '-' for default (django_manage:0) + +###### `remote_command` + +Command to run in the tmux. +If a command specified, then it will always run in a new window. +If a command is *not* specified, then a it will rejoin the most +recently visited tmux window; only if there are no currently open +tmux windows will a new one be opened. + +### Operational + + +#### `ping` + +Ping specified or all machines to see if they have been provisioned yet. + +``` +commcare-cloud ping [--use-factory-auth] inventory_group +``` + +##### Positional Arguments + +###### `inventory_group` + +Machines to run on. Is anything that could be used in as a value for +`hosts` in an playbook "play", e.g. +`all` for all machines, +`webworkers` for a single group, +`celery:pillowtop` for multiple groups, etc. +See the description in [this blog](http://goinbigdata.com/understanding-ansible-patterns/) +for more detail in what can go here. + +##### Optional Arguments + +###### `--use-factory-auth` + +authenticate using the pem file (or prompt for root password if there is no pem file) + + +#### `ansible-playbook` +(Alias `ap`) + +Run a playbook as you would with ansible-playbook + +``` +commcare-cloud ansible-playbook [--use-factory-auth] playbook +``` + +By default, you will see --check output and then asked whether to apply. + +#### Example + +``` +commcare-cloud ansible-playbook deploy_proxy.yml --limit=proxy +``` + +##### Positional Arguments + +###### `playbook` + +The ansible playbook .yml file to run. +Options are the `*.yml` files located under `commcare_cloud/ansible` +which is under `src` for an egg install and under +`/lib/python2.7/site-packages` for a wheel install. + +##### Optional Arguments + +###### `--use-factory-auth` + +authenticate using the pem file (or prompt for root password if there is no pem file) + +##### The ansible-playbook options below are available as well +``` + -e EXTRA_VARS, --extra-vars=EXTRA_VARS + set additional variables as key=value or YAML/JSON, if + filename prepend with @ + --flush-cache clear the fact cache + --force-handlers run handlers even if a task fails + -f FORKS, --forks=FORKS + specify number of parallel processes to use + (default=5) + --list-hosts outputs a list of matching hosts; does not execute + anything else + --list-tags list all available tags + --list-tasks list all tasks that would be executed + -M MODULE_PATH, --module-path=MODULE_PATH + prepend colon-separated path(s) to module library + (default=[u'~/.ansible/plugins/modules', + u'/usr/share/ansible/plugins/modules']) + --skip-tags=SKIP_TAGS + only run plays and tasks whose tags do not match these + values + --start-at-task=START_AT_TASK + start the playbook at the task matching this name + --step one-step-at-a-time: confirm each task before running + --syntax-check perform a syntax check on the playbook, but do not + execute it + -t TAGS, --tags=TAGS only run plays and tasks tagged with these values + --vault-id=VAULT_IDS the vault identity to use + -v, --verbose verbose mode (-vvv for more, -vvvv to enable + connection debugging) + --version show program's version number and exit + +``` +##### Connection Options +``` + control as whom and how to connect to hosts + + -k, --ask-pass ask for connection password + --private-key=PRIVATE_KEY_FILE, --key-file=PRIVATE_KEY_FILE + use this file to authenticate the connection + -u REMOTE_USER, --user=REMOTE_USER + connect as this user (default=None) + -c CONNECTION, --connection=CONNECTION + connection type to use (default=smart) + -T TIMEOUT, --timeout=TIMEOUT + override the connection timeout in seconds + (default=10) + --ssh-common-args=SSH_COMMON_ARGS + specify common arguments to pass to sftp/scp/ssh (e.g. + ProxyCommand) + --sftp-extra-args=SFTP_EXTRA_ARGS + specify extra arguments to pass to sftp only (e.g. -f, + -l) + --scp-extra-args=SCP_EXTRA_ARGS + specify extra arguments to pass to scp only (e.g. -l) + --ssh-extra-args=SSH_EXTRA_ARGS + specify extra arguments to pass to ssh only (e.g. -R) + +``` +##### Privilege Escalation Options +``` + control how and which user you become as on target hosts + + -b, --become run operations with become (does not imply password + prompting) + --become-method=BECOME_METHOD + privilege escalation method to use (default=sudo), + valid choices: [ sudo | su | pbrun | pfexec | doas | + dzdo | ksu | runas | pmrun ] + --become-user=BECOME_USER + run operations as this user (default=root) + -K, --ask-become-pass + ask for privilege escalation password +``` + + +#### `deploy-stack` +(Alias `aps`) + +Run the ansible playbook for deploying the entire stack. + +``` +commcare-cloud deploy-stack [--use-factory-auth] +``` + +Often used in conjunction with --limit and/or --tag +for a more specific update. + +##### Optional Arguments + +###### `--use-factory-auth` + +authenticate using the pem file (or prompt for root password if there is no pem file) + + +#### `update-config` + +Run the ansible playbook for updating app config. + +``` +commcare-cloud update-config [--use-factory-auth] +``` + +This includes django `localsettings.py` and formplayer `application.properties`. + +##### Optional Arguments + +###### `--use-factory-auth` + +authenticate using the pem file (or prompt for root password if there is no pem file) + + +#### `after-reboot` + +Bring a just-rebooted machine back into operation. + +``` +commcare-cloud after-reboot [--use-factory-auth] inventory_group +``` + +Includes mounting the encrypted drive. +This command never runs in check mode. + +##### Positional Arguments + +###### `inventory_group` + +Machines to run on. Is anything that could be used in as a value for +`hosts` in an playbook "play", e.g. +`all` for all machines, +`webworkers` for a single group, +`celery:pillowtop` for multiple groups, etc. +See the description in [this blog](http://goinbigdata.com/understanding-ansible-patterns/) +for more detail in what can go here. + +##### Optional Arguments + +###### `--use-factory-auth` + +authenticate using the pem file (or prompt for root password if there is no pem file) + + +#### `bootstrap-users` + +Add users to a set of new machines as root. + +``` +commcare-cloud bootstrap-users [--use-factory-auth] +``` + +This must be done before any other user can log in. + +This will set up machines to reject root login and require +password-less logins based on the usernames and public keys +you have specified in your environment. This can only be run once +per machine; if after running it you would like to run it again, +you have to use `update-users` below instead. + +##### Optional Arguments + +###### `--use-factory-auth` + +authenticate using the pem file (or prompt for root password if there is no pem file) + + +#### `update-users` + +Bring users up to date with the current CommCare Cloud settings. + +``` +commcare-cloud update-users [--use-factory-auth] +``` + +In steady state this command (and not `bootstrap-users`) should be used +to keep machine user accounts, permissions, and login information +up to date. + +##### Optional Arguments + +###### `--use-factory-auth` + +authenticate using the pem file (or prompt for root password if there is no pem file) + + +#### `update-supervisor-confs` + +Updates the supervisor configuration files for services required by CommCare. + +``` +commcare-cloud update-supervisor-confs [--use-factory-auth] +``` + +These services are defined in app-processes.yml. + +##### Optional Arguments + +###### `--use-factory-auth` + +authenticate using the pem file (or prompt for root password if there is no pem file) + + +#### `fab` + +Run a fab command as you would with fab + +``` +commcare-cloud fab [-l] [fab_command] +``` + +##### Positional Arguments + +###### `fab_command` + +The name of the fab task to run. It and all following arguments +will be passed on without modification to `fab`, so all normal `fab` +syntax rules apply. + +##### Optional Arguments + +###### `-l` + +Use `-l` instead of a command to see the full list of commands. + +##### Available commands +``` + + apply_patch Used to apply a git patch created via `git for... + awesome_deploy Preindex and deploy if it completes quickly en... + check_status + clean_offline_releases Cleans all releases in home directory + clean_releases Cleans old and failed deploys from the ~/www/<... + deploy Preindex and deploy if it completes quickly en... + deploy_airflow + deploy_formplayer + force_update_static + hotfix_deploy deploy ONLY the code with no extra cleanup or ... + kill_stale_celery_workers Kills celery workers that failed to properly g... + manage run a management command + offline_setup_release + perform_system_checks + pillowtop + preindex_views Creates a new release that runs preindex_every... + prepare_offline_deploy + reset_mvp_pillows + restart_services + reverse_patch Used to reverse a git patch created via `git f... + rollback Rolls back the servers to the previous release... + rollback_formplayer + setup_limited_release Sets up a release on a single machine + setup_release Sets up a full release across the cluster + start_celery + start_pillows + stop_celery + stop_pillows + supervisorctl + unlink_current Unlinks the current code directory. Use with c... + update_current + webworkers +``` + + +#### `service` + +Manage services. + +``` +commcare-cloud service [--only PROCESS_PATTERN] + + {celery,commcare,couchdb,couchdb2,elasticsearch,elasticsearch-classic,formplayer,kafka,nginx,pillowtop,postgresql,rabbitmq,redis,riakcs,touchforms,webworker} + [{celery,commcare,couchdb,couchdb2,elasticsearch,elasticsearch-classic,formplayer,kafka,nginx,pillowtop,postgresql,rabbitmq,redis,riakcs,touchforms,webworker} ...] + {start,stop,restart,status,help} +``` + +#### Example + +``` +cchq service postgresql status +cchq service riakcs restart --only riak,riakcs +cchq service celery help +cchq service celery restart --limit +cchq service celery restart --only ,: +cchq service pillowtop restart --limit --only +``` + +Services are grouped together to form conceptual service groups. +Thus the `postgresql` service group applies to both the `postgresql` +service and the `pgbouncer` service. We'll call the actual services +"subservices" here. + +##### Positional Arguments + +###### `{celery,commcare,couchdb,couchdb2,elasticsearch,elasticsearch-classic,formplayer,kafka,nginx,pillowtop,postgresql,rabbitmq,redis,riakcs,touchforms,webworker}` + +The name of the service group(s) to apply the action to. +There is a preset list of service groups that are supported. +More than one service may be supplied as separate arguments in a row. + +###### `{start,stop,restart,status,help}` + +Action can be `status`, `start`, `stop`, or `restart`. +This action is applied to every matching service. + +##### Optional Arguments + +###### `--only PROCESS_PATTERN` + +Sub-service name to limit action to. +Format as 'name' or 'name:number'. +Use 'help' action to list all options. + + +#### `migrate-couchdb` +(Alias `migrate_couchdb`) + +Perform a CouchDB migration + +``` +commcare-cloud migrate-couchdb migration_plan {describe,plan,migrate,commit,clean} +``` + +This is a recent and advanced addition to the capabilities, +and is not yet ready for widespread use. At such a time as it is +ready, it will be more thoroughly documented. + +##### Positional Arguments + +###### `migration_plan` + +Path to migration plan file + +###### `{describe,plan,migrate,commit,clean}` + +Action to perform + +- describe: Print out cluster info +- plan: generate plan details from migration plan +- migrate: stop nodes and copy shard data according to plan +- commit: update database docs with new shard allocation +- clean: remove shard files from hosts where they aren't needed + + +#### `downtime` + +Manage downtime for the selected environment. + +``` +commcare-cloud downtime [-m MESSAGE] {start,end} +``` + +This notifies Datadog of the planned downtime so that is is recorded +in the history, and so that during it service alerts are silenced. + +##### Positional Arguments + +###### `{start,end}` + +##### Optional Arguments + +###### `-m MESSAGE, --message MESSAGE` + +Optional message to set on Datadog. + + +#### `copy-files` + +Copy files from multiple sources to targets. + +``` +commcare-cloud copy-files plan {prepare,copy,cleanup} +``` + +This is a general purpose command that can be used to copy files between +hosts in the cluster. + +Files are copied using `rsync` from the target host. This tool assumes that the +specified user on the source host has permissions to read the files being copied. + +The plan file must be formatted as follows: + +```yml +copy_files: + - : + - source_host: + source_user: + source_dir: + target_dir: + files: + - test/ + - test1/test-file.txt + exclude: + - logs/* + - test/temp.txt +``` +- **copy_files**: Multiple target hosts can be listed. +- **target-host**: Hostname or IP of the target host. Multiple source definitions can be +listed for each target host. +- **source-host**: Hostname or IP of the source host. +- **source-user**: (optional) User to ssh as from target to source. Defaults to 'ansible'. This user must have permissions +to read the files being copied. +- **source-dir**: The base directory from which all source files referenced. +- **target-dir**: Directory on the target host to copy the files to. +- **files**: List of files to copy. File paths are relative to `source-dir`. Directories can be included and must +end with a `/`. +- **exclude**: (optional) List of relative paths to exclude from the *source-dir*. Supports wildcards e.g. "logs/*". + +##### Positional Arguments + +###### `plan` + +Path to plan file + +###### `{prepare,copy,cleanup}` + +Action to perform + +- prepare: generate the scripts and push them to the target servers +- migrate: execute the scripts +- cleanup: remove temporary files and remote auth + + +#### `list-dbs` + +List out databases by host + +``` +commcare-cloud list-dbs +``` From 6fe068ba1372747342f3d97fc2fdd62b696fa323 Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Wed, 1 Aug 2018 13:52:41 -0700 Subject: [PATCH 18/21] Add back the origin secrets.tar.enc file --- .travis/secrets.tar.enc | Bin 0 -> 6672 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .travis/secrets.tar.enc diff --git a/.travis/secrets.tar.enc b/.travis/secrets.tar.enc new file mode 100644 index 0000000000000000000000000000000000000000..b3e53c3a0debef3bea5c477122eece63b33c1a7d GIT binary patch literal 6672 zcmV+r8t>%>=rv84=@dO}6dMe{{|RJye@NMFFD5q~EsbcFykJhe`ACne_xCo{GawYJ7IIDb0qO4FvhIdbxxA-LsjAYanCavCK)%o!(Bgw5j&M1uGSVCxkN zoEJA&VHK*2O=xR{{EF~2eOshJIt2=d8Y)33$KW#crtRB2&Q`Pe9u2{8MI>3i=f}kO z0*O%pk@=^*A=s_N(J2UofzWD}Ir?zbLd!RoZe9TZbx_k<>SQ!?kjee0mLIsW_n`Mc z>DAeNCCN&xr@u+YUA{va``e#rFW&_YLYMI1Cm4>iY!$YrudWsOlrFJjO2EBTiAXghBs4hHv9|FS$}9zINeF$ zS*rKhb%#S0W*2COwkL0qO+I3DO#d6JQSr7Fm63DCXZ8j=&)fz(OEXJNXgVwV=OxGM zqnAd0QZ=4*)An79r%1kWn+$H=1gZfuK*VcIF{#X@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isKX7pqeP>AzJJtG)o8aQbv~H-?hY(4tjaA+_ioj)>IAM_Z4YgYP;Ln?FbR(NIUMr}kO{|+T;5zj z=8H(64&N+ApuVf(yaO1#9T-zc^nK&_u1PK;+_H0>zv&V_-r?5TfUU9ceV!64?~v)6 zbc=u_L_dro|4`(1dQU4MHRjO;&>1-KpB~`^J^nX}_yyyZXN*;6QP7asmdKZ3Ojv%& z-!Kb8##-fWTiu=xy`N*rNZ*tPJN*#1zmhA20VTIzii^yPt@2ekVO^rEDV6EL*l%j( z&nrL;qwm6S2-ucoh3~Q$rFl1&&>z2&tU$(9O537#83lAX>bBl zoVkcw5;2O+SHM;x=doHt=O*aoZT(K;5w1*#JEo|YPqUXeoe?CkPJ${h0IY=e5)q!S aT-^PPd>lPFLnhdkNVkP;fcL7S@@4Vl?%nGE literal 0 HcmV?d00001 From 9a8c2aeaf2db8f0b89756856d6bbe0301120dfba Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Thu, 2 Aug 2018 12:53:18 -0700 Subject: [PATCH 19/21] Start es before pillows, and consolidate pillow code --- src/commcare_cloud/commands/ansible/service.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/commcare_cloud/commands/ansible/service.py b/src/commcare_cloud/commands/ansible/service.py index fbc77b82b8..e9d2006e81 100644 --- a/src/commcare_cloud/commands/ansible/service.py +++ b/src/commcare_cloud/commands/ansible/service.py @@ -300,24 +300,21 @@ def execute_action(self, action, host_pattern=None, process_pattern=None): "\nRestart is a stop followed by a start.\n Continue?", strict=False): return 0 # exit code if action == 'stop' or action == 'restart': - exit_code = self._act_on_pillows(action=action) - if not exit_code == 0: - print("ERROR while stopping pillows. Exiting.") - sys.exit(1) + self._act_on_pillows(action=action) self._run_rolling_restart_yml(tags='action_stop') + if action == 'start' or action == 'restart': - exit_code = self._act_on_pillows(action=action) - if not exit_code == 0: - print("ERROR while starting pillows. Exiting.") - sys.exit(1) self._run_rolling_restart_yml(tags='action_start') + self._act_on_pillows(action=action) def _act_on_pillows(self, action): # Used to stop or start pillows ansible_context = AnsibleContext(None) service = SERVICES_BY_NAME['pillowtop'](self.environment, ansible_context) exit_code = service.run(action=action) - return exit_code + if not exit_code == 0: + print("ERROR while trying to {} pillows. Exiting.".format(action)) + sys.exit(1) def _run_rolling_restart_yml(self, tags): from commcare_cloud.commands.ansible.ansible_playbook import run_ansible_playbook From 26605f14e6ad5bc99f03c340456c5132c8c52403 Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Thu, 2 Aug 2018 14:59:27 -0700 Subject: [PATCH 20/21] Use stop and start strings instead of the action variable, for restart --- src/commcare_cloud/commands/ansible/service.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commcare_cloud/commands/ansible/service.py b/src/commcare_cloud/commands/ansible/service.py index e9d2006e81..4d60a910d1 100644 --- a/src/commcare_cloud/commands/ansible/service.py +++ b/src/commcare_cloud/commands/ansible/service.py @@ -300,12 +300,12 @@ def execute_action(self, action, host_pattern=None, process_pattern=None): "\nRestart is a stop followed by a start.\n Continue?", strict=False): return 0 # exit code if action == 'stop' or action == 'restart': - self._act_on_pillows(action=action) + self._act_on_pillows(action='stop') self._run_rolling_restart_yml(tags='action_stop') if action == 'start' or action == 'restart': self._run_rolling_restart_yml(tags='action_start') - self._act_on_pillows(action=action) + self._act_on_pillows(action='start') def _act_on_pillows(self, action): # Used to stop or start pillows From ba1d4017ebb5a0969000fe59355caaa61247a13b Mon Sep 17 00:00:00 2001 From: Preethi Vaidyanathan Date: Mon, 6 Aug 2018 13:53:51 -0400 Subject: [PATCH 21/21] Specify the Pillow service directly --- src/commcare_cloud/commands/ansible/service.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/commcare_cloud/commands/ansible/service.py b/src/commcare_cloud/commands/ansible/service.py index 4d60a910d1..9545bd4de1 100644 --- a/src/commcare_cloud/commands/ansible/service.py +++ b/src/commcare_cloud/commands/ansible/service.py @@ -309,8 +309,7 @@ def execute_action(self, action, host_pattern=None, process_pattern=None): def _act_on_pillows(self, action): # Used to stop or start pillows - ansible_context = AnsibleContext(None) - service = SERVICES_BY_NAME['pillowtop'](self.environment, ansible_context) + service = Pillowtop(self.environment, AnsibleContext(None)) exit_code = service.run(action=action) if not exit_code == 0: print("ERROR while trying to {} pillows. Exiting.".format(action))