Skip to content

Commit

Permalink
[IMP] Systemd integration.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmequignon authored and sebalix committed Jan 29, 2018
1 parent 3775cf6 commit a192a6b
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 21 deletions.
7 changes: 0 additions & 7 deletions tasks/install_buildout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,3 @@
become_user: "{{ odoo_user }}"
command: "{{ odoo_buildout_bin_path }} -c {{ odoo_buildout_config_path }}"
changed_when: False

- name: Generate Odoo init script
template: src=odoo-buildout.init dest=/etc/init.d/{{ odoo_service }}
owner=root group=root mode=0755
force=yes
backup=yes
notify: Restart Odoo
7 changes: 0 additions & 7 deletions tasks/install_pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,3 @@
- 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
7 changes: 0 additions & 7 deletions tasks/install_standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,3 @@
- import_tasks: config.yml
tags:
- odoo_config

- name: Generate Odoo init script
template: src=odoo-{{ odoo_version }}.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
60 changes: 60 additions & 0 deletions tasks/service.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,65 @@
---

- block:
- name: Generate Odoo init script (standard)
template: src=odoo-{{ odoo_version }}.init dest=/etc/init.d/{{ odoo_service }}
owner=root group=root mode=0755
force=yes
backup=yes
when: ansible_service_mgr != 'systemd'
notify: Restart Odoo

- name: Generate systemd Odoo service (standard)
template:
src=odoo-standard.service
dest=/etc/systemd/system/{{ odoo_service }}.service
owner=root group=root mode=0755
force=yes
backup=yes
when: ansible_service_mgr == 'systemd'
notify: Restart Odoo
when: odoo_install_type == 'standard'

- block:
- name: Generate Odoo init script (buildout)
template: src=odoo-buildout.init dest=/etc/init.d/{{ odoo_service }}
owner=root group=root mode=0755
force=yes
backup=yes
when: ansible_service_mgr != 'systemd'
notify: Restart Odoo

- name: Generate systemd Odoo service (buildout)
template:
src=odoo-buildout.service
dest=/etc/systemd/system/{{ odoo_service }}.service
owner=root group=root mode=0755
force=yes
backup=yes
when: ansible_service_mgr == 'systemd'
notify: Restart Odoo
when: odoo_install_type == 'buildout'

- block:
- name: Generate Odoo init script (pip)
template: src=odoo-pip.init dest=/etc/init.d/{{ odoo_service }}
owner=root group=root mode=0755
force=yes
backup=yes
when: ansible_service_mgr != 'systemd'
notify: Restart Odoo

- name: Generate systemd Odoo service (pip)
template:
src=odoo-pip.service
dest=/etc/systemd/system/{{ odoo_service }}.service
owner=root group=root mode=0755
force=yes
backup=yes
when: ansible_service_mgr == 'systemd'
notify: Restart Odoo
when: odoo_install_type == 'pip'

- name: Enable Odoo service
service: name={{ odoo_service }} enabled=yes state=started
when: odoo_init == True
Expand Down
15 changes: 15 additions & 0 deletions templates/odoo-buildout.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description={{ odoo_service }}
After=network.target

[Service]
Type=simple
User={{ odoo_user }}
WorkingDirectory={{ odoo_workdir }}
ExecStart={{ odoo_buildout_odoo_bin_path }}
{% for name, value in odoo_init_env.iteritems() %}
Environment={{ name }}={{ value }}
{% endfor %}

[Install]
WantedBy=multi-user.target
15 changes: 15 additions & 0 deletions templates/odoo-pip.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description={{ odoo_service }}
After=network.target

[Service]
Type=simple
User={{ odoo_user }}
WorkingDirectory={{ odoo_workdir }}
ExecStart={{ odoo_pip_odoo_bin_path }}
{% for name, value in odoo_init_env.iteritems() %}
Environment={{ name }}={{ value }}
{% endfor %}

[Install]
WantedBy=multi-user.target
19 changes: 19 additions & 0 deletions templates/odoo-standard.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[Unit]
Description={{ odoo_service }}
After=network.target

[Service]
Type=simple
User={{ odoo_user }}
WorkingDirectory={{ odoo_workdir }}
{% if odoo_version | version_compare('10.0', '>=') %}
ExecStart={{ odoo_rootdir }}/odoo-bin --logfile {{ odoo_logdir }}/{{ odoo_service }}.log
{% else %}
ExecStart={{ odoo_rootdir }}/odoo.py --logfile {{ odoo_logdir }}/{{ odoo_service }}.log
{% endif %}
{% for name, value in odoo_init_env.iteritems() %}
Environment={{ name }}={{ value }}
{% endfor %}

[Install]
WantedBy=multi-user.target

0 comments on commit a192a6b

Please sign in to comment.