Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

ZRAD-127: provision gitconfig into the vm #58

Merged
merged 5 commits into from
Nov 28, 2018
Merged

Conversation

byrond
Copy link
Contributor

@byrond byrond commented Oct 13, 2018

See ticket ZRAD-127 and issue #57.

Uses Vagrant's file provisioner to copy .gitconfig from the host.

Ansible will subsequently modify excludesfile to use the .gitignore that it copies into the VM.

To test:

  • Install the-vagrant into a project using this branch.
  • Run provisioning vagrant reload --provision
  • vagrant ssh and verify that ~/.gitconfig has the correct user.name and user.email

Questions:
Should this detect a missing user.name and user.email and prompt the developer to configure Git prior to provisioning the VM, or display a warning?

@byrond byrond requested a review from becw October 13, 2018 20:40
@byrond byrond self-assigned this Oct 13, 2018
Copy link
Member

@becw becw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this! It's simple and obvious what the Vagrantfile is doing -- which I think is better than hiding the change in an Ansible playbook. The tradeoff is that the change wouldn't be applied automatically if you just update the-vagrant (without reinstalling), but I am OK with that.

I'm going to test this before I merge, though :)

@becw
Copy link
Member

becw commented Oct 30, 2018

Hmm, the issue I'm seeing here is that I have all kinds of things in my local ~/.gitconfig that may or may not make sense in the Vagrant environment -- and, the-vagrant already provisions a .gitconfig and .gitignore:

vagrant@test:/var/www/test.local$ more ~/.gitconfig
[core]
	excludesfile = /home/vagrant/.gitignore
vagrant@test:/var/www/test.local$ more ~/.gitignore
# Folder view configuration files
.DS_Store

# cache files
._*

# Files that might appear on external disks
.Spotlight-V100
.Trashes

# IDE files
.idea

# Application specific files
node_modules
npm-debug.log
.sass-cache

... whereas my local .gitconfig contains, among other things:

[core]
        excludesfile = /Users/white/.gitignore

Is there another way we could approach this? Or do these config files need to change?

@byrond
Copy link
Contributor Author

byrond commented Nov 5, 2018

@becw, thanks for the feedback! I'm going to try a different approach by using Ansible.

@byrond
Copy link
Contributor Author

byrond commented Nov 6, 2018

@becw, I updated this to use Ansible to make changes to .gitconfig. It was originally being provisioned by this section:

- name: Common | Configure global gitignore
command: /usr/bin/git config --global core.excludesfile ~/.gitignore
tags: common

That would have updated any excludesfile setting coming in from the host, but it didn't address other things that might be in a .gitconfig. Now, the file is copied in from the host, Ansible reads the values of user.name and user.emai, then uses those in a gitconfig template that overwrites what came in from the host.

If you think this approach will work, I should probably move the file provisioning from the Vagrant file into the Ansible playbook, so everything is together. Also, this method will copy and update the .gitconfig every time provisioning is run. That doesn't seem like a huge deal, but if you think we need to only perform these steps when the host file changes, it might be possible.

@becw
Copy link
Member

becw commented Nov 14, 2018

I think this approach is good.

We talked about how the .gitconfig has to be copied from the host initially in order to have the config options available to Ansible. Given that, I think you should move forward with what you laid out above -- moving the file provisioning from the Vagrantfile into the Ansible playbook so that it lives with the other .gitconfig provisioning.

I think it's fine if this provisioning step runs every time the Vagrant provisioning is run.

@byrond
Copy link
Contributor Author

byrond commented Nov 21, 2018

@becw I moved the provisioning for copying the user's .gitconfig into the Ansible playbook. I tested provisioning after this change, and everything seems to still be working ok. I think this is good to go. Thanks!

@becw becw merged commit 47a3398 into develop Nov 28, 2018
@becw becw deleted the zrad-127-configure-git-user branch November 28, 2018 21:14
@becw
Copy link
Member

becw commented Nov 28, 2018

Fantastic, thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants