Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] Enterprise and/or project addons to register and deploy from Git. #105

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: [email protected]:customer/enterprise.git
odoo_enterprise_repo_rev: 11.0

# Odoo Addons
odoo_addons_repo_url: [email protected]: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):

Expand Down
26 changes: 26 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
45 changes: 45 additions & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -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
Expand Down Expand Up @@ -94,3 +134,8 @@
tags:
- odoo
- odoo_packages

- name: Install addons dependencies
import_tasks: install_addons_dependencies.yml
tags:
- odoo_packages
25 changes: 25 additions & 0 deletions tasks/install_addons_dependencies.yml
Original file line number Diff line number Diff line change
@@ -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