- hosts: - numquam tasks: - become: yes file: path: /etc/odoo state: absent - become: yes copy: dest: /etc/systemd/system/docker.odoo.service content: | [Unit] After=docker.service Requires=docker.service [Service] TimeoutStartSec=0 Restart=always ExecStartPre=-/usr/bin/docker stop odoo ExecStartPre=-/usr/bin/docker rm odoo ExecStartPre=/usr/bin/docker pull odoo ExecStart=/usr/bin/docker run \ -e HOST=172.17.0.1 \ -e PORT=5432 \ -e USER=odoo \ -e PASSWORD=odoo \ -p 8069:8069 \ --mount source=odoo-data,target=/var/lib/odoo \ --mount source=odoo-extra-addons,target=/mnt/extra-addons \ --name odoo -t \ odoo \ --workers=5 \ --http-port=8069 \ --longpolling-port=8070 \ --email-from=odoo@trygvis.io \ --smtp=172.17.0.1 \ --proxy-mode [Install] WantedBy=multi-user.target register: service_file - become: yes systemd: daemon_reload: yes when: service_file.changed - become: yes systemd: unit: docker.odoo.service enabled: yes state: started when: not service_file.changed - become: yes systemd: unit: docker.odoo.service enabled: yes state: restarted when: service_file.changed