Ask Your Question
0

Puppet Repository Module Structure (Rspec, Vagrant, Serverspec)

asked 2015-11-18 17:03:12 -0500

louis gravatar image

updated 2015-11-19 20:18:59 -0500

I am trying to create a module layout that supports the following activities:

  1. Running Syntax Guide Validation (Rake Lint)
  2. Running Rspec (Unit Tests)
  3. Serverspec Tests
  4. Vagrant (Puppet Apply)

So far I got #1,#2 working using Puppetlabs Spec Helper and the following Layout.

├── Gemfile
├── Gemfile.lock
├── Modulefile
├── Puppetfile
├── README.md
├── Rakefile
├── Vagrantfile
├── default.pp
├── development
│   └── manifests
├── examples
│   └── init.pp
├── manifests
│   ├── **init.pp**
│   ├── install.pp
│   └── configure.pp
├── metadata.json
├── modules
│   ├── chocolatey
│   ├── stdlib
│   └── windows_env
├── scripts
│   ├── disable-firewall.bat
│   └── puppet-provisioning.bat
├── serverspec
├── spec
│   ├── classes
│   ├── defines
│   ├── fixtures
│   ├── functions
│   ├── hosts
│   └── spec_helper.rb
└── templates
    ├── sometemplate.erb

I am using a Windows Vagrant Box in order to test the puppet module but I am unable to map the current puppet module in the current directory(./manifests folder). The dependencies are managed normally and can be added to the Vagrantfile as expected.

Ideally, I would like to write my code and run all the tests before I commit any change to any fork repo.

Vagrantfile

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

    config.vm.box_url      = 'http://myserver/vagrantboxes/win2012r2-enterprise-1.2.2-virtualbox.box'
    config.vm.box          = 'win2012r2-enterprise-1.2.2-virtualbox'
    config.vm.communicator = 'winrm'
    config.winrm.username  = '_puppet'
    config.vm.boot_timeout = 1600
    config.vm.hostname     = 'myservername'
    config.vm.network "forwarded_port", guest: 5985, host: 15985, auto_correct: true # winrm
    config.vm.network "forwarded_port", guest: 3389, host: 13390, auto_correct: true #rdp

    config.vm.provider :virtualbox do |v|
      v.gui = true
      v.memory = 1048
      v.cpus   = 2
    end

    config.vm.provision :shell, path: 'scripts/disable-firewall.bat'
    config.vm.provision :shell, path: 'scripts/add-drive.ps1'

    config.vm.provision "puppet" do |puppet|
      puppet.module_path = ["modules","modules/gold/modules","development/modules"]
      puppet.environment = "development"
      puppet.environment_path = "."
      puppet.options = "--verbose --debug"
    end
end
edit retag flag offensive close merge delete

Comments

It would probably help to see your Vagrantfile if you can post a link to a pastebin of it.

GregLarkin gravatar imageGregLarkin ( 2015-11-19 19:58:14 -0500 )edit

there is a **vagrant-serverspec** plugin but was not looking to extend my dependencies at this point

louis gravatar imagelouis ( 2015-11-19 20:19:39 -0500 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2015-11-19 21:12:59 -0500

GregLarkin gravatar image

In order for Vagrant's Puppet provisioner to work by default, you have to place default.pp under your manifests directory relative to your Vagrantfile.

You can change those settings with the manifests_path and manifest_file options detailed here: https://docs.vagrantup.com/v2/provisioning/puppet_apply.html

I hope I understood the problem correctly, but if I didn't, please clarify.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-11-18 17:03:12 -0500

Seen: 143 times

Last updated: Nov 19 '15