Permalink
Browse files

[IMP] Add the 'buildout' install type (anybox.recipe.odoo integration)

  • Loading branch information...
sebalix committed Jun 17, 2016
1 parent c46c660 commit 81703537f8f7ba12df1307b9feefcee97a31c3f4
View
@@ -6,13 +6,19 @@ python: "2.7"
env:
# Odoo 8.0
- ODOO_VERSION=8.0 ANSIBLE_VERSION="1.9,<2.0"
- ODOO_VERSION=8.0 ANSIBLE_VERSION="2.0,<2.1"
- ODOO_VERSION=8.0 ANSIBLE_VERSION="2.1,<2.2"
- ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="1.9,<2.0"
- ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="1.9,<2.0"
- ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.0,<2.1"
- ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.0,<2.1"
- ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.1,<2.2"
- ODOO_VERSION=8.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.1,<2.2"
# Odoo 9.0
- ODOO_VERSION=9.0 ANSIBLE_VERSION="1.9,<2.0"
- ODOO_VERSION=9.0 ANSIBLE_VERSION="2.0,<2.1"
- ODOO_VERSION=9.0 ANSIBLE_VERSION="2.1,<2.2"
- ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="1.9,<2.0"
- ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="1.9,<2.0"
- ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.0,<2.1"
- ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.0,<2.1"
- ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=standard ANSIBLE_VERSION="2.1,<2.2"
- ODOO_VERSION=9.0 ODOO_INSTALL_TYPE=buildout ANSIBLE_VERSION="2.1,<2.2"
before_install:
- sudo apt-get update -qq
@@ -23,23 +29,4 @@ install:
- "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg"
script:
# Check the role/playbook's syntax.
- "ansible-playbook -i tests/inventory tests/test.yml --syntax-check"
# Run the role/playbook with ansible-playbook.
- "ansible-playbook -i tests/inventory tests/test.yml --connection=local --sudo -e \"odoo_version=$ODOO_VERSION\""
- sudo service odoo status
# Run the role/playbook again, checking to make sure it's idempotent.
- >
ansible-playbook -i tests/inventory tests/test.yml --connection=local --sudo -e "odoo_version=$ODOO_VERSION"
| grep -q 'changed=0.*failed=0'
&& (echo 'IDEMPOTENCE TEST: OK' && exit 0)
|| (echo 'IDEMPOTENCE TEST: FAILED' && exit 1)
- sudo service odoo status
# Run the role/playbook again but change the configuration, and check if the service restart
- >
ansible-playbook -i tests/inventory tests/test.yml --connection=local --sudo -e "odoo_version=$ODOO_VERSION odoo_config_workers=4"
| grep -q 'changed=2.*failed=0'
&& (echo 'RESTART TEST: OK' && exit 0)
|| (echo 'RESTART TEST: FAILED' && exit 1)
- sudo service odoo status
- sleep 3 && wget http://localhost:8069
- ./tests/run.sh
View
209 README.md
@@ -3,40 +3,67 @@
Ansible role to install Odoo from a Git or Mercurial repository,
and configure it.
This role supports two 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).
* **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.
Odoo and its dependencies are then installed and executed inside a Python
virtual environment. The configuration part is also managed by Buildout
(`odoo_config_*` options are not used excepting the `odoo_config_db_*` ones
for PostgreSQL related tasks).
Minimum Ansible Version: 2.0
## Supported versions and systems
### Standard (odoo_install_type: standard)
| System / Odoo | 8.0 | 9.0 |
|---------------|-----|-----|
| Debian 7 | yes | - |
| Debian 8 | yes | yes |
| Ubuntu 12.04 | yes | - |
| Ubuntu 14.04 | yes | yes |
| Ubuntu 16.04 | yes | yes |
### Buildout (odoo_install_type: buildout)
You only need a Debian-based system, all the stuff is then handled by Buildout
to run Odoo >= 8.0.
## Example (Playbook)
### odoo_install_type: standard (default)
Standard installation (assuming that PostgreSQL is installed and running on
the same host):
```yaml
- name: Odoo
hosts: odoo_server
sudo: yes
become: yes
roles:
- odoo
vars:
- odoo_version: 8.0
- odoo_config_admin_passwd: SuPerPassWorD
```
With the standard installation type you configure Odoo with the available
`odoo_config_*` options.
Standard installation but with PostgreSQL installed on a remote host (and
available from your Ansible inventory):
```yaml
- name: Odoo
hosts: odoo_server
sudo: yes
become: yes
roles:
- odoo
vars:
@@ -47,8 +74,8 @@ available from your Ansible inventory):
- odoo_config_db_passwd: PaSsWoRd
```
Installation from a personnal Git repository such as your repository looks
like this:
Standard installation from a personnal Git repository such as your repository
looks like this:
```sh
REPO/
@@ -63,7 +90,7 @@ Here we set some options required by the ``connector`` framework:
```yaml
- name: Odoo
hosts: odoo_server
sudo: yes
become: yes
roles:
- odoo
vars:
@@ -85,102 +112,82 @@ Here we set some options required by the ``connector`` framework:
odoo_config_workers: 8
```
## Variables
### odoo_install_type: buildout
With a Buildout installation type, Odoo is installed and configured directly
by Buildout:
```yaml
odoo_service: odoo
odoo_version: 8.0
odoo_user: odoo
odoo_user_passwd: odoo
odoo_user_system: False
odoo_logdir: "/var/log/{{ odoo_user }}"
odoo_workdir: "/home/{{ odoo_user }}/odoo"
odoo_rootdir: "/home/{{ odoo_user }}/odoo/server"
odoo_init: True
odoo_init_env: {}
#VAR1: value1
#VAR2: value2
odoo_config_file: "/home/{{ odoo_user }}/{{ odoo_service }}.conf"
odoo_force_config: True
odoo_repo_type: git # git or hg
odoo_repo_url: https://github.com/odoo/odoo.git
odoo_repo_dest: "{{ odoo_rootdir }}"
odoo_repo_rev: "{{ odoo_version }}"
odoo_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_repo_depth: 1 # Set to 0 to clone the full history
# (option not supported with hg repository)
odoo_wkhtmltox_version: 0.12.1 # Download URLs available in the
# 'odoo_wkhtmltox_urls' variable
# (see 'vars/main.yml')
odoo_reportlab_font_url: http://www.reportlab.com/ftp/pfbfer.zip
# Tasks related to PostgreSQL
odoo_postgresql_set_user: True
odoo_postgresql_active_unaccent: True
# Odoo parameters
odoo_config_addons_path:
- "/home/{{ odoo_user }}/odoo/server/openerp/addons"
- "/home/{{ odoo_user }}/odoo/server/addons"
odoo_config_admin_passwd: admin
odoo_config_auto_reload: False
odoo_config_csv_internal_sep: ','
odoo_config_data_dir: "/home/{{ odoo_user }}/.local/share/Odoo"
odoo_config_db_host: False
odoo_config_db_host_user: "{{ ansible_ssh_user }}"
odoo_config_db_maxconn: 64
odoo_config_db_name: False
odoo_config_db_passwd: False
odoo_config_db_port: False
odoo_config_db_template: template1
odoo_config_db_user: odoo
odoo_config_dbfilter: '.*'
odoo_config_debug_mode: False
odoo_config_pidfile: None
odoo_config_proxy_mode: False
odoo_config_email_from: False
odoo_config_geoip_database: /usr/share/GeoIP/GeoLiteCity.dat
odoo_config_limit_memory_hard: 805306368
odoo_config_limit_memory_soft: 671088640
odoo_config_limit_time_cpu: 60
odoo_config_limit_time_real: 120
odoo_config_list_db: True
odoo_config_log_db: False
odoo_config_log_level: info
odoo_config_logfile: None
odoo_config_logrotate: False
odoo_config_longpolling_port: 8072
odoo_config_osv_memory_age_limit: 1.0
odoo_config_osv_memory_count_limit: False
odoo_config_max_cron_threads: 2
odoo_config_secure_cert_file: server.cert
odoo_config_secure_pkey_file: server.pkey
odoo_config_server_wide_modules: None
odoo_config_smtp_password: False
odoo_config_smtp_port: 25
odoo_config_smtp_server: localhost
odoo_config_smtp_ssl: False
odoo_config_smtp_user: False
odoo_config_syslog: False
odoo_config_timezone: False
odoo_config_translate_modules: ['all']
odoo_config_unaccent: False
odoo_config_without_demo: False
odoo_config_workers: 0
odoo_config_xmlrpc: True
odoo_config_xmlrpc_interface: ''
odoo_config_xmlrpc_port: 8069
odoo_config_xmlrpcs: True
odoo_config_xmlrpcs_interface: ''
odoo_config_xmlrpcs_port: 8071
# Custom configuration options
odoo_config_custom: {}
#your_option1: value1
#your_option2: value2
# Extra options
odoo_user_sshkeys: False # ../../path/to/public_keys/*
- name: Odoo
hosts: odoo_server
become: yes
roles:
- odoo
vars:
- odoo_install_type: buildout
- odoo_version: 8.0
- odoo_repo_type: git
- odoo_repo_url: https://github.com/osiell/odoo-buildout-example.git
- odoo_repo_rev: "{{ odoo_version }}"
- odoo_repo_dest: "/home/{{ odoo_user }}/odoo"
```
The same but with PostgreSQL installed on a remote host (and available from
your Ansible inventory):
```yaml
- name: Odoo
hosts: odoo_server
become: yes
roles:
- odoo
vars:
- odoo_install_type: buildout
- odoo_version: 8.0
- odoo_repo_type: git
- odoo_repo_url: https://github.com/osiell/odoo-buildout-example.git
- odoo_repo_rev: "{{ odoo_version }}"
- odoo_repo_dest: "/home/{{ odoo_user }}/odoo"
- odoo_config_db_host: pg_server
- odoo_config_db_user: odoo
- odoo_config_db_passwd: PaSsWoRd
```
By default Ansible is looking for a `bootstrap.py` script and a `buildout.cfg`
file at the root of the cloned repository to call Buildout, but you can change
that to point to your own files. Assuming your repository looks like this:
```sh
REPO/
├── addons # custom modules
├── bin
│   └── bootstrap.py
├── builtout.cfg
├── builtout.dev.cfg
├── builtout.prod.cfg
└── builtout.test.cfg
```
We just set the relevant options to tell Ansible the files to use with the
`odoo_buildout_*` options:
```yaml
- name: Odoo
hosts: odoo_server
become: yes
roles:
- odoo
vars:
- odoo_install_type: buildout
- odoo_version: 8.0
- odoo_repo_type: git
- odoo_repo_url: https://SERVER/REPO
- odoo_repo_rev: master
- odoo_repo_dest: "/home/{{ odoo_user }}/odoo"
- odoo_buildout_bootstrap_path: "/home/{{ odoo_user }}/odoo/bin/bootstrap.py"
- odoo_buildout_config_path: "/home/{{ odoo_user }}/odoo/buildout.prod.cfg"
```
## Variables
See the [defaults/main.yml](defaults/main.yml) file.
View
@@ -1,27 +1,30 @@
odoo_service: odoo
odoo_install_type: standard # standard, buildout
odoo_version: 8.0
odoo_service: odoo
odoo_user: odoo
odoo_user_passwd: odoo
odoo_user_system: False
odoo_logdir: "/var/log/{{ odoo_user }}"
odoo_workdir: "/home/{{ odoo_user }}/odoo"
odoo_rootdir: "/home/{{ odoo_user }}/odoo/server"
odoo_init: True
odoo_init_env: {}
#VAR1: value1
#VAR2: value2
odoo_config_file: "/home/{{ odoo_user }}/{{ odoo_service }}.conf"
odoo_force_config: True
odoo_logdir: "/var/log/{{ odoo_user }}"
odoo_workdir: "/home/{{ odoo_user }}/odoo"
odoo_rootdir: "{{ odoo_install_type == 'buildout' and '/home/'+odoo_user+'/odoo/parts/odoo' or '/home/'+odoo_user+'/odoo/server' }}"
# Project repository to deploy
odoo_repo_type: git # git or hg
odoo_repo_url: https://github.com/odoo/odoo.git
odoo_repo_dest: "{{ odoo_rootdir }}"
odoo_repo_url: "{{ odoo_install_type == 'buildout' and 'https://github.com/osiell/odoo-buildout-example.git' or 'https://github.com/odoo/odoo.git' }}"
odoo_repo_dest: "{{ odoo_install_type == 'buildout' and odoo_workdir or odoo_rootdir }}"
odoo_repo_rev: "{{ odoo_version }}"
odoo_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_repo_depth: 1 # Set to 0 to clone the full history (slower)
# (this option is not supported with hg)
# Third party programs options
odoo_wkhtmltox_version: 0.12.1 # Download URLs available in the
# 'odoo_wkhtmltox_urls' variable
# (see 'vars/main.yml')
@@ -32,7 +35,9 @@ odoo_postgresql_set_user: True
odoo_postgresql_user_role_attr: CREATEDB,NOSUPERUSER
odoo_postgresql_active_unaccent: True
# Configuration options
# Standard installation/configuration options (odoo_install_type == 'standard')
odoo_config_file: "/home/{{ odoo_user }}/{{ odoo_service }}.conf"
odoo_force_config: True
odoo_config_addons_path:
- "/home/{{ odoo_user }}/odoo/server/openerp/addons"
- "/home/{{ odoo_user }}/odoo/server/addons"
@@ -92,5 +97,12 @@ odoo_config_custom: {}
#your_option1: value1
#your_option2: value2
# Buildout installation options (odoo_install_type == 'buildout')
odoo_buildout_venv_path: "{{ odoo_workdir }}/sandbox"
odoo_buildout_bootstrap_path: "{{ odoo_workdir }}/bootstrap.py"
odoo_buildout_bin_path: "{{ odoo_workdir }}/bin/buildout"
odoo_buildout_config_path: "{{ odoo_workdir }}/buildout.cfg"
odoo_buildout_odoo_bin_path: "{{ odoo_workdir }}/bin/start_odoo"
# Extra options
odoo_user_sshkeys: False # ../../path/to/public_keys/*
Oops, something went wrong.

0 comments on commit 8170353

Please sign in to comment.