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

force the creation of odoo_workdir and odoo_rootdir #90

Open
wants to merge 6 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
13 changes: 7 additions & 6 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ odoo_init: True
odoo_init_env: {}
#VAR1: value1
#VAR2: value2
odoo_logdir: "/var/log/{{ odoo_user }}"
odoo_logdir: "/var/log"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove {{ odoo_user }}?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because that's the base directory that will be used as the basis to create the specific odoo log directory, in the task:

  • name: Create log directory
    file: path={{ odoo_logdir }}/{{ odoo_service }} state=directory
    owner={{ odoo_user }} group={{ odoo_user }} force=no
    tags:
    • odoo_log

Copy link
Collaborator

@sebalix sebalix Jul 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why not odoo_logdir = "/var/log/{{ odoo_service }}"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because then someone could do odoo_logdir = "/var/log" by mistake, and then the role would change the permissions of the /var/log directory, that is shared.

The idea that I had in order to prevent this kind of errors is that the *dir variables point to the root dir. the final directory is root dir + {{ odoo_service }}

Copy link
Member Author

@JordiBForgeFlow JordiBForgeFlow Jul 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, {{ odoo_service }} will be used as a subdir of:
/{{ odoo_logdir }}/{{ odoo_service }} => For logs
/{{ odoo_workdir }}/{{ odoo_service }} => For work dir
/{{ odoo_rootdir }}/{{ odoo_service }}/server => For the server

odoo_logfile: "{{ ansible_service_mgr != 'systemd' and ('/'.join([odoo_logdir, odoo_service]) + '.log') or ''}}"
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' }}"
odoo_workdir: "/home/{{ odoo_user }}/{{ odoo_service }}"
odoo_rootdir: "{{ '/home/'+odoo_user+'/'+odoo_service }}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The odoo_rootdir is supposed to be the server directory (containing the odoo executable), which is /home/odoo/odoo/parts/odoo for buildout by default (need to be adapted), /home/odoo/odoo/server/ for standardandpip` (to adapt too). Or you want to change its meaning?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem to add absolute paths in a variable, is that someone could set odoo_rootdir = /opt and screw everything, because it would add permissions on odoo for the whole /opt.


# Project repository to deploy
odoo_repo_type: git # git or hg
Expand All @@ -39,7 +39,8 @@ odoo_postgresql_extensions:
- unaccent

# Standard installation/configuration options (odoo_install_type == 'standard')
odoo_config_file: "/home/{{ odoo_user }}/{{ odoo_service }}.conf"
odoo_config_file_dir: "/home/{{ odoo_user }}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use directly {{ odoo_config_file | dirname}} to get the directory path without adding another user option.
Feel free to create a new variable in ./vars/main.yml if you want a variable odoo_config_file_dir, these options are not supposed to be change by the user.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion {{ odoo_config_file }} should only contain the name of the config file. Because if you want to specify a certain subdir for the odoo config file, how can you possibly create that dir?

Same as above, for any path that you indicate you need a step that ensures that this path exists and is assigned to the right user.

And in order to ensure that people do now screw the standard linux, the paths indicated in parameters would not be created directly, but /{{ odoo_service }}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand now, thank you, so we have to drop the compatibility to achieve this, it wasn't clear and I was trying to keep this compatible.
A major release number is also required for such change (./meta/main.yml, to update to 2.0?).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be a problem, since it seems that ansible does not seem to support role versioning ansible/proposals#23

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was just to "warn" the users that this new version break the compatibility with the previous ones, nothing more :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we document that? will adding - version: 2.0 just work?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to document this change, you could add a page in the wiki telling how to stay compatible with old releases (list old variable values) and link it on the README? For the moment it's enough.

odoo_config_file: "{{ odoo_config_file_dir }}/{{ odoo_service }}.conf"
odoo_force_config: True
odoo_config_addons_path:
- "/home/{{ odoo_user }}/odoo/server/{{ (odoo_version | int) < 10 and 'openerp' or 'odoo' }}/addons"
Expand Down Expand Up @@ -106,13 +107,13 @@ odoo_config_custom: {}
#your_option2: value2

# Pip installation options (odoo_install_type == 'pip')
odoo_pip_venv_path: "{{ odoo_workdir }}/sandbox"
odoo_pip_venv_path: "{{ odoo_workdir }}/{{ odoo_service }}/sandbox"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

odoo_workdir already includes the odoo_service value.

odoo_pip_requirements_url: "file:///home/{{ odoo_user }}/requirements.txt"
odoo_pip_odoo_bin_path: "{{ odoo_pip_venv_path }}/bin/{{ (odoo_version | int) < 10 and 'odoo.py' or 'odoo' }}"

# Buildout installation options (odoo_install_type == 'buildout')
odoo_buildout_version: 2.10.0
odoo_buildout_venv_path: "{{ odoo_workdir }}/sandbox"
odoo_buildout_venv_path: "{{ odoo_workdir }}/{{ odoo_service }}/sandbox"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark.

odoo_buildout_bootstrap_path: "{{ odoo_workdir }}/bootstrap.py"
odoo_buildout_bootstrap_cmd: "{{ odoo_buildout_venv_path }}/bin/python {{ odoo_buildout_bootstrap_path }} -c {{ odoo_buildout_config_path }} --buildout-version {{ odoo_buildout_version }}"
odoo_buildout_bin_path: "{{ odoo_workdir }}/bin/buildout"
Expand Down
24 changes: 22 additions & 2 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- odoo_install_ssh

- name: Create log directory
file: path={{ odoo_logdir }} state=directory
file: path={{ odoo_logdir }}/{{ odoo_service }} state=directory
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If odoo_service should be part of the odoo_logdir directory, include it directly in this last option, this ensures that the "Create log directory" will effectively create the directory set in odoo_logdir, without any surprise.

owner={{ odoo_user }} group={{ odoo_user }} force=no
tags:
- odoo_log
Expand Down Expand Up @@ -62,8 +62,28 @@
tags:
- odoo_project

- name: Create working dir directory
file: path={{ odoo_workdir }}/{{ odoo_service }} state=directory
owner={{ odoo_user }} group={{ odoo_user }} force=yes

- name: Create odoo server directory
file: path={{ odoo_rootdir }}/{{ odoo_service }}/server state=directory
owner={{ odoo_user }} group={{ odoo_user }} force=yes
when: odoo_install_type != 'pip'
tags:
- odoo_install_type_standard
- odoo_install_type_buildout

- name: Create odoo config file directory
file: path={{ odoo_config_file_dir }}/{{ odoo_service }} state=directory
owner={{ odoo_user }} group={{ odoo_user }} force=yes
when: odoo_install_type != 'buildout'
tags:
- odoo_install_type_pip
- odoo_install_type_standard

- name: Create odoo data dir directory
file: path={{ odoo_config_data_dir }} state=directory
file: path={{ odoo_config_data_dir }}/{{ odoo_service }} state=directory
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark as for the "Create log directory" task / odoo_logdir option.

owner={{ odoo_user }} group={{ odoo_user }} force=yes
when: odoo_install_type != 'buildout'
tags:
Expand Down
2 changes: 1 addition & 1 deletion templates/odoo-10.0.init
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

PATH=/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin
WORKDIR={{ odoo_workdir }}
DAEMON={{ odoo_rootdir }}/odoo-bin
DAEMON={{ odoo_rootdir }}/{{ odoo_service }}/server/odoo-bin
NAME={{ odoo_service }}
DESC={{ odoo_service }}
CONFIG={{ odoo_config_file }}
Expand Down
2 changes: 1 addition & 1 deletion templates/odoo-8.0.init
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

PATH=/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin
WORKDIR={{ odoo_workdir }}
DAEMON={{ odoo_rootdir }}/odoo.py
DAEMON={{ odoo_rootdir }}/{{ odoo_service }}/server/odoo.py
NAME={{ odoo_service }}
DESC={{ odoo_service }}
CONFIG={{ odoo_config_file }}
Expand Down
2 changes: 1 addition & 1 deletion templates/odoo-9.0.init
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

PATH=/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin
WORKDIR={{ odoo_workdir }}
DAEMON={{ odoo_rootdir }}/odoo.py
DAEMON={{ odoo_rootdir }}/{{ odoo_service }}/server/odoo.py
NAME={{ odoo_service }}
DESC={{ odoo_service }}
CONFIG={{ odoo_config_file }}
Expand Down
4 changes: 2 additions & 2 deletions templates/odoo-standard.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Type=simple
User={{ odoo_user }}
WorkingDirectory={{ odoo_workdir }}
{% if odoo_version | version_compare('10.0', '>=') %}
ExecStart={{ odoo_rootdir }}/odoo-bin{{ odoo_logfile and ' --logfile %s' % odoo_logfile }} --config {{ odoo_config_file }}
ExecStart={{ odoo_rootdir }}/{{ odoo_service }}/server/odoo-bin{{ odoo_logfile and ' --logfile %s' % odoo_logfile }} --config {{ odoo_config_file }}
KillMode=mixed
{% else %}
ExecStart={{ odoo_rootdir }}/odoo.py{{ odoo_logfile and ' --logfile %s' % odoo_logfile }} --config {{ odoo_config_file }}
ExecStart={{ odoo_rootdir }}/{{ odoo_service }}/server/odoo.py{{ odoo_logfile and ' --logfile %s' % odoo_logfile }} --config {{ odoo_config_file }}
{% endif %}
{% for name, value in odoo_init_env.iteritems() %}
Environment={{ name }}={{ value }}
Expand Down
2 changes: 1 addition & 1 deletion vars/Ubuntu-16_Odoo-11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ odoo_buildout_build_dependencies:
- libwebp-dev

odoo_buildout_venv_cmd: "virtualenv --no-setuptools --python=python3 {{ odoo_buildout_venv_path }}"
odoo_pip_venv_cmd: "virtualenv --python=python3 {{ odoo_pip_venv_path }}"
º: "virtualenv --python=python3 {{ odoo_pip_venv_path }}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo.


odoo_wkhtmltox_version: 0.12.4

Expand Down