diff --git a/roles/odoo/files/custom_502.html b/roles/odoo/files/custom_502.html
new file mode 100644
index 0000000..096b22a
--- /dev/null
+++ b/roles/odoo/files/custom_502.html
@@ -0,0 +1,363 @@
+
+
+
+Error 502
+
+
+
+
+
+
Error
+
502
+
Falla en la aplicación
+
+
+
+
+
+
diff --git a/roles/odoo/files/logrotate b/roles/odoo/files/logrotate
new file mode 100644
index 0000000..c5bad7f
--- /dev/null
+++ b/roles/odoo/files/logrotate
@@ -0,0 +1,11 @@
+/var/log/odoo/*.log {
+ daily
+ dateext
+ dateyesterday
+ rotate 30
+ compress
+ delaycompress
+ copytruncate
+ missingok
+ notifempty
+}
diff --git a/roles/odoo/files/nginx.conf b/roles/odoo/files/nginx.conf
new file mode 100644
index 0000000..43fa34b
--- /dev/null
+++ b/roles/odoo/files/nginx.conf
@@ -0,0 +1,73 @@
+pstream odoo8 {
+ server 127.0.0.1:8090 weight=1 fail_timeout=0;
+}
+
+upstream odoo8-im {
+ server 127.0.0.1:8082 weight=1 fail_timeout=0;
+}
+
+server {
+ # server port and name
+ listen 80;
+ server_name _;
+
+ # Specifies the maximum accepted body size of a client request,
+ # as indicated by the request header Content-Length.
+ client_max_body_size 200m;
+
+ ssl off;
+
+ # increase proxy buffer to handle some Odoo web requests
+ proxy_buffers 16 64k;
+ proxy_buffer_size 128k;
+ # force timeouts if the backend dies
+ proxy_connect_timeout 180m;
+ proxy_send_timeout 180m;
+ proxy_read_timeout 180m;
+ proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
+
+ gzip on;
+ gzip_min_length 1100;
+ gzip_buffers 4 32k;
+ gzip_types text/plain application/x-javascript text/xml text/css;
+ gzip_vary on;
+
+ # set headers
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
+
+ # by default, do not forward anything
+ proxy_redirect off;
+ proxy_buffering off;
+
+ error_page 502 /custom_502.html;
+
+ location = /custom_502.html {
+ root /usr/share/nginx/html;
+ internal;
+ }
+
+ location / {
+ proxy_pass http://odoo8;
+ }
+
+ location /longpolling {
+ proxy_pass http://odoo8-im;
+ }
+
+ # Cache some static data in memory for 2 hours.
+ # Under heavy load this should relieve stress on the Odoo web interface
+ location /web/static/ {
+ proxy_cache_valid 200 120m;
+ proxy_buffering on;
+ expires 864000;
+ proxy_pass http://odoo8;
+ }
+ location /website/static/ {
+ proxy_cache_valid 200 120m;
+ proxy_buffering on;
+ expires 864000;
+ proxy_pass http://odoo8;
+ }
+}
diff --git a/roles/odoo/files/odoo.conf b/roles/odoo/files/odoo.conf
new file mode 100644
index 0000000..898316e
--- /dev/null
+++ b/roles/odoo/files/odoo.conf
@@ -0,0 +1,47 @@
+[options]
+#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# Configuracion Odoo para Agofer
+#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+; Contrasena para administracion de base de datos:
+admin_passwd = 928333333333333333nc4046564565787444444444444444686783489u394d835n03984mw0d38$
+db_user = odoo
+db_name = Agofer
+list_db = True
+dbfilter = ^Agofer$
+addons_path = /opt/odoo_agofer/addons,/opt/v8_agofer,/opt/aeroo_report,/opt/contrib
+without_demo = True
+test_enable = False
+timezone = America/Bogota
+unaccent = True
+
+#-----------------------------------------------------------------------------
+# Registro
+#-----------------------------------------------------------------------------
+# syslog = True
+logfile = /var/log/odoo/odoo-server.log
+logrotate = False
+# ['debug_rpc_answer', 'debug_rpc', 'debug', 'debug_sql',
+# 'info', 'warn', 'error', 'critical']
+log_level = warn
+
+#-----------------------------------------------------------------------------
+# Rendimiento
+#-----------------------------------------------------------------------------
+#osv_memory_age_limit = 0.5
+workers = 4
+limit_time_cpu = 12000
+limit_time_real = 24000
+limit-memory-soft = 8053063680
+limit-memory-hard = 9395240960
+
+#-----------------------------------------------------------------------------
+# Acceso
+#-----------------------------------------------------------------------------
+proxy_mode = True
+xmlrpcs = False
+longpolling_port = 8082
+xmlrpc_port = 8090
+xmlrpc_interface = 127.0.0.1
+netrpc_interface = 127.0.0.1
+
diff --git a/roles/odoo/files/systemd_unit b/roles/odoo/files/systemd_unit
new file mode 100644
index 0000000..6b1bcb9
--- /dev/null
+++ b/roles/odoo/files/systemd_unit
@@ -0,0 +1,16 @@
+[Unit]
+Description=Odoo
+Requires=postgresql.service
+After=network.target postgresql.service
+
+[Service]
+Type=simple
+SyslogIdentifier=odoo
+PermissionsStartOnly=true
+User=odoo
+Group=odoo
+ExecStart=/home/odoo/.virtualenvs/odoo/bin/python /opt/odoo_agofer/openerp-server -c /etc/odoo_agofer-server.conf
+StandardOutput=journal+console
+
+[Install]
+WantedBy=multi-user.target
diff --git a/roles/odoo/tasks/main.yml b/roles/odoo/tasks/main.yml
index 29e36bb..497e556 100644
--- a/roles/odoo/tasks/main.yml
+++ b/roles/odoo/tasks/main.yml
@@ -60,9 +60,15 @@
- name: Clone current Odoo code
git:
repo: 'ssh://git@gitea.agofer.net:22001/Agofer/odoo_running_code.git'
- dest: /home/odoo/src/odoo
+ dest: /opt
depth: 1
+- name: Install python requirements for Odoo
+ pip:
+ virtualenv: /home/odoo/.virtualenvs/odoo
+ virtualenv_python: python2.7
+ requirements: /opt/odoo_agofer/requirements.txt
+
- name: Download and install wkhtmltopdf
apt:
deb: https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
@@ -126,3 +132,63 @@
db: Agofer
path_to_script: /home/odoo/remove_remote_connections.sql
+- name: Install Aeroo libs
+ pip:
+ virtualenv: /home/odoo/.virtualenvs/odoo
+ virtualenv_python: python2.7
+ name: 'git+https://github.com/aeroo/aeroolib.git@py2.x'
+
+- name: Configure Odoo log rotation
+ copy:
+ src: logrotate
+ dest: /etc/logrotate.d/odoo
+ mode: '0644'
+
+- name: Configure Nginx
+ copy:
+ src: custom_502.html
+ dest: /etc/nginx/custom_502.html
+ mode: '0644'
+
+- copy:
+ src: nginx.conf
+ dest: /etc/nginx/sites-available/odoo8
+ mode: '0644'
+
+- file:
+ state: link
+ src: /etc/nginx/sites-available/odoo8
+ dest: /etc/nginx/sites-enabled/odoo8
+
+- file:
+ state: link
+ src: /etc/nginx/custom_502.html
+ dest: /usr/share/nginx/html/custom_502.html
+
+- file:
+ state: absent
+ path: /etc/nginx/sites-enabled/default
+
+- name: Restart Nginx
+ systemd:
+ name: nginx
+ state: restarted
+
+- name: Configure Odoo
+ copy:
+ src: odoo.conf
+ dest: /etc/odoo_agofer-server.conf
+ mode: '0640'
+ owner: odoo
+ group: odoo
+
+- copy:
+ src: systemd_unit
+ dest: /etc/systemd/system/odoo.service
+
+- name: Enable and restart Odoo service
+ systemd:
+ name: odoo
+ enabled: true
+ state: started
+