Mapping Git branches to environments

333 views
Skip to first unread message

Joost Cassee

unread,
Jul 3, 2013, 6:45:31 PM7/3/13
to ansible...@googlegroups.com
Hi,

I am looking into Ansible to define our infrastructure in, and one charming idea I got from other provisioning systems is to map Git branches to environments. For example, I could try out a change in the infrastructure in a development branch and merge back into master to apply this change to the production servers. Puppet can do this with r10k [1], and Salt has this baked in with its GitFS backend [2].

Is anyone doing something like this with Ansible?

[1] https://github.com/adrienthebo/r10k
[2] http://docs.saltstack.com/topics/tutorials/gitfs.html

Regards,
Joost

Michael DeHaan

unread,
Jul 3, 2013, 7:01:43 PM7/3/13
to ansible...@googlegroups.com
Both of these tend to make my eyes bleed.

Generally, I don't think there's no reason for Ansible to need to because you could just execute an ansible-playbook command for each environment.

You could just check out your branch in different directories and you are good to go.

(However, this is pretty easy to do in AWX as you would just set up seperate project checkouts)





--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Michael DeHaan <mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

Joost Cassee

unread,
Jul 3, 2013, 8:46:53 PM7/3/13
to ansible...@googlegroups.com
Op donderdag 4 juli 2013 01:01:43 UTC+2 schreef Michael DeHaan het volgende:

Both of these tend to make my eyes bleed.

Generally, I don't think there's no reason for Ansible to need to because you could just execute an ansible-playbook command for each environment.

But would not developing that playbook be easier in a separate branch than copied from one directory to another?

You could just check out your branch in different directories and you are good to go.

(However, this is pretty easy to do in AWX as you would just set up seperate project checkouts)

Sure, I can set up some Git hooks myself too. That was my plan B. :-)

Regards,
Joost

Michael DeHaan

unread,
Jul 3, 2013, 8:53:26 PM7/3/13
to ansible...@googlegroups.com
Yeah I'm suggesting you would still be using a seperate branch, you'd just have it checked out in a few different places.   Same repo, branched, mergeable, still...

Just not having to "git branch" from the checkout location to get to see the one you want when you have to work on it, but rather making it accessible via the current filesystem -- thus Ansible need not know about it :)








Regards,
Joost

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Joost Cassee

unread,
Jul 3, 2013, 9:05:46 PM7/3/13
to ansible...@googlegroups.com
Op donderdag 4 juli 2013 02:53:26 UTC+2 schreef Michael DeHaan het volgende:

Yeah I'm suggesting you would still be using a seperate branch, you'd just have it checked out in a few different places.   Same repo, branched, mergeable, still...

Ah, check!

Just not having to "git branch" from the checkout location to get to see the one you want when you have to work on it, but rather making it accessible via the current filesystem -- thus Ansible need not know about it :)

Okay, I can see why you would want to keep this out of Ansible proper. If I would take the directory layout from the Best Practices docs [1], what would be the best place to integrate other branches?


Regards,
Joost 

Michael DeHaan

unread,
Jul 4, 2013, 12:18:47 AM7/4/13
to ansible...@googlegroups.com
You'd actually branch the entire project, so it wouldn't affect the hierarchy.

You could just check out the repo at two filesystem different points at different branches.





Regards,
Joost 

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dave Cottlehuber

unread,
Jul 4, 2013, 2:27:47 AM7/4/13
to ansible...@googlegroups.com
On 4 July 2013 06:18, Michael DeHaan <mic...@ansibleworks.com> wrote:
> You'd actually branch the entire project, so it wouldn't affect the
> hierarchy.
>
> You could just check out the repo at two filesystem different points at
> different branches.

While I like the concept of ansible getting its info via git, I think
in general its linking something unnecessary into ansible. I'd rather
have an HTTP accessible method where (for example) ansible retrieves
playbooks etc, and writes facts back into e.g. into CouchDB. I can
replicate securely between datacentres, and share inventory across
separate secure infrastructures. I'm not sure if an HTTP arrangement
like GET /ansible/playbooks … PUT /ansible/configs/:server would be
acceptable for core ansible?

Anyway.

In git-contrib there's a module called git-new-workdir which allows
sharing the same git index across multiple working dirs. It should
come in a default install of any recent git in the last couple years.

On my OSX is set as a shell alias:

gnw='/usr/local/Cellar/git/*/share/git-core/contrib/workdir/git-new-workdir'

usage: gnw <repository> <new_workdir> [<branch>]

if your project is stored in /projects/runcible then you can have a
separate checkout like so:

gnw /projects/runcible projects/pea-green-boat leafy-branch

Inside /projects/pea-green-boat it behaves just like a normal git
clone, except that the index is shared from /projects/runcible.

A+
Dave

Michael DeHaan

unread,
Jul 4, 2013, 8:02:59 AM7/4/13
to ansible...@googlegroups.com
"I'd rather
have an HTTP accessible method where (for example) ansible retrieves
playbooks etc, and writes facts back into e.g. into CouchDB."

No, Ansible pushes playbooks.

I don't see any need for an http layer with it's own security system here.

As for recording facts, you could definitely write your own callback system, though there is no reason for this to require another network connection.

I'm looking at building a system that keeps facts in a lookaside cache sometime in 1.3 or early 1.4.




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply all
Reply to author
Forward
0 new messages