diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000000000000000000000000000000000..af2651bb1e19ee8c7765dff2512d3f1a7a4e5f4d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,115 @@ +# Änderungen / Zur Entwicklung beitragen + +## Puppet und Module + +Eine Installation von Puppet und Abhängigen Modulen in ```metadata.json``` ist Voraussetzung. + +Puppet-Module können im Kontext des Benutzer installiert werden, der die Tests durchführt. + +Die Installation z.B. von ```puppetlabs-stdlib```: +``` +$ puppet module install puppetlabs-stdlib +$ puppet module list +/home/benny/.puppet/modules +└── puppetlabs-stdlib (v4.13.1) +``` + +## puppet-lint + +Puppet-Code soll dem [Puppet Styleguide](https://docs.puppet.com/guides/style_guide.html) entsprechen, prüfbar durch ```puppet-lint```, mit Ausnahme des Checks für die Zeilenlänge. + +Installiert wird ```puppet-lint``` [per Gem](http://puppet-lint.com/): + +``` +$ gem install puppet-lint +``` + +## rpec-puppet + +Puppet-Code sollte mit spec-Tests abgedeckt sein, siehe [rspec-puppet](http://rspec-puppet.com/). + +Installation von ```rspec-puppet``` per [Gem](http://rspec-puppet.com/): + +``` +$ gem install rspec-puppet +$ cd <module_root> +``` + +Für eine detailiertere Ausgabe in Farbe kann eine Datei unter ```~/.rspec``` angelegt werden mit folgendem Inhalt: +``` +--color --format documentation +``` + +## Testen + +Die bestehenden spec-Tests finden sich unter ```spec/classes/```: + +``` +$ ls spec/classes/ +autoremove_pkg_spec.rb firewall_spec.rb noipv6_spec.rb puppet_agent_spec.rb +changetrack_spec.rb grub_spec.rb nrpe_spec.rb remove_pkg_spec.rb +docker_extras_spec.rb kernel_lts_spec.rb ntp_spec.rb simple_security_spec.rb +docker_spec.rb monit_spec.rb openssh-server_spec.rb sysctl_hung_task_panic_spec.rb +ethtool_setup_spec.rb motd_spec.rb postfix_spec.rb unattended_upgrades_spec.rb +``` +Die Tests können mit ```rake``` aus dem Projektverzeichnis ausgeführt werden: + +``` +$ rake + +ubuntu_server::autoremove_pkg + should compile into a catalogue without dependency cycles + +ubuntu_server::changetrack + should compile into a catalogue without dependency cycles + +ubuntu_server::docker_extras + should compile into a catalogue without dependency cycles + +ubuntu_server::docker + should compile into a catalogue without dependency cycles + with class defaults and docker_compose_version < 1.8.1 + should compile into a catalogue without dependency cycles + should contain Exec[docker-compose] + should contain Exec[docker-compose-bash-completion] + should contain File[/usr/local/bin/docker-compose] + with class defaults and docker_compose_version => 1.8.1 + should compile into a catalogue without dependency cycles + should not contain Exec[docker-compose] + should not contain Exec[docker-compose-bash-completion] + should not contain File[/usr/local/bin/docker-compose] + +(...) +ubuntu_server::unattended_upgrades + with class defaults, operatingsystem => Ubuntu + should compile into a catalogue without dependency cycles + should not contain File[/etc/apt/apt.conf.d/50unattended-upgrades] with content =~ /^Unattended-Upgrade::Automatic-Reboot[[:blank:]]*"true"/ + should contain File[/etc/apt/apt.conf.d/50unattended-upgrades] with content =~ /^Unattended-Upgrade::Remove-Unused-Dependencies[[:blank:]]*"true"/ + should contain File[/etc/apt/apt.conf.d/50unattended-upgrades] with content =~ /^[[:blank:]]*"docker-engine";/ + with $automatic_reboot = true, operatingsystem => Ubuntu + should compile into a catalogue without dependency cycles + should contain File[/etc/apt/apt.conf.d/50unattended-upgrades] with content =~ /^Unattended-Upgrade::Automatic-Reboot[[:blank:]]*"true"/ + with autoremove = false, operatingsystem => Ubuntu + should compile into a catalogue without dependency cycles + should not contain File[/etc/apt/apt.conf.d/50unattended-upgrades] with content =~ /^Unattended-Upgrade::Remove-Unused-Dependencies[[:blank:]]*"true"/ + +Total resources: 125 +Touched resources: 29 +Resource coverage: 23.20% +Untouched resources: + + Class[Ubuntu_server::Autoremove_pkg] + Class[Ubuntu_server::Changetrack] + Class[Ubuntu_server::Docker] + Class[Ubuntu_server::Docker_extras] +(...) + Service[postfix] + Service[puppet] + Service[rsyslog] + Service[ssh] + +Finished in 2.62 seconds (files took 0.50861 seconds to load) +91 examples, 0 failures +``` + +Dabei werden die Unit-Tests von ```rspec-puppet``` wie auch ein Test mit ```puppet-lint``` ausgeführt. diff --git a/metadata.json b/metadata.json index 0289545b1a5647ca7b08f7675dc94aa84cfc42e9..a5608a7bf44424fe71becd15136313f63e8351c9 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "GWDG-Puppet", - "version": "0.0.1", + "version": "1.0.0", "author": "Benedikt Wegmann <benedikt.wegmann@gwdg.de>", "summary": "Puppet-Module zur Server-Administration in der Infrastruktur der GWDG", "license": "Apache 2.0",