From 6614f36774be2f9037f4f4db26f1f7968a588f3d Mon Sep 17 00:00:00 2001 From: Daniel Palomar Date: Thu, 4 Jun 2020 11:54:09 +0200 Subject: [PATCH 1/5] Use Avanon Pyenv community role to install Pyenv Add default Pyenv vars to set the global Python interpreter to 3.8.2 and the Odoo python interpreter to 3.7.7. --- defaults/main.yml | 5 ++++- meta/main.yml | 4 +++- tasks/main.yml | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 1100969..3f75001 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,7 +4,10 @@ odoo_role_odoo_user: odoo odoo_role_odoo_group: odoo # VirtualEnv vars -odoo_role_odoo_venv_path: /opt/.odoo_venv +pyenv_odoo_python_version: "3.7.7" +pyenv_global_python_version: "3.8.2" +pyenv_venv_name: "odoo" +odoo_role_odoo_venv_path: "/home/{{ odoo_role_odoo_user }}/pyenv/versions/{{ pyenv_venv_name }}/" # Odoo releases download strategy: tar or git odoo_role_download_strategy: tar diff --git a/meta/main.yml b/meta/main.yml index 5e64ba4..404f2ae 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -23,4 +23,6 @@ galaxy_info: - erp - python -dependencies: [] +dependencies: + - name: avanov.pyenv + version: 1.1.0 diff --git a/tasks/main.yml b/tasks/main.yml index 84ca729..c44d3d2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -31,7 +31,8 @@ deb: "https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox_0.12.5-1.{{ ansible_distribution_release }}_amd64.deb" when: wkhtmltox_installed.rc == 1 -- import_tasks: virtualenv.yml +- import_tasks: pyenv.yml + become: yes - name: Create Odoo directories become: yes From 9fb1713fa53d7717cbff6751ec46c1c1172294a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Thu, 4 Jun 2020 12:05:47 +0200 Subject: [PATCH 2/5] Disable nodejs link if Ubuntu version > 18.04 --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index c44d3d2..0cf75f5 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -94,7 +94,7 @@ src: /usr/bin/nodejs dest: /usr/bin/node state: link - when: ansible_distribution == "Ubuntu" and not ansible_distribution_version == "18.04" + when: ansible_distribution == "Ubuntu" and not ansible_distribution_version >= "18.04" - name: Install Odoo become: yes From 2be5a55749947510af90577af8b834f670bc10b9 Mon Sep 17 00:00:00 2001 From: Daniel Palomar Date: Thu, 4 Jun 2020 12:28:12 +0200 Subject: [PATCH 3/5] Add pyenv task and remove virtualenv tasks --- tasks/pyenv.yml | 14 ++++++++++++++ tasks/virtualenv.yml | 33 --------------------------------- 2 files changed, 14 insertions(+), 33 deletions(-) create mode 100644 tasks/pyenv.yml delete mode 100644 tasks/virtualenv.yml diff --git a/tasks/pyenv.yml b/tasks/pyenv.yml new file mode 100644 index 0000000..41f0152 --- /dev/null +++ b/tasks/pyenv.yml @@ -0,0 +1,14 @@ +--- +- name: Install Pyenv + import_role: + name: avanov.pyenv + vars: + pyenv_path: "/home/{{ odoo_role_odoo_user }}/pyenv/" + pyenv_owner: "{{ odoo_role_odoo_user }}" + pyenv_global: "{{ pyenv_global_python_version }}" + pyenv_python_versions: + - "{{ pyenv_odoo_python_version }}" + - "{{ pyenv_global_python_version }}" + pyenv_virtualenvs: + - venv_name: "{{ pyenv_venv_name }}" + py_version: "{{ pyenv_odoo_python_version }}" diff --git a/tasks/virtualenv.yml b/tasks/virtualenv.yml deleted file mode 100644 index 2381d5c..0000000 --- a/tasks/virtualenv.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -- name: Install virtualenv package - become: yes - apt: - update_cache: yes - pkg: python3-venv - state: present - -- name: Create virtualenv directory - become: yes - file: - path: "{{ odoo_role_odoo_venv_path }}" - state: directory - mode: 02775 - group: "{{ odoo_role_odoo_group }}" - -- name: Check if virtualenv is already created - stat: - path: "{{ odoo_role_odoo_venv_path }}/bin" - register: env - -- name: Manually create the initial virtualenv - command: "python3 -m venv {{ odoo_role_odoo_venv_path }}" - when: env.stat.isdir is undefined - -- name: Change virtualenv permissions - become: yes - file: - path: "{{ odoo_role_odoo_venv_path }}" - owner: odoo - group: "{{ odoo_role_odoo_group }}" - mode: 02775 - recurse: yes From 9131709b876d9abfca06926e8122834804ed3056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Thu, 4 Jun 2020 15:19:32 +0200 Subject: [PATCH 4/5] limit nodejs deps to odoo<12.0 and ubuntu<18.04 --- tasks/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 0cf75f5..38d41f6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -79,6 +79,7 @@ - nodejs - npm state: present + when: odoo_role_odoo_version < "12.0" - name: Install Less CSS via nodejs become: yes @@ -86,15 +87,16 @@ name: less version: 2.7.2 global: yes + when: odoo_role_odoo_version < "12.0" -# This link is needed in Ubuntu 16.04 and in Ubuntu 18.04 raise and error. +# This link is needed in Ubuntu 16.04 and in Ubuntu 18.04 raise an error. - name: Create node symlink become: yes file: src: /usr/bin/nodejs dest: /usr/bin/node state: link - when: ansible_distribution == "Ubuntu" and not ansible_distribution_version >= "18.04" + when: odoo_role_odoo_version < "12.0" and ansible_distribution == "Ubuntu" and not ansible_distribution_version >= "18.04" - name: Install Odoo become: yes From e5f0130e5ea466c7aa2134e8403f4a0cab330cc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20L=C3=B3pez=20Ram=C3=ADrez?= Date: Thu, 4 Jun 2020 15:34:03 +0200 Subject: [PATCH 5/5] Added new Ubuntu versions supported --- meta/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/meta/main.yml b/meta/main.yml index 404f2ae..d63dac8 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -11,6 +11,8 @@ galaxy_info: - name: Ubuntu versions: - xenial + - bionic + - focal galaxy_tags: - odoo