This is the main repo for my GIT Workshop at PuppetConf 2014. http://sched.co/1nwrtol
Although really you should have it installed on your local machine already.
gem install puppet-lint
This vagrant setup requires one of the following versions: 4.0, 4.1, 4.2. The latest Virtualbox version is 4.3
Latest version, 1.5.6 when this repo was created, will work fine.
git clone https://github.com/terrimonster/gitworkshop.git
Get yourself a coffee and a snack. This is going to take awhile. Vagrant is provisioning the instances xmaster, gitlab, and testagent.
If you destroy (vagrant destroy ) the vagrant VMs and rebuild, the provisioning process won't take nearly as long because you'll already have downloaded the Puppet Enterprise installation file.
Login to the Gitlab web interface at: http://192.168.137.11 (default)
The default credentials are:
Username | root |
Password | 5iveL!fe |
You will be prompted immediately to change the root password.
Project Name: mymotd
Namespace: puppet
Visibility Level: Public
Go to the "profile settings" in Gitlab and click on "SSH Keys"
Add a public SSH key from your local machine
On your local machine, clone the example mymotd module:
git clone https://github.com/terrimonster/mymotd.git
cd mymotd
rm -rf .git
Now the code is not a git working directory. Let's make that into a repo for your GitLab server. While still inside that mymotd directory:
git init
git add .
git commit -m "Initial commit"
git remote add origin [email protected]:puppet/mymotd.git
git push origin master
You should then be able to see the pushed code in the Gitlab repositories.
cd mymotd
cp hooks/pre-commit .git/hooks/
chmod 755 .git/hooks/pre-commit
Introduce an error into mymotd/manifests/init.pp, then try to add and commit the file. You will have a result somewhat like below.
vi manifests/init.pp
git add manifests/init.pp
git commit -m 'error'
Validating manifests/init.pp...
Error: Could not parse for environment production: Syntax error at 'owner'; expected '}' at mymotd/manifests/init.pp:6
[master df572b4] error
1 file changed, 1 insertion(+), 1 deletion(-)
Fix the error(s) and re-attempt committing and pushing the file.
SSH into the GitLab server, copy the hooks in the vagrant directory to the mymotd directory, and make the pre-receive hook executable:
vagrant ssh gitlab
sudo su -
cp -r /vagrant/hooks /var/opt/gitlab/git-data/repositories/puppet/mymotd.git/
chmod a+x /var/opt/gitlab/git-data/repositories/puppet/mymotd.git/hooks/pre-receive
Delete the pre-commit hook from your local repository:
rm .git/hooks/pre-commit
Re-introduce an error into the manifests/init.pp file. You should see a result like below:
vi manifests/init.pp
git add manifests/init.pp
git commit -m 're-introducing error'
[master d66d298] re-introducing error
1 file changed, 2 insertions(+), 2 deletions(-)
git push origin master
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 358 bytes | 0 bytes/s, done.
Total 4 (delta 2), reused 0 (delta 0)
remote: Checking puppet manifest syntax for manifests/init.pp...
remote: Error: Could not parse for environment production: Syntax error at 'owner'; expected '}' at /tmp/mymotd/manifests/init.pp:6
remote: Error: puppet syntax error in manifests/init.pp (see above)
remote: Error: 1 syntax error(s) found in puppet manifests. Commit will be aborted.
remote: puppet-lint not installed. Skipping puppet-lint tests...
remote: Error: 1 subhooks failed. Declining push.
To [email protected]:puppet/mymotd.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:puppet/mymotd.git'
vagrant ssh xmaster
sudo su -
cat ~/.ssh/id_rsa.pub
Copy the output and paste it into a new SSH key entry in Gitlab.
vagrant ssh xmaster
sudo su -
cd /etc/puppetlabs/puppet/environments/production/modules
git clone [email protected]:puppet/mymotd.git
vagrant ssh xmaster
sudo su -
vi /etc/puppetlabs/puppet/environments/production/manifests/site.pp
Delete the comment to enable mymotd on node default.
vagrant ssh testagent
sudo su -
puppet agent -t
This makes use of Greg Sarjeant's data-driven-vagrantfile
Learn more about puppet-lint
Go do an interactive git tutorial
No Vagrant plugins are required.