Skip to content

Commit

Permalink
add support for pip install of odoo and addons
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiBForgeFlow committed Jan 21, 2018
1 parent 15d810c commit 6d681a3
Show file tree
Hide file tree
Showing 37 changed files with 1,418 additions and 6 deletions.
56 changes: 56 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
bin/
build/
develop-eggs/
dist/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo

# Pycharm
.idea

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Rope
.ropeproject

# Sphinx documentation
docs/_build/

# Backup files
*~
*.swp
11 changes: 11 additions & 0 deletions .idea/ansible-odoo.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

762 changes: 762 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,62 @@ env:
# Odoo 8.0
- IMAGE="images:debian/jessie" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="images:debian/jessie" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="images:debian/jessie" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5"
# Odoo 9.0
- IMAGE="images:debian/jessie" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="images:debian/jessie" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="images:debian/jessie" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5"
# Odoo 10.0
- IMAGE="images:debian/jessie" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="images:debian/jessie" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="images:debian/jessie" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5"
# Debian 9 (stretch)
# Odoo 8.0
- IMAGE="images:debian/stretch" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="images:debian/stretch" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="images:debian/stretch" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5"
# Odoo 9.0
- IMAGE="images:debian/stretch" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="images:debian/stretch" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="images:debian/stretch" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5"
# Odoo 10.0
- IMAGE="images:debian/stretch" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="images:debian/stretch" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="images:debian/stretch" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5"
# Odoo 11.0
- IMAGE="images:debian/stretch" ODOO_VERSION=11.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="images:debian/stretch" ODOO_VERSION=11.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="images:debian/stretch" ODOO_VERSION=11.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5"
# Ubuntu 14.04 (trusty)
# Odoo 8.0
- IMAGE="ubuntu:trusty" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="ubuntu:trusty" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="ubuntu:trusty" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5"
# Odoo 9.0
- IMAGE="ubuntu:trusty" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="ubuntu:trusty" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="ubuntu:trusty" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5"
# Odoo 10.0
- IMAGE="ubuntu:trusty" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="ubuntu:trusty" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="ubuntu:trusty" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5"
# Ubuntu 16.04 (xenial)
# Odoo 8.0
- IMAGE="ubuntu:xenial" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="ubuntu:xenial" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="ubuntu:xenial" ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5"
# Odoo 9.0
- IMAGE="ubuntu:xenial" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="ubuntu:xenial" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="ubuntu:xenial" ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5"
# Odoo 10.0
- IMAGE="ubuntu:xenial" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="ubuntu:xenial" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="ubuntu:xenial" ODOO_VERSION=10.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5"
# Odoo 11.0
- IMAGE="ubuntu:xenial" ODOO_VERSION=11.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="ubuntu:xenial" ODOO_VERSION=11.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.4,<2.5"
- IMAGE="ubuntu:xenial" ODOO_VERSION=11.0 ODOO_INSTALL_TYPE=pip ANSIBLE_VERSION="2.4,<2.5"

install:
# Spawn a LXD container
Expand Down
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# Odoo [![Build Status](https://travis-ci.org/osiell/ansible-odoo.png)](https://travis-ci.org/osiell/ansible-odoo)

Ansible role to install Odoo from a Git or Mercurial repository,
Ansible role to install Odoo from a Git or Mercurial repository, or from pip,
and configure it.

This role supports two types of installation:
This role supports three types of installation:

* **standard**: install the Odoo dependencies from APT repositories and the
Odoo project from a Git/Hg repository. Odoo is configured with Ansible options
(`odoo_config_*` ones).

* **pip**: install the Odoo dependencies from APT repositories and the
Odoo project and modules from a pip requirements.txt file. Odoo is configured
with Ansible options
(`odoo_config_*` ones).

* **buildout**: build the Odoo project from a Git/Hg repository containing a
Buildout configuration file based on the
[anybox.recipe.odoo](https://pypi.python.org/pypi/anybox.recipe.odoo/) recipe.
Expand Down Expand Up @@ -101,6 +106,25 @@ Here we set some options required by the ``connector`` framework:
odoo_config_workers: 8
```

### odoo_install_type: pip

Pip installation (assuming that PostgreSQL is installed and running on
the same host):

```yaml
- name: Odoo
hosts: odoo_server
become: yes
roles:
- role: odoo
odoo_install_type: pip
odoo_version: 11.0
odoo_repo_type: pip
odoo_pip_requirements_url: https://raw.githubusercontent.com/OCA/sample-oca-pip-requirements/11.0/requirements.txt
odoo_config_admin_passwd: SuPerPassWorD
```


### odoo_install_type: buildout

With a Buildout installation type, Odoo is installed and configured directly
Expand Down
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ odoo_config_custom: {}
#your_option1: value1
#your_option2: value2

# Pip installation options (odoo_install_type == 'pip')
odoo_pip_venv_path: "{{ odoo_workdir }}/sandbox"
odoo_pip_requirements_url: "file:///home/{{ odoo_user }}/requirements.txt"
odoo_pip_odoo_bin_path: "{{ odoo_workdir }}/sandbox/src/odoo/odoo-bin"

# Buildout installation options (odoo_install_type == 'buildout')
odoo_buildout_version: 2.9.5
odoo_buildout_venv_path: "{{ odoo_workdir }}/sandbox"
Expand Down
6 changes: 6 additions & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
tags:
- odoo_install_type_buildout

- name: Pip installation
import_tasks: install_pip.yml
when: odoo_install_type == 'pip'
tags:
- odoo_install_type_pip

- name: Install NPM packages
import_tasks: install_npm.yml
when: (odoo_version | int) >= 9
Expand Down
58 changes: 58 additions & 0 deletions tasks/install_pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---

- name: Install Odoo dependencies
apt: pkg={{ item }}
state=installed
update_cache={{ odoo_apt_update_cache }}
cache_valid_time={{ odoo_apt_cache_valid_time }}
with_items: "{{ odoo_debian_packages }}"
tags:
- odoo_packages

- name: Generate sample requirements.txt file
template: src=odoo-{{ odoo_version }}-pip-requirements.txt dest="/home/{{ odoo_user }}/requirements.txt"
owner={{ odoo_user }} group={{ odoo_user }} mode=0600

- name: Install build dependencies
apt: pkg={{ item }}
state=installed
update_cache={{ odoo_apt_update_cache }}
cache_valid_time={{ odoo_apt_cache_valid_time }}
with_items: "{{ odoo_pip_build_dependencies }}"

- name: Prepare the Python virtual environment
become: yes
become_user: "{{ odoo_user }}"
shell: "{{ odoo_pip_venv_cmd }}"
args:
creates: "{{ odoo_pip_venv_path }}"

- name: Download the pip requirements file
get_url: url="{{ odoo_pip_requirements_url }}"
force=yes
dest="/home/{{ odoo_user }}/requirements.txt"


- name: Install Odoo dependencies (PyPi)
pip:
name: "{{ item }}"
extra_args: --upgrade
virtualenv: "{{ odoo_pip_venv_path }}"
with_items: "{{ odoo_pypi_packages }}"

- name: Install Odoo from pip external requirements file
pip:
requirements: /home/{{ odoo_user }}/requirements.txt
extra_args: --upgrade
virtualenv: "{{ odoo_pip_venv_path }}"

- import_tasks: config.yml
tags:
- odoo_config

- name: Generate Odoo init script
template: src=odoo-pip.init dest=/etc/init.d/{{ odoo_service }}
owner=root group=root mode=0755
force={{ odoo_force_config and 'yes' or 'no' }}
backup=yes
notify: Restart Odoo
2 changes: 2 additions & 0 deletions templates/odoo-10.0-pip-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-e git+https://github.com/odoo/[email protected]#egg=odoo
-e git+https://github.com/OCA/[email protected]#egg=odoo10_addon_date_range&subdirectory=setup/date_range
2 changes: 1 addition & 1 deletion templates/odoo-10.0.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[options]
addons_path = {{ odoo_config_addons_path.__class__.__name__ == 'list' and odoo_config_addons_path | join(',') or odoo_config_addons_path }}
addons_path = {{ odoo_config_addons_path.__class__.__name__ == 'list' and odoo_config_addons_path | join(',') or odoo_install_type == 'standard' and odoo_config_addons_path or ''}}
admin_passwd = {{ odoo_config_admin_passwd }}
csv_internal_sep = {{ odoo_config_csv_internal_sep }}
data_dir = {{ odoo_config_data_dir }}
Expand Down
2 changes: 2 additions & 0 deletions templates/odoo-11.0-pip-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-e git+https://github.com/odoo/[email protected]#egg=odoo
-e git+https://github.com/OCA/[email protected]#egg=odoo11_addon_date_range&subdirectory=setup/date_range
2 changes: 1 addition & 1 deletion templates/odoo-11.0.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[options]
addons_path = {{ odoo_config_addons_path.__class__.__name__ == 'list' and odoo_config_addons_path | join(',') or odoo_config_addons_path }}
addons_path = {{ odoo_config_addons_path.__class__.__name__ == 'list' and odoo_config_addons_path | join(',') or odoo_install_type == 'standard' and odoo_config_addons_path or ''}}
admin_passwd = {{ odoo_config_admin_passwd }}
csv_internal_sep = {{ odoo_config_csv_internal_sep }}
data_dir = {{ odoo_config_data_dir }}
Expand Down
1 change: 1 addition & 0 deletions templates/odoo-8.0-pip-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e git+https://github.com/odoo/[email protected]#egg=odoo
2 changes: 1 addition & 1 deletion templates/odoo-8.0.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[options]
addons_path = {{ odoo_config_addons_path.__class__.__name__ == 'list' and odoo_config_addons_path | join(',') or odoo_config_addons_path }}
addons_path = {{ odoo_config_addons_path.__class__.__name__ == 'list' and odoo_config_addons_path | join(',') or odoo_install_type == 'standard' and odoo_config_addons_path or ''}}
admin_passwd = {{ odoo_config_admin_passwd }}
auto_reload = {{ odoo_config_auto_reload }}
csv_internal_sep = {{ odoo_config_csv_internal_sep }}
Expand Down
1 change: 1 addition & 0 deletions templates/odoo-9.0-pip-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e git+https://github.com/odoo/[email protected]#egg=odoo
2 changes: 1 addition & 1 deletion templates/odoo-9.0.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[options]
addons_path = {{ odoo_config_addons_path.__class__.__name__ == 'list' and odoo_config_addons_path | join(',') or odoo_config_addons_path }}
addons_path = {{ odoo_config_addons_path.__class__.__name__ == 'list' and odoo_config_addons_path | join(',') or odoo_install_type == 'standard' and odoo_config_addons_path or ''}}
admin_passwd = {{ odoo_config_admin_passwd }}
csv_internal_sep = {{ odoo_config_csv_internal_sep }}
data_dir = {{ odoo_config_data_dir }}
Expand Down
Loading

0 comments on commit 6d681a3

Please sign in to comment.