{"id":13777912,"url":"https://github.com/neillturner/kitchen-puppet","last_synced_at":"2025-04-08T10:09:37.382Z","repository":{"id":15253900,"uuid":"17982967","full_name":"neillturner/kitchen-puppet","owner":"neillturner","description":"A Test Kitchen Provisioner for Puppet","archived":false,"fork":false,"pushed_at":"2023-08-09T09:00:38.000Z","size":655,"stargazers_count":104,"open_issues_count":4,"forks_count":85,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-17T13:38:00.843Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"ckaotik/ckaosMilitia","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neillturner.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2014-03-21T14:49:45.000Z","updated_at":"2024-05-22T19:39:54.000Z","dependencies_parsed_at":"2024-01-16T12:49:47.333Z","dependency_job_id":"514cc281-1d94-492a-a41d-cc48821f1800","html_url":"https://github.com/neillturner/kitchen-puppet","commit_stats":{"total_commits":418,"total_committers":52,"mean_commits":8.038461538461538,"dds":"0.43779904306220097","last_synced_commit":"6064967d7ef768334fc443e992ec41447d95e7f3"},"previous_names":[],"tags_count":72,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neillturner%2Fkitchen-puppet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neillturner%2Fkitchen-puppet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neillturner%2Fkitchen-puppet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neillturner%2Fkitchen-puppet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neillturner","download_url":"https://codeload.github.com/neillturner/kitchen-puppet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247819947,"owners_count":21001394,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T18:00:49.704Z","updated_at":"2025-04-08T10:09:37.355Z","avatar_url":"https://github.com/neillturner.png","language":"Ruby","funding_links":[],"categories":["Testing"],"sub_categories":[],"readme":"# Kitchen Puppet\n\n[![Gem Version](https://badge.fury.io/rb/kitchen-puppet.svg)](http://badge.fury.io/rb/kitchen-puppet)\n[![Gem Downloads](http://ruby-gem-downloads-badge.herokuapp.com/kitchen-puppet?type=total\u0026color=brightgreen)](https://rubygems.org/gems/kitchen-puppet)\n[![Build Status](https://travis-ci.org/neillturner/kitchen-puppet.png)](https://travis-ci.org/neillturner/kitchen-puppet)\n\n# kitchen-puppet\nA Test Kitchen Provisioner for Puppet\n\nThe providers supports both puppet apply and puppet agent clients and puppet bolt.\n\nThe PuppetApply provider works by passing the puppet repository based on attributes in .kitchen.yml \u0026 calling puppet apply.\n\nThe PuppetAgent provider works by passing the puppetmaster and other attributes in .kitchen.yml \u0026 calling puppet agent.\n\nThe PuppetBolt provider works by passing the puppet bolt commands based on attributes in .kitchen.yml \u0026 calling puppet bolt.\n\n\n\nThis provider has been tested against the Ubuntu 1604 and Centos 7 boxes running in docker and vagrant/virtualbox.\n\n## Template\n\nTemplate project for using kitchen for puppet development:\n\nhttps://github.com/scoopex/puppet-kitchen_template\n\n## Resources\n* http://ehaselwanter.com/en/blog/2014/05/08/using-test-kitchen-with-puppet\n* http://www.slideshare.net/MartinEtmajer/testdriven-infrastructure-with-puppet-test-kitchen-serverspec-and-rspec\n* http://www.slideshare.net/YuryTsarev/containercon-test-driven-infrastructure\n* http://events.linuxfoundation.org/sites/events/files/slides/ContainerCon%20-%20Test%20Driven%20Infrastructure_0.pdf\n* https://www.cedric-meury.ch/2016/10/test-driven-infrastructure-with-puppet-docker-test-kitchen-and-serverspec-yury-tsarev-gooddata\n* https://docs.puppet.com/puppet/latest/puppet_platform.html\n\n## Install\n\n1. install the latest Ruby on your workstations (for windows see https://rubyinstaller.org/downloads/)\n\n2. From a Command prompt:\n  * gem install librarian-puppet\n  * gem install test-kitchen  (or gem install test-kitchen -v 1.16.0 if using ruby version less than 2.3)\n  * gem install kitchen-puppet\n\n## Requirements\nIt is recommended to have a metadata.json file of your puppet module. It is used by kitchen-puppet to configure the module path.\nThe puppet docs describe (https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#write-a-metadatajson-file) how to create one.\n\nYou'll need a driver box without a chef installation so puppet can be installed. Puppet have one at http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box or http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box.\n\nFor PuppetAgent a server with a puppet master is required that can resolve the hostname ip address of the server. The server must also be able to resolve the hostname ip address of the puppet master.\n\nYou can also use the PuppetApply driver with a docker container, provided the necessary box requirements to install puppet are included inside the container. The easiest way to do this is to supply Kitchen-Docker with a custom dockerfile to install the needed dependencies for puppet installation.\n\n## Windows Support\n\nThere is windows/winrm support, currently not all functionality is supported.\n  * `require_chef_for_busser: false` (it is possible to call rspec over winrm to run the tests)\n  * `resolve_with_librarian_puppet: false` (librarian-puppet is not working on windows server)\n\nSample Puppet Repositories\n  * A sample hello world example puppet repository: https://github.com/neillturner/puppet_windows_repo\n  * A sample hello world example puppet repository for vagrant: https://github.com/neillturner/puppet_vagrant_windows_repo\n  * A more extensive sample installing virtualbox on windows: https://github.com/red-gate/puppet-virtualbox_windows\n\n## Using Environments\n\nIn the root directory for your puppet repository:\n\nCreate a `.kitchen.yml`, much like one the described above:\n\n```yaml\n    ---\n    driver:\n      name: vagrant\n\n    provisioner:\n      name: puppet_apply\n      puppet_environment: dev\n# the puppet environmnt files can be in this repository\n      puppet_environment_config_path: environment/dev/environment.conf\n      manifests_path:  environment/dev/manifests\n      modules_path: environment/dev/modules_mycompany\n# or external to this repository as long as they are accessible\n#     puppet_environment_config_path: /my_environments/dev/environment.conf\n#     manifests_path:                 /my_environments/dev/manifests\n#     modules_path:                   /my_environments/dev/modules_mycompany\n      hiera_data_path: /repository/puppet_repo/hieradata\n\n    platforms:\n    - name: nocm_ubuntu-12.04\n      driver_plugin: vagrant\n      driver_config:\n        box: nocm_ubuntu-12.04\n        box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box\n\n    suites:\n     - name: default\n```\n\nSample Puppet Repositories\n  * A sample hello world example puppet repository with docker : https://github.com/neillturner/puppet_docker_repo\n  * A sample hello world example puppet repository without environents : https://github.com/neillturner/puppet_vagrant_repo\n  * A sample hello world example puppet repository with environents : https://github.com/neillturner/puppet_vagrant_environment_repo\n  * A sample puppet bolt example puppet repository with docker : https://github.com/neillturner/bolt_docker_repo\n\n## Test-Kitchen Serverspec\n\nTo run the verify step with the test-kitchen serverspec setup your puppet repository as follows:\n\nIn the root directory for your puppet repository:\n\nCreate a `.kitchen.yml`, much like one the described above:\n\n```yaml\n    ---\n    driver:\n      name: vagrant\n\n    provisioner:\n      name: puppet_apply\n      manifests_path: /repository/puppet_repo/manifests\n      modules_path: /repository/puppet_repo/modules-mycompany\n      hiera_data_path: /repository/puppet_repo/hieradata\n\n    platforms:\n    - name: nocm_ubuntu-12.04\n      driver_plugin: vagrant\n      driver_config:\n        box: nocm_ubuntu-12.04\n        box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box\n\n    suites:\n     - name: default\n```\n\nThen for serverspec:\n\n```bash\n  mkdir -p test/integration/default/serverspec/localhost\n  echo \"require 'serverspec'\" \u003e\u003e test/integration/default/serverspec/spec_helper.rb\n  echo \"set :backend, :exec\" \u003e\u003e test/integration/default/serverspec/spec_helper.rb\n```\n\nCreate your serverspec tests in `test/integration/default/serverspec/localhost/xxxxxx_spec.rb`:\n\n```ruby\n  require 'spec_helper'\n\n  if os[:family] == 'ubuntu'\n        describe '/etc/lsb-release' do\n          it \"exists\" do\n              expect(file('/etc/lsb-release')).to be_file\n          end\n        end\n  end\n\n  if os[:family] == 'redhat'\n    describe '/etc/redhat-release' do\n      it \"exists\" do\n          expect(file('/etc/redhat-release')).to be_file\n      end\n    end\n  end\n```\n\n## Test-Kitchen Beaker\n\ntest-kitchen normally uses tests setup in `test/integration/....` directory. Beaker format puts the tests with the\n`spec/acceptance` directory in the puppet repository and the `spec_helper.rb` under the `spec` directory which is more logical.\n\nFor examples see:\n* https://gitlab.com/joshbeard/puppet-module-test\n* https://github.com/puppetlabs/puppetlabs-mysql/tree/master/spec\n\nTo implement this with test-kitchen setup the puppet repository with:\n\n* the spec files with the spec/acceptance directory.\n\n* the spec_helper in the spec folder.\n\n* install kitchen-verifier-serverspec on your workstation i.e. 'gem install kitchen-verifier-serverspec'\n\nSee examples:\n* [https://github.com/neillturner/puppet_vagrant_repo](https://github.com/neillturner/puppet_vagrant_repo)\n\n* [https://github.com/neillturner/puppet_repo](https://github.com/neillturner/puppet_repo)\n\n```\n.\n+-- spec\n¦   +-- acceptance\n¦   ¦   +-- mariadb_spec.rb\n¦   ¦   +-- nginx_spec.rb\n¦   ¦\n    +-- spec_helper.rb\n\n```\n\nIn the root directory for your puppet repository create a `.kitchen.yml` with\n\n* a verifier of 'serverspec'\n* a pattern parameter with the spec tests to run\n\n```yaml\nverifier:\n  name: serverspec\n\nsuites:\n  - name: base\n    verifier:\n      patterns:\n      - modules/mycompany_base/spec/acceptance/base_spec.rb\n```\n\nSee [kitchen-verifier-serverspec](https://github.com/neillturner/kitchen-verifier-serverspec)\n\n## hiera_writer_files option\n\nAllows creation of arbitrary YAML files in the target instance's `hieradata/`\ndir in test-kitchen configuration (eg `kitchen.yml`). Like setting chef\nattributes in `kitchen.yml`, except for Hiera YAML files.\n\nset `hiera_writer_files` in `kitchen.yml`\n\n```\n---\ndriver:\n  name: vagrant\n\nprovisioner:\n  name: puppet_apply\n  manifests_path: /repository/puppet_repo/manifests\n  modules_path: /repository/puppet_repo/modules-mycompany\n  hiera_data_path: /repository/puppet_repo/hieradata\n  hiera_writer_files:\n    - datacenter/vagrant.yaml:\n        logstash_servers: []\n        hosts:\n          10.1.2.3:\n          - puppet\n          - puppetdb\n\nplatforms:\n- name: nocm_ubuntu-12.04\n  driver_plugin: vagrant\n  driver_config:\n    box: nocm_ubuntu-12.04\n    box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box\n\nsuites:\n - name: default\n```\n\nThe above configuration will result in the creation of a file on the guest named\n`${hieradata}/datacenter/vagrant.yaml` containing:\n\n```\n---\nlogstash_servers: []\n  hosts:\n    10.1.2.3:\n    - puppet\n    - puppetdb\n```\n\nIt will overwrite any existing Hiera YAML files with the same name (on the\nguest), not merge.\n\n## Provisioner Options\nPlease see the Provisioner Options (https://github.com/neillturner/kitchen-puppet/blob/master/provisioner_options.md).\n\n## Contributing\nTo contribute to the repository, please follow the Fork / PR model:\n\n1. Fork The Repository\n2. Work on epic changes\n3. Write tests for your changes, see [TESTING](TESTING.md)\n4. Update Documentation\n5. Commit\n6. Push\n7. Create PR\n8. Profit(?)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneillturner%2Fkitchen-puppet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneillturner%2Fkitchen-puppet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneillturner%2Fkitchen-puppet/lists"}