From 5ee7f149c8a41abbc51765818a4314afca50672e Mon Sep 17 00:00:00 2001 From: sebalix Date: Sat, 13 Dec 2014 11:58:36 +0100 Subject: [PATCH] [IMP] Two new options 'odoo_repo_force' and 'odoo_repo_update' (default to True) to have more control on the repository checkout. A checkout will always occured on the first playbook run, even with 'odoo_repo_update: False' (fix issue #8). --- README.md | 6 ++++++ defaults/main.yml | 6 ++++++ tasks/main.yml | 12 +++++++----- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a362716..4869541 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,12 @@ odoo_repo_type: git # git or hg odoo_repo_url: https://github.com/odoo/odoo.git odoo_repo_dest: "{{ odoo_rootdir }}" odoo_repo_rev: 8.0 +odoo_repo_force: True # Discards uncommited changes. The task will failed if + # local changes exist in the working copy and + # `odoo_repo_force: False` + `odoo_repo_update: True` +odoo_repo_update: True # Update the working copy or not. This option is + # ignored on the first run (a checkout of the working + # copy is always processed) # Odoo parameters odoo_config_addons_path: "/home/{{ odoo_user }}/odoo/server/addons,/home/{{ odoo_user }}/odoo/server/openerp/addons" diff --git a/defaults/main.yml b/defaults/main.yml index faea2c6..1fe806c 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -14,6 +14,12 @@ odoo_repo_type: git # git or hg odoo_repo_url: https://github.com/odoo/odoo.git odoo_repo_dest: "{{ odoo_rootdir }}" odoo_repo_rev: 8.0 +odoo_repo_force: True # Discards uncommited changes. The task will failed if + # local changes exist in the working copy and + # `odoo_repo_force: False` + `odoo_repo_update: True` +odoo_repo_update: True # Update the working copy or not. This option is + # ignored on the first run (a checkout of the working + # copy is always processed) # Configuration options odoo_config_addons_path: "/home/{{ odoo_user }}/odoo/server/addons,/home/{{ odoo_user }}/odoo/server/openerp/addons" diff --git a/tasks/main.yml b/tasks/main.yml index be400bd..cc019cb 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -36,7 +36,7 @@ - odoo - odoo_log -- name: Project repository exists? (Mercurial) +- name: Project repository already cloned? stat: path={{ odoo_repo_dest }} register: project_path tags: @@ -48,8 +48,9 @@ hg: repo={{ odoo_repo_url }} dest={{ odoo_repo_dest }} revision={{ odoo_repo_rev }} - force=no - when: odoo_repo_type == 'hg' and project_path.stat.exists == False and odoo_repo_url + force={{ odoo_repo_force and 'yes' or 'no' }} + when: odoo_repo_type == 'hg' and odoo_repo_url + and (odoo_repo_update or (project_path.stat.exists == False)) tags: - odoo - odoo_project @@ -59,8 +60,9 @@ git: repo={{ odoo_repo_url }} dest={{ odoo_repo_dest }} version={{ odoo_repo_rev }} - update=no - force=no + update={{ project_path.stat.exists == False and 'yes' + or (odoo_repo_update and 'yes' or 'no') }} + force={{ odoo_repo_force and 'yes' or 'no' }} when: odoo_repo_type == 'git' and odoo_repo_url tags: - odoo