|
8 | 8 | mode: 0644 |
9 | 9 | tags: ['community-modules', 'only-modules'] |
10 | 10 |
|
11 | | -- name: Deploy community roles with pip |
| 11 | +- name: Read requirements.txt and filter packages without pinned versions |
| 12 | + shell: | |
| 13 | + grep -vE '==[0-9]' {{ odoo_role_odoo_modules_path }}/requirements.txt | grep -v '^#' | grep -v '^\s*$' || true |
| 14 | + register: upgradable_packages |
| 15 | + tags: ['community-modules', 'only-modules'] |
| 16 | + |
| 17 | +- name: Upgrade non-pinned packages to latest version using virtualenv |
12 | 18 | pip: |
13 | | - requirements: "{{ odoo_role_odoo_modules_path }}/requirements.txt" |
| 19 | + name: "{{ item }}" |
| 20 | + state: latest |
14 | 21 | virtualenv: "{{ odoo_role_odoo_venv_path }}" |
| 22 | + become: true |
| 23 | + become_user: "{{ odoo_role_odoo_user }}" |
| 24 | + loop: "{{ upgradable_packages.stdout_lines }}" |
| 25 | + when: upgradable_packages.stdout_lines is defined and upgradable_packages.stdout_lines | length > 0 |
| 26 | + tags: ['community-modules', 'only-modules'] |
| 27 | + |
| 28 | +- name: Install pinned packages (without upgrade, using virtualenv) |
| 29 | + shell: | |
| 30 | + source "{{ odoo_role_odoo_venv_path }}bin/activate" && grep -E '==[0-9]' {{ odoo_role_odoo_modules_path }}/requirements.txt | grep -v '^#' | grep -v '^\s*$' | xargs -r pip install |
15 | 31 | register: reg_pip |
16 | 32 | become: true |
17 | 33 | become_user: "{{ odoo_role_odoo_user }}" |
| 34 | + args: |
| 35 | + executable: /bin/bash |
18 | 36 | tags: ['community-modules', 'only-modules'] |
19 | | - # Using the output of pip, detect which packages have been installed, |
20 | | - # both fresh or upgraded. Save the list with a register so that we can |
21 | | - # feed better odoo with it. |
22 | 37 |
|
23 | 38 | - name: Detect upgraded packages |
24 | 39 | args: |
|
43 | 58 | # - option `-n` combined with flag `/p` prints "nothing" except the result of the script. Therefore, unmatching lines are hidden, and matching lines are shown after processed. |
44 | 59 | # - capturing groups `(something)` can be referenced inside the matching part or at the replacing part with \1, \2, in order of appearence. |
45 | 60 | shell: > |
| 61 | + echo "{{ reg_pip.stdout | default('') }}" | \ |
46 | 62 | grep 'Successfully installed' | |
47 | 63 | sed -r 's/ /\n/g' | |
48 | | - sed -rn 's/^odoo(1[0-9])-addon-(.+)-\1\..+$/\2/p' | |
| 64 | + sed -rn 's/^odoo1?[0-9]?-addon-(.+)-[0-9].*$/\1/p' | |
49 | 65 | tr '-' '_' |
50 | 66 | register: reg_pip_upgraded |
51 | 67 | changed_when: reg_pip_upgraded.stdout |
52 | 68 | failed_when: false # noqa 306 "shell and pipefail". Both grep and sed must be able to fail |
53 | 69 | tags: ['community-modules', 'only-modules'] |
| 70 | + args: |
| 71 | + executable: /bin/bash |
0 commit comments