From 2c2b68c54e74ed4b1d8da3f60b845b9df2a896f9 Mon Sep 17 00:00:00 2001 From: Bob Leers Date: Sun, 23 Jun 2019 18:52:26 +0200 Subject: [PATCH 1/4] [ADD] Enterprise and/or project addons to register and deploy from Git. --- README.md | 28 ++++++++++++++++++++++++++++ defaults/main.yml | 26 ++++++++++++++++++++++++++ tasks/install.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) diff --git a/README.md b/README.md index f4e1db4..2d3ca4a 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,34 @@ the same host): With the standard installation type you configure Odoo with the available `odoo_config_*` options. +Standard installation with mirrored *Enterprise* and (custom, external) *addons* +(assuming that PostgreSQL is installed and running on the same host): + +```yaml +- name: Odoo + hosts: odoo_server + become: yes + roles: + - role: odoo + odoo_version: 11.0 + odoo_config_admin_passwd: SuPerPassWorD + + # Odoo Enterprise + odoo_enterprise_repo_url: git@example.com:customer/enterprise.git + odoo_enterprise_repo_rev: 12.0 + + # Odoo Addons + odoo_addons_repo_url: git@example.com:customer/addons.git + odoo_addons_repo_rev: 12.0 + + odoo_config_addons_path: + - "/home/{{ odoo_user }}/odoo/enterprise" + - "/home/{{ odoo_user }}/odoo/addons/custom" + - "/home/{{ odoo_user }}/odoo/addons/external" + - "/home/{{ odoo_user }}/odoo/server/odoo/addons" + - "/home/{{ odoo_user }}/odoo/server/addons" +``` + Standard installation but with PostgreSQL installed on a remote host (and available from your Ansible inventory): diff --git a/defaults/main.yml b/defaults/main.yml index c270c5c..b3cc7dc 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -29,6 +29,32 @@ odoo_repo_update: True # Update the working copy or not. This option is odoo_repo_depth: 1 # Set to 0 to clone the full history (slower) # (this option is not supported with hg) +# Enterprise repository to deploy +odoo_enterprise_dir: "/home/{{ odoo_user }}/odoo/enterprise/" +odoo_enterprise_repo_type: git # git or hg +odoo_enterprise_repo_url: False +odoo_enterprise_repo_dest: "{{ odoo_install_type == 'buildout' and odoo_workdir or odoo_enterprise_dir }}" +odoo_enterprise_repo_rev: "{{ odoo_version }}" +odoo_enterprise_repo_update: True # Update the working copy or not. This option is + # ignored on the first run (a checkout of the working + # copy is always processed on the given revision) + # WARNING: uncommited changes will be discarded! +odoo_enterprise_repo_depth: 1 # Set to 0 to clone the full history (slower) + # (this option is not supported with hg) + +# Addons repository to deploy +odoo_addons_dir: "/home/{{ odoo_user }}/odoo/addons/" +odoo_addons_repo_type: git # git or hg +odoo_addons_repo_url: False +odoo_addons_repo_dest: "{{ odoo_install_type == 'buildout' and odoo_workdir or odoo_addons_dir }}" +odoo_addons_repo_rev: "{{ odoo_version }}" +odoo_addons_repo_update: True # Update the working copy or not. This option is + # ignored on the first run (a checkout of the working + # copy is always processed on the given revision) + # WARNING: uncommited changes will be discarded! +odoo_addons_repo_depth: 1 # Set to 0 to clone the full history (slower) + # (this option is not supported with hg) + # Third party programs options odoo_reportlab_font_url: http://www.reportlab.com/ftp/pfbfer.zip diff --git a/tasks/install.yml b/tasks/install.yml index 0ac737f..9cfd466 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -36,6 +36,18 @@ tags: - odoo_project +- name: Enterprise repository already cloned? + stat: path={{ odoo_enterprise_repo_dest }} + register: enterprise_path + tags: + - odoo_project + +- name: Addons repository already cloned? + stat: path={{ odoo_addons_repo_dest }} + register: addons_path + tags: + - odoo_project + - name: Clone project repository (Mercurial) become: yes become_user: "{{ odoo_user }}" @@ -62,6 +74,34 @@ tags: - odoo_project +- name: Clone enterprise repository (Git) + become: yes + become_user: "{{ odoo_user }}" + git: repo={{ odoo_enterprise_repo_url }} + dest={{ odoo_enterprise_repo_dest }} + version={{ odoo_enterprise_repo_rev | string }} + update={{ enterprise_path.stat.exists == False and 'yes' + or (odoo_enterprise_repo_update and 'yes' or 'no') }} + depth={{ odoo_enterprise_repo_depth }} + when: odoo_install_type != 'pip' and odoo_repo_type == 'git' and odoo_enterprise_repo_url + notify: Restart Odoo + tags: + - odoo_project + +- name: Clone addons repository (Git) + become: yes + become_user: "{{ odoo_user }}" + git: repo={{ odoo_addons_repo_url }} + dest={{ odoo_addons_repo_dest }} + version={{ odoo_addons_repo_rev | string }} + update={{ addons_path.stat.exists == False and 'yes' + or (odoo_addons_repo_update and 'yes' or 'no') }} + depth={{ odoo_addons_repo_depth }} + when: odoo_install_type != 'pip' and odoo_repo_type == 'git' and odoo_addons_repo_url + notify: Restart Odoo + tags: + - odoo_project + - name: Create odoo data dir directory file: path={{ odoo_config_data_dir }} state=directory owner={{ odoo_user }} group={{ odoo_user }} force=yes From 071c54e57fdeef579805f59c6efa59823a02a5bd Mon Sep 17 00:00:00 2001 From: Bob Leers Date: Sun, 23 Jun 2019 19:00:24 +0200 Subject: [PATCH 2/4] [UPD] Enterprise and/or project addons, Odoo version in README. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2d3ca4a..a5b5859 100644 --- a/README.md +++ b/README.md @@ -66,11 +66,11 @@ Standard installation with mirrored *Enterprise* and (custom, external) *addons* # Odoo Enterprise odoo_enterprise_repo_url: git@example.com:customer/enterprise.git - odoo_enterprise_repo_rev: 12.0 + odoo_enterprise_repo_rev: 11.0 # Odoo Addons odoo_addons_repo_url: git@example.com:customer/addons.git - odoo_addons_repo_rev: 12.0 + odoo_addons_repo_rev: 11.0 odoo_config_addons_path: - "/home/{{ odoo_user }}/odoo/enterprise" From ec6e3c55f62c5dcd02528c51c6cbe67512f2d7a5 Mon Sep 17 00:00:00 2001 From: Bob Leers Date: Mon, 24 Jun 2019 13:52:23 +0200 Subject: [PATCH 3/4] [ADD] Install Python packages required by addons, from Debian/apt and PyPi requirements. --- README.md | 17 +++++++++++++++-- tasks/install.yml | 5 +++++ tasks/install_addons_dependencies.yml | 24 ++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 tasks/install_addons_dependencies.yml diff --git a/README.md b/README.md index a5b5859..5f7c2fb 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,17 @@ the same host): With the standard installation type you configure Odoo with the available `odoo_config_*` options. -Standard installation with mirrored *Enterprise* and (custom, external) *addons* -(assuming that PostgreSQL is installed and running on the same host): +Standard installation with Enterprise and addons (assuming that PostgreSQL is +installed and running on the same host) + +- `odoo_enterprise_repo`: Odoo Enterprise (mirrored) +- `odoo_addons_repo`: Project/customer addons (custom, external) +- `odoo_addons_debian_packages`: Debian/apt packages required by addons. + +Consideration: +It's also possible to put Python packages into the `{{ odoo_addons_dir }}/requirements.txt` file. +So consider whether to install Python packages by +either the PyPi requirements or `odoo_addons_debian_packages` ```yaml - name: Odoo @@ -78,6 +87,10 @@ Standard installation with mirrored *Enterprise* and (custom, external) *addons* - "/home/{{ odoo_user }}/odoo/addons/external" - "/home/{{ odoo_user }}/odoo/server/odoo/addons" - "/home/{{ odoo_user }}/odoo/server/addons" + + odoo_addons_debian_packages: + - python3-openpyxl + - python3-numpy ``` Standard installation but with PostgreSQL installed on a remote host (and diff --git a/tasks/install.yml b/tasks/install.yml index 9cfd466..8ab86c3 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -134,3 +134,8 @@ tags: - odoo - odoo_packages + +- name: Install addons dependencies + import_tasks: install_addons_dependencies.yml + tags: + - odoo_packages diff --git a/tasks/install_addons_dependencies.yml b/tasks/install_addons_dependencies.yml new file mode 100644 index 0000000..4a74cd6 --- /dev/null +++ b/tasks/install_addons_dependencies.yml @@ -0,0 +1,24 @@ +--- + +- name: Addons - Install Debian/apt dependencies + apt: pkg={{ item }} + state=present + update_cache={{ odoo_apt_update_cache }} + cache_valid_time={{ odoo_apt_cache_valid_time }} + with_items: "{{ odoo_addons_debian_packages }}" + tags: + - odoo_packages + +- name: Addons - Check PyPi requirements file exist + stat: + path: "{{ odoo_addons_dir }}/requirements.txt" + register: addons_requirements_file + tags: + - odoo_packages + +- name: Addons - Install PyPi dependencies using requirements file + pip: + requirements: "file://{{ odoo_addons_dir }}/requirements.txt" + when: addons_requirements_file.stat.exists + tags: + - odoo_packages From e201e6b82cfefcf7e1f5debd9e0fa46bcd641187 Mon Sep 17 00:00:00 2001 From: Bob Leers Date: Mon, 24 Jun 2019 16:35:57 +0200 Subject: [PATCH 4/4] [FIX] Check whether odoo_addons_debian_packages is defined. --- tasks/install_addons_dependencies.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/install_addons_dependencies.yml b/tasks/install_addons_dependencies.yml index 4a74cd6..f88f71b 100644 --- a/tasks/install_addons_dependencies.yml +++ b/tasks/install_addons_dependencies.yml @@ -6,6 +6,7 @@ update_cache={{ odoo_apt_update_cache }} cache_valid_time={{ odoo_apt_cache_valid_time }} with_items: "{{ odoo_addons_debian_packages }}" + when: odoo_addons_debian_packages is defined tags: - odoo_packages