Skip to content

Commit 6761357

Browse files
committed
Create python packages requirements.txt file from template
1 parent 4e6c7a6 commit 6761357

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

tasks/community-modules.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
---
2-
- name: Copy requirements.txt
3-
copy:
4-
src: "{{ odoo_role_community_modules_requirements_path }}"
2+
- name: Create requirements.txt from template
3+
ansible.builtin.template:
4+
src: "{{ lookup('ansible.builtin.first_found', template_sources) }}"
55
dest: "{{ odoo_role_odoo_modules_path }}/requirements.txt"
66
owner: "{{ odoo_role_odoo_user }}"
77
group: "{{ odoo_role_odoo_group }}"
88
mode: 0644
9+
vars:
10+
template_sources:
11+
- "{{ inventory_dir }}/../files/requirements.txt"
12+
- templates/requirements.txt.j2
913
tags: ['community-modules', 'only-modules']
1014

1115
- name: Deploy community roles with pip

tasks/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@
123123
become: true
124124
become_user: "{{ odoo_role_odoo_user }}"
125125
ansible.builtin.shell: >
126-
{{ odoo_role_odoo_python_path }} -m pip list | grep odoo
126+
{{ odoo_role_odoo_python_path }} -m pip show odoo
127127
register: odoo_package_is_installed
128128
failed_when: odoo_package_is_installed.rc not in [0,1]
129129

130130
- name: Install Odoo
131131
become: true
132132
become_user: "{{ odoo_role_odoo_user }}"
133133
shell: "cd {{ odoo_role_odoo_path }} && {{ odoo_role_odoo_python_path }} setup.py install"
134-
when: odoo_role_desired_tar_download.changed or odoo_role_desired_git_download.changed or odoo_package_is_installed.stdout == ''
134+
when: odoo_role_desired_tar_download.changed or odoo_role_desired_git_download.changed or odoo_package_is_installed.rc == 1
135135

136136
- name: Populate community db modules
137137
set_fact:

templates/requirements.txt.j2

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# {{ ansible_managed }}
2+
3+
{% for package in odoo_role_odoo_community_packages|default([]) %}
4+
{{ package }}
5+
{% endfor %}
6+
7+
{% for package in odoo_role_odoo_project_packages|default([]) %}
8+
{{ package }}
9+
{% endfor %}

0 commit comments

Comments
 (0)