From e0a3e9c914cb81ef7df1a4028ed7930ef2201cf7 Mon Sep 17 00:00:00 2001 From: Bob Leers Date: Mon, 24 Jun 2019 20:26:29 +0200 Subject: [PATCH 1/2] [ADD] Preserve/replace previous admin_passwd in Odoo configuration file --- tasks/config.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tasks/config.yml b/tasks/config.yml index 95b2e86..dcaf73b 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -1,8 +1,19 @@ --- +- name: Grep admin_passwd (to preserve) from current Odoo configuration file + shell: grep admin_passwd /home/{{ odoo_user }}/odoo.conf + register: grep_admin_passwd + ignore_errors: true + - name: Generate Odoo configuration file template: src=odoo-{{ odoo_version }}.conf dest={{ odoo_config_file }} owner={{ odoo_user }} group={{ odoo_user }} mode=0600 force={{ odoo_force_config and 'yes' or 'no' }} backup=yes + +- name: Preserve/replace previous admin_passwd in Odoo configuration file + lineinfile: + path: /home/{{ odoo_user }}/odoo.conf + regexp: '^admin_passwd.*=' + line: "{{ grep_admin_passwd.stdout }}" notify: Restart Odoo From 7f9322254e6cee67fd1baf93a7ac5ddd12806a52 Mon Sep 17 00:00:00 2001 From: Bob Leers Date: Wed, 9 Oct 2019 16:40:32 +0200 Subject: [PATCH 2/2] [UPD] User odoo_config_file variable instead of hardcoding. --- tasks/config.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tasks/config.yml b/tasks/config.yml index dcaf73b..482a135 100644 --- a/tasks/config.yml +++ b/tasks/config.yml @@ -1,9 +1,10 @@ --- - name: Grep admin_passwd (to preserve) from current Odoo configuration file - shell: grep admin_passwd /home/{{ odoo_user }}/odoo.conf + shell: grep admin_passwd {{ odoo_config_file }} register: grep_admin_passwd - ignore_errors: true + failed_when: false + changed_when: false - name: Generate Odoo configuration file template: src=odoo-{{ odoo_version }}.conf dest={{ odoo_config_file }} @@ -13,7 +14,7 @@ - name: Preserve/replace previous admin_passwd in Odoo configuration file lineinfile: - path: /home/{{ odoo_user }}/odoo.conf + path: "{{ odoo_config_file }}" regexp: '^admin_passwd.*=' line: "{{ grep_admin_passwd.stdout }}" notify: Restart Odoo