Skip to content

Instantly share code, notes, and snippets.

@fabiang
Created February 12, 2016 09:52
Show Gist options
  • Save fabiang/f0a1c93204458c47c00a to your computer and use it in GitHub Desktop.
Save fabiang/f0a1c93204458c47c00a to your computer and use it in GitHub Desktop.
Pass Github access token to virtual machines for Composer

Create a Github access token and set it globally with:

git config --global github.accesstoken your_access_token

You can also set a separate token for each project, if you don't pass --global to git config.

Exec { 'github-accesstoken':
command => "git config --global github.accesstoken '$github_accesstoken'",
unless => "test `git config --global github.accesstoken` = '$github_accesstoken'",
onlyif => "test -n '$github_accesstoken'",
before => Composer::Exec['composer-install'],
require => Package['git'],
user => 'vagrant',
environment => "HOME=/home/vagrant",
path => "/usr/bin",
}
GITHUB_ACCESSTOKEN=`git config github.accesstoken`.strip!
Vagrant.configure("2") do |config|
config.vm.define "foobar" do |foobar|
foobar.vm.provision :puppet do |puppet|
puppet.facter = {
"ssh_username" => "vagrant",
"github_accesstoken" => GITHUB_ACCESSTOKEN,
}
puppet.manifests_path = "puppet/manifests"
puppet.manifest_file = "site.pp"
puppet.options = ["--verbose", "--hiera_config /vagrant/puppet/hiera.yaml", "--parser future"]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment