Skip to content

Commit

Permalink
Detect upgraded pip modules and update them in Odoo DB's (#67)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
raneq authored Aug 15, 2019
1 parent 89a2ad2 commit ed3adbd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tasks/community-modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down Expand Up @@ -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

0 comments on commit ed3adbd

Please sign in to comment.