From 9fecb4154e41062a6a817a0a55df38a3a0eee824 Mon Sep 17 00:00:00 2001
From: Nicolas ROCHE <nroche@entrouvert.com>
Date: Fri, 28 Feb 2020 11:11:58 +0100
Subject: [PATCH] run hobo in python3 (#40259)

---
 delete-tenants.yml                                  | 2 +-
 roles/hobo-agent/tasks/main.yml                     | 2 +-
 roles/hobo-agent/templates/hobo-agent-settings.j2   | 2 +-
 roles/hobo-agent/templates/hobo-agent-supervisor.j2 | 2 +-
 roles/hobo-agent/templates/hobo-agent.j2            | 2 +-
 roles/hobo/vars/main.yml                            | 4 ++--
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/delete-tenants.yml b/delete-tenants.yml
index cc1a92b..8f00071 100644
--- a/delete-tenants.yml
+++ b/delete-tenants.yml
@@ -4,17 +4,17 @@
   vars:
     venv_bin: "{{venv}}/bin"
     venv_py3_bin: "{{venv_py3}}/bin"
   roles:
     - facts
 
   tasks:
     - name: "delete hobo tenant"
-      command: "{{venv_bin}}/{{apps['hobo']['project_name']}}-manage delete_tenant {{tenants_conf['dev-hobo']}}"
+      command: "{{venv_py3_bin}}/{{apps['hobo']['project_name']}}-manage delete_tenant {{tenants_conf['dev-hobo']}}"
       ignore_errors: yes
 
     - name: "delete combo user tenant"
       command: "{{venv_py3_bin}}/{{apps['combo']['project_name']}}-manage delete_tenant {{tenants_conf['user-combo']}}"
       ignore_errors: yes
 
     - name: "delete combo agent tenant"
       command: "{{venv_py3_bin}}/{{apps['combo']['project_name']}}-manage delete_tenant {{tenants_conf['agent-combo']}}"
diff --git a/roles/hobo-agent/tasks/main.yml b/roles/hobo-agent/tasks/main.yml
index 267fd60..6de9bd8 100644
--- a/roles/hobo-agent/tasks/main.yml
+++ b/roles/hobo-agent/tasks/main.yml
@@ -23,16 +23,16 @@
 - name: hobo agent settings file
   template:
     src: hobo-agent-settings.j2
     dest: "{{agent_settings}}"
 
 - name: agent script
   template:
     src: hobo-agent.j2
-    dest: "{{venv_bin}}/{{agent_dash_name}}"
+    dest: "{{venv_py3_bin}}/{{agent_dash_name}}"
     mode: "u=rwx,g=rx,o=rx"
 
 - name: hobo agent supervisor configuration
   template:
     src: hobo-agent-supervisor.j2
     dest: "/etc/supervisor/conf.d/{{agent_dash_name}}.conf"
   become: yes
diff --git a/roles/hobo-agent/templates/hobo-agent-settings.j2 b/roles/hobo-agent/templates/hobo-agent-settings.j2
index dcca91e..da7fa6d 100644
--- a/roles/hobo-agent/templates/hobo-agent-settings.j2
+++ b/roles/hobo-agent/templates/hobo-agent-settings.j2
@@ -8,17 +8,17 @@ AGENT_HOST_PATTERNS = {
 {% endfor %}
 }
 
 {% for appkey, app in apps.items() %}
   {% if appkey == 'wcs' %}
 WCS_MANAGE_COMMAND = "{{venv_py3_bin}}/wcsctl.py -f {{publik_settings}}/wcs/wcs.cfg"
 WCS_MANAGE_TRY_COMMAND = "{{venv_py3_bin}}/wcsctl.py"
   {% else %}
-    {% if appkey in ('combo', 'chrono', 'fargo', 'passerelle') %}
+    {% if appkey in ('combo', 'chrono', 'fargo', 'hobo', 'passerelle') %}
     {# applications en python3 #}
 {% filter upper %}{{appkey}}{% endfilter %}_MANAGE_COMMAND = "{{venv_py3_bin}}/{{app['project_name']}}-manage"
     {% else %}
     {# cas général, applications Django toutjours en python2, devra disparaître #}
 {% filter upper %}{{appkey}}{% endfilter %}_MANAGE_COMMAND = "{{venv_bin}}/{{app['project_name']}}-manage"
     {% endif %}
 {% filter upper %}{{appkey}}{% endfilter %}_MANAGE_TRY_COMMAND = {% filter upper %}{{appkey}}{% endfilter %}_MANAGE_COMMAND
    {% endif %}
diff --git a/roles/hobo-agent/templates/hobo-agent-supervisor.j2 b/roles/hobo-agent/templates/hobo-agent-supervisor.j2
index 4a0df36..106a350 100644
--- a/roles/hobo-agent/templates/hobo-agent-supervisor.j2
+++ b/roles/hobo-agent/templates/hobo-agent-supervisor.j2
@@ -1,11 +1,11 @@
 [program:{{agent_dash_name}}]
 ; Concurrency set to 1 because there is no lock around calls to hobo_notify
-command={{venv_bin}}/celery worker --hostname={{agent_dot_name}}.%%h --app=hobo.agent.worker --loglevel=INFO --concurrency=1
+command={{venv_py3_bin}}/celery worker --hostname={{agent_dot_name}}.%%h --app=hobo.agent.worker --loglevel=INFO --concurrency=1
 environment=HOBO_AGENT_SETTINGS_FILE="{{agent_settings}}",THEMES_DIRECTORY="{{themes_dir}}"
 process_name={{agent_dash_name}}
 user={{user}}
 numprocs=1
 stdout_logfile=/var/log/{{agent_dash_name}}/stdout.log
 stderr_logfile=/var/log/{{agent_dash_name}}/stderr.log
 
 autostart=true
diff --git a/roles/hobo-agent/templates/hobo-agent.j2 b/roles/hobo-agent/templates/hobo-agent.j2
index 5f52910..c09a71d 100644
--- a/roles/hobo-agent/templates/hobo-agent.j2
+++ b/roles/hobo-agent/templates/hobo-agent.j2
@@ -1,2 +1,2 @@
 #!/bin/bash
-HOBO_AGENT_SETTINGS_FILE="{{agent_settings}}" THEMES_DIRECTORY="{{themes_dir}}" {{venv_bin}}/celery worker --hostname={{agent_dot_name}}.%%h --app=hobo.agent.worker --loglevel=INFO --concurrency=1
+HOBO_AGENT_SETTINGS_FILE="{{agent_settings}}" THEMES_DIRECTORY="{{themes_dir}}" {{venv_py3_bin}}/celery worker --hostname={{agent_dot_name}}.%%h --app=hobo.agent.worker --loglevel=INFO --concurrency=1
diff --git a/roles/hobo/vars/main.yml b/roles/hobo/vars/main.yml
index 98ec1ac..2f36105 100644
--- a/roles/hobo/vars/main.yml
+++ b/roles/hobo/vars/main.yml
@@ -1,11 +1,11 @@
 app_name: hobo
 compile_scss: false
 compile_translations: true
 db_name: "{{apps['hobo']['db_name']}}"
-manage_cmd: "{{venv_python}} {{src_dir}}/hobo/manage.py"
+manage_cmd: "{{venv_py3_python}} {{src_dir}}/hobo/manage.py"
 nginx_host_pattern: "{{apps['hobo']['nginx_host_pattern']}}"
 nginx_template_name: "std-nginx-server.j2"
 project_name: "{{apps['hobo']['project_name']}}"
 server_port: "{{apps['hobo']['server_port']}}"
 settings_env_var: HOBO_SETTINGS_FILE
-virtualenv: "{{venv}}"
+virtualenv: "{{venv_py3}}"
-- 
2.25.1

