From ed3adbd27076c4b8f35a94a3a7292c44d480e2cc Mon Sep 17 00:00:00 2001 From: raneq <46573858+raneq@users.noreply.github.com> Date: Thu, 15 Aug 2019 12:02:37 +0200 Subject: [PATCH] Detect upgraded pip modules and update them in Odoo DB's (#67) * Detect upgraded pip modules and update them in Odoo DB's * Update community-modules.yml * Perform pip install with odoo user * Parse properly output from pip. Don't let other than odoo packages pass, and output one package per line to ease logics --- tasks/community-modules.yml | 18 ++++++++++++++++++ tasks/main.yml | 17 +++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/tasks/community-modules.yml b/tasks/community-modules.yml index ff5e0de..2ce0eee 100644 --- a/tasks/community-modules.yml +++ b/tasks/community-modules.yml @@ -10,3 +10,21 @@ pip: requirements: "{{ odoo_role_odoo_modules_path }}/requirements.txt" virtualenv: "{{ odoo_role_odoo_venv_path }}" + register: reg_pip + become: yes + become_user: "{{ odoo_role_odoo_user }}" + +- name: Detect upgraded packages + shell: > + grep 'Successfully installed' | + sed -r 's/ /\n/g' | + egrep '^odoo1[0-9]-addon-[^ ]+-[0-9\.]+' | + sed -r 's/odoo1[0-9]-addon-([^ ]+)-[0-9\.]+/\1/g' | + tr -- '-' '_' + + args: + stdin: "{{ reg_pip.stdout }}" + executable: bash + register: reg_pip_upgraded + changed_when: reg_pip_upgraded.stdout + failed_when: false # noqa 306 "shell and pipefail". Both grep and sed must be able to fail diff --git a/tasks/main.yml b/tasks/main.yml index 06a042d..30a44e2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -65,6 +65,8 @@ - import_tasks: download.yml - name: Install Odoo python requirements + become: yes + become_user: "{{ odoo_role_odoo_user }}" pip: requirements: "{{ odoo_role_odoo_path }}/requirements.txt" virtualenv: "{{ odoo_role_odoo_venv_path }}" @@ -181,4 +183,19 @@ index_var: index notify: restart odoo +- name: Update in Odoo pip upgraded community modules + become: yes + become_user: "{{ odoo_role_odoo_user }}" + command: > + {{ odoo_role_odoo_python_path }} {{ odoo_role_odoo_bin_path }} + -c {{ odoo_role_odoo_config_path }}/odoo.conf + -d {{ item }} + --update {{ reg_pip_upgraded.stdout_lines | join(',') }} + --stop-after-init + --logfile=/dev/stdout + --log-level=warn + when: reg_pip_upgraded.stdout + with_items: "{{ odoo_role_odoo_dbs }}" + notify: restart odoo + - import_tasks: add-service.yml