diff --git a/README.md b/README.md index f4e1db4..5f7c2fb 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,47 @@ the same host): With the standard installation type you configure Odoo with the available `odoo_config_*` options. +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 + 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: 11.0 + + # Odoo Addons + odoo_addons_repo_url: git@example.com:customer/addons.git + odoo_addons_repo_rev: 11.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" + + odoo_addons_debian_packages: + - python3-openpyxl + - python3-numpy +``` + 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..8ab86c3 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 @@ -94,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..f88f71b --- /dev/null +++ b/tasks/install_addons_dependencies.yml @@ -0,0 +1,25 @@ +--- + +- 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 }}" + when: odoo_addons_debian_packages is defined + 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