Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No core files deployed using git since Ansible 1.8.2 #8

Closed
clonedagain opened this issue Dec 10, 2014 · 7 comments
Closed

No core files deployed using git since Ansible 1.8.2 #8

clonedagain opened this issue Dec 10, 2014 · 7 comments

Comments

@clonedagain
Copy link
Contributor

Ansible recently made it so that "git: update=no" does not make a checkout anymore (ansible/ansible@28f6a18).
So currently the playbook does not deploy the git repo when configured for it.

@clonedagain clonedagain changed the title No checkout created since Ansible 1.8.2 No core files deployed using git since Ansible 1.8.2 Dec 10, 2014
@sebalix
Copy link
Collaborator

sebalix commented Dec 10, 2014

Ok, I remember why I put the update=no statement in the playbook: to avoid an undesirable update to the last version of a given branch (odoo_repo_rev) when running the playbook a second time, which could bring regressions.

So, update should be removed (it is set to yes by default), and the clone task should not be run if the cloned directory already exists, as it is already done for Mercurial repositories. Is that ok for you?

@clonedagain
Copy link
Contributor Author

That's how I've set up my extra repos, but it feels awkward (I had to
use a shell task).
I'm new to Ansible but I feel that's not what a play should do. It's
supposed to setup the target into a well known state, so if the config
says it's a branch we should probably just checkout the branch with no
further ado.
If we want a specific commit deployed we can set {{ odoo_repo_rev }}.

@sebalix
Copy link
Collaborator

sebalix commented Dec 11, 2014

I agree, but in a day-to-day work, I don't want to pick a changeset hash on the remote repo and update my Ansible configuration, as we make releases manually on the server. What if we add an option to ensure update=no/yes (default yes)?
To test if a directory exists, there is the stat module: http://docs.ansible.com/stat_module.html#examples

@clonedagain
Copy link
Contributor Author

I'm trying to use Ansible mainly to bootstrap/resync my development
hosts from the production server.
Come to think of it, what I want to do is simply point odoo_repo_url,
and let Ansible reset the repo for me to the same state as production.
I'd even so far as to suggest we remove force=no too, so we really
know what to expect.
Currently I use a custom bash script to do just that, and then
automatically merge all the dev branches in, so it feels most natural to me.

Still, I see your point, and when I bootstrap the production server I do
the same as you. I just fell dirty doing it. Here's how I do it for my
extra repos, let me know if you find a more proper way.

  - shell: "[ -d /home/{{ odoo_user }}/{{ item }}/ ] ||git clone
git@git:/srv/git/odoo/{{item}}.git /home/{{ odoo_user }}/{{ item }}"

An option for |update=no/yes |won't do the job, because git : update=no has no "effect" (it only queries the remote server but
creates nothing locally).
You could add an option to decide whether to checkout every time (using
git: ... force=yes), or only the first time (using shell:). I
suggest it should be "checkout everytime" by default.

If that's too much trouble, you may just close this issue and I'll take
no offense: I think I can use tags to skip the git part of the role and
do my own stuff in my playbook.

@sebalix
Copy link
Collaborator

sebalix commented Dec 12, 2014

That's right, by default it should be force=yes and update=yes as this is the purpose of an Ansible role as you said. I need to override these values, because sometimes we prefer to avoid this behaviour (e.g. I prefer not to lose non-committed changes on my development VM by running its playbook). For production servers the default behaviour is a better choice.

I will add two options odoo_repo_update: True and odoo_repo_force: True, with an identical behaviour for Git and Mercurial repositories.

sebalix added a commit to sebalix/ansible-odoo that referenced this issue Dec 13, 2014
…he repository checkout. A checkout will always occured on the first playbook run, even with (fix issue OCA#8).
sebalix added a commit to sebalix/ansible-odoo that referenced this issue Dec 13, 2014
…lt 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 OCA#8).
sebalix added a commit to sebalix/ansible-odoo that referenced this issue Dec 13, 2014
…ntrol on the repository checkout. A checkout will always occured on the first playbook run, even with 'odoo_repo_update: False' (fix issue OCA#8).
@sebalix
Copy link
Collaborator

sebalix commented Dec 13, 2014

Finally, I just added one option odoo_repo_update: True + remove the force statement. Having equivalent control on the force part with Hg and Git is a bit awkward, so one option is enough (there is no real need to have an update on the working copy but without lose uncommitted changes (playbook hanging on a merge is not acceptable...)).
With this option we can run playbooks repeatedly on development environments without risk of losing uncommitted changes, it's all what I wanted!

You can check my branch fix-issue-8
Is this ok for you?

sebalix added a commit that referenced this issue Jan 2, 2015
[IMP] New option 'odoo_repo_update' (default to True) to have more control on the repository checkout (fix issue #8)
@clonedagain
Copy link
Contributor Author

Thanks, for the moment I've switch to a custom play to deploy all my git repos because of #2 but I think what you did is OK.

sebalix added a commit to sebalix/ansible-odoo that referenced this issue Oct 19, 2017
…ntrol on the repository checkout. A checkout will always occured on the first playbook run, even with 'odoo_repo_update: False' (fix issue OCA#8).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants