From af35b8956f01e6411cb5a8604aa0ba2f4836fd30 Mon Sep 17 00:00:00 2001 From: Sergio Oliveira Date: Thu, 1 Aug 2013 12:59:35 -0300 Subject: [PATCH] Adding vagrant and initial provisioning to colab --- .gitignore | 1 + Vagrantfile | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ puppet/bootstrap.sh | 12 ++++++++++++ puppet/hiera.yaml | 6 ++++++ puppet/hieradata/common.yaml | 6 ++++++ puppet/manifests/init.pp | 2 ++ puppet/modules/colab/manifests/init.pp | 9 +++++++++ puppet/modules/locale/README.md | 2 ++ puppet/modules/locale/TODO | 1 + puppet/modules/locale/manifests/init.pp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ puppet/modules/locale/test/init.pp | 1 + puppet/modules/ntp/.gitignore | 18 ++++++++++++++++++ puppet/modules/ntp/README.md | 16 ++++++++++++++++ puppet/modules/ntp/manifests/init.pp | 15 +++++++++++++++ puppet/modules/ntp/tests/init.pp | 1 + puppet/modules/postfix/README.md | 2 ++ puppet/modules/postfix/manifests/init.pp | 41 +++++++++++++++++++++++++++++++++++++++++ puppet/modules/postfix/templates/postfix.preseed.erb | 17 +++++++++++++++++ puppet/modules/postfix/tests/init.pp | 2 ++ puppet/modules/ps1/README.md | 18 ++++++++++++++++++ puppet/modules/ps1/manifests/init.pp | 37 +++++++++++++++++++++++++++++++++++++ puppet/modules/ps1/test/init.pp | 1 + puppet/modules/timezone/.gitignore | 2 ++ puppet/modules/timezone/LICENSE | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ puppet/modules/timezone/Modulefile | 9 +++++++++ puppet/modules/timezone/README.md | 26 ++++++++++++++++++++++++++ puppet/modules/timezone/manifests/init.pp | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ puppet/modules/timezone/manifests/params.pp | 12 ++++++++++++ puppet/modules/timezone/spec/spec.opts | 6 ++++++ puppet/modules/timezone/spec/spec_helper.rb | 18 ++++++++++++++++++ puppet/modules/timezone/tests/init.pp | 1 + puppet/modules/vim/README.md | 2 ++ puppet/modules/vim/files/vimrc.local | 0 puppet/modules/vim/manifests/init.pp | 17 +++++++++++++++++ puppet/modules/vim/test/init.pp | 0 35 files changed, 725 insertions(+), 0 deletions(-) create mode 100644 Vagrantfile create mode 100644 puppet/bootstrap.sh create mode 100644 puppet/hiera.yaml create mode 100644 puppet/hieradata/common.yaml create mode 100644 puppet/manifests/init.pp create mode 100644 puppet/modules/colab/manifests/init.pp create mode 100644 puppet/modules/locale/README.md create mode 100644 puppet/modules/locale/TODO create mode 100644 puppet/modules/locale/manifests/init.pp create mode 100644 puppet/modules/locale/test/init.pp create mode 100644 puppet/modules/ntp/.gitignore create mode 100644 puppet/modules/ntp/README.md create mode 100644 puppet/modules/ntp/manifests/init.pp create mode 100644 puppet/modules/ntp/tests/init.pp create mode 100644 puppet/modules/postfix/README.md create mode 100644 puppet/modules/postfix/manifests/init.pp create mode 100644 puppet/modules/postfix/templates/postfix.preseed.erb create mode 100644 puppet/modules/postfix/tests/init.pp create mode 100644 puppet/modules/ps1/README.md create mode 100644 puppet/modules/ps1/manifests/init.pp create mode 100644 puppet/modules/ps1/test/init.pp create mode 100644 puppet/modules/timezone/.gitignore create mode 100644 puppet/modules/timezone/LICENSE create mode 100644 puppet/modules/timezone/Modulefile create mode 100644 puppet/modules/timezone/README.md create mode 100644 puppet/modules/timezone/manifests/init.pp create mode 100644 puppet/modules/timezone/manifests/params.pp create mode 100644 puppet/modules/timezone/spec/spec.opts create mode 100644 puppet/modules/timezone/spec/spec_helper.rb create mode 100644 puppet/modules/timezone/tests/init.pp create mode 100644 puppet/modules/vim/README.md create mode 100644 puppet/modules/vim/files/vimrc.local create mode 100644 puppet/modules/vim/manifests/init.pp create mode 100644 puppet/modules/vim/test/init.pp diff --git a/.gitignore b/.gitignore index f69b52a..65de7cd 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ local_settings.py *.swp *.sqlite3 .DS_Store +.vagrant diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..4d6f216 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,84 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # All Vagrant configuration is done here. The most common configuration + # options are documented and commented below. For a complete reference, + # please see the online documentation at vagrantup.com. + + # Every Vagrant virtual environment requires a box to build off of. + config.vm.box = "precise64" + + # The url from where the 'config.vm.box' box will be fetched if it + # doesn't already exist on the user's system. + config.vm.box_url = "http://files.vagrantup.com/precise64.box" + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + config.vm.network :forwarded_port, guest: 80, host: 8080 + config.vm.network :forwarded_port, guest: 8000, host: 8000 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network :private_network, ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network :public_network + + # If true, then any SSH connections made will enable agent forwarding. + # Default value: false + # config.ssh.forward_agent = true + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider :virtualbox do |vb| + # # Don't boot with headless mode + # vb.gui = true + # + # # Use VBoxManage to customize the VM. For example to change memory: + # vb.customize ["modifyvm", :id, "--memory", "1024"] + # end + # + # View the documentation for the provider you're using for more + # information on available options. + + config.vm.provision :shell, :path => "puppet/bootstrap.sh" + + # Enable provisioning with Puppet stand alone. Puppet manifests + # are contained in a directory path relative to this Vagrantfile. + # You will need to create the manifests directory and a manifest in + # the file base.pp in the manifests_path directory. + # + # An example Puppet manifest to provision the message of the day: + # + # # group { "puppet": + # # ensure => "present", + # # } + # # + # # File { owner => 0, group => 0, mode => 0644 } + # # + # # file { '/etc/motd': + # # content => "Welcome to your Vagrant-built virtual machine! + # # Managed by Puppet.\n" + # # } + # + config.vm.provision :puppet do |puppet| + puppet.module_path = "puppet/modules" + puppet.manifests_path = "puppet/manifests" + puppet.manifest_file = "init.pp" + end +end diff --git a/puppet/bootstrap.sh b/puppet/bootstrap.sh new file mode 100644 index 0000000..3a2a8fa --- /dev/null +++ b/puppet/bootstrap.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +PUPPET_VERSION=`dpkg -l | grep puppet-common | awk '{ print $3 }'` + +if [ "$PUPPET_VERSION" != '3.2.3-1puppetlabs1' ] ; then + wget -O /tmp/puppet_apt.deb http://apt.puppetlabs.com/puppetlabs-release-precise.deb &> /dev/null + dpkg -i /tmp/puppet_apt.deb + DEBIAN_FRONTEND=noninteractive apt-get update -y + DEBIAN_FRONTEND=noninteractive apt-get install puppet -y +fi + +cp /vagrant/puppet/hiera.yaml /etc/puppet/hiera.yaml -f diff --git a/puppet/hiera.yaml b/puppet/hiera.yaml new file mode 100644 index 0000000..7e57ab9 --- /dev/null +++ b/puppet/hiera.yaml @@ -0,0 +1,6 @@ +--- +:backends: yaml +:yaml: + :datadir: /vagrant/puppet/hieradata +:hierarchy: common +:logger: console diff --git a/puppet/hieradata/common.yaml b/puppet/hieradata/common.yaml new file mode 100644 index 0000000..5e66af3 --- /dev/null +++ b/puppet/hieradata/common.yaml @@ -0,0 +1,6 @@ +--- +locale::locales: pt_BR pt_BR.UTF-8 en_US en_US.UTF-8 + +timezone::timezone: America/Sao_Paulo + +postfix::admin_email: test@test.test diff --git a/puppet/manifests/init.pp b/puppet/manifests/init.pp new file mode 100644 index 0000000..a480ae4 --- /dev/null +++ b/puppet/manifests/init.pp @@ -0,0 +1,2 @@ + +include colab diff --git a/puppet/modules/colab/manifests/init.pp b/puppet/modules/colab/manifests/init.pp new file mode 100644 index 0000000..f3c8f19 --- /dev/null +++ b/puppet/modules/colab/manifests/init.pp @@ -0,0 +1,9 @@ + +class colab { + include ps1 + include vim + include ntp + include locale + include timezone + include postfix +} diff --git a/puppet/modules/locale/README.md b/puppet/modules/locale/README.md new file mode 100644 index 0000000..dd9cc77 --- /dev/null +++ b/puppet/modules/locale/README.md @@ -0,0 +1,2 @@ +puppet-locale +============= \ No newline at end of file diff --git a/puppet/modules/locale/TODO b/puppet/modules/locale/TODO new file mode 100644 index 0000000..ecd7ab6 --- /dev/null +++ b/puppet/modules/locale/TODO @@ -0,0 +1 @@ +Add unless to check if necessary exec install_locales \ No newline at end of file diff --git a/puppet/modules/locale/manifests/init.pp b/puppet/modules/locale/manifests/init.pp new file mode 100644 index 0000000..dfce7c3 --- /dev/null +++ b/puppet/modules/locale/manifests/init.pp @@ -0,0 +1,56 @@ +class locale ( + $locales = 'en_US.UTF-8 pt_BR', + $lang = 'en_US.UTF-8', + $language = 'en_US' +) { + + Exec { + path => ['/usr/bin', '/usr/sbin', '/bin'] + } + + file { '/var/cache/locale': + ensure => directory, + mode => '0755', + owner => 'root', + } + + file { '/var/cache/locale/installed': + ensure => present, + mode => '0644', + owner => 'root', + content => "${locales}-${lang}-${language}", + require => File['/var/cache/locale'], + } + + exec { 'install_locales': + command => "locale-gen ${locales}", + refreshonly => true, + subscribe => File['/var/cache/locale/installed'], + notify => Exec['reload_locales'] + } + + if $lang { + exec { 'update_default_lang': + command => "update-locale LANG='${lang}'", + notify => Exec['reload_locales'], + refreshonly => true, + subscribe => File['/var/cache/locale/installed'], + } + } + + if $language { + exec { 'update_default_language': + command => "update-locale LANGUAGE='${language}'", + notify => Exec['reload_locales'], + refreshonly => true, + subscribe => File['/var/cache/locale/installed'], + } + } + + exec { 'reload_locales': + command => "dpkg-reconfigure locales", + refreshonly => true + } + +} + diff --git a/puppet/modules/locale/test/init.pp b/puppet/modules/locale/test/init.pp new file mode 100644 index 0000000..d29ba73 --- /dev/null +++ b/puppet/modules/locale/test/init.pp @@ -0,0 +1 @@ +include locale \ No newline at end of file diff --git a/puppet/modules/ntp/.gitignore b/puppet/modules/ntp/.gitignore new file mode 100644 index 0000000..560d1a6 --- /dev/null +++ b/puppet/modules/ntp/.gitignore @@ -0,0 +1,18 @@ +*.gem +*.rbc +.bundle +.config +coverage +InstalledFiles +lib/bundler/man +pkg +rdoc +spec/reports +test/tmp +test/version_tmp +tmp + +# YARD artifacts +.yardoc +_yardoc +doc/ diff --git a/puppet/modules/ntp/README.md b/puppet/modules/ntp/README.md new file mode 100644 index 0000000..e4f6178 --- /dev/null +++ b/puppet/modules/ntp/README.md @@ -0,0 +1,16 @@ +Puppet ntp +========== +Start a cronjob to run every hour ntpdate + +Usage +========== + +```puppet +include ntp # Use default server (pool.ntp.org) or your hiera config (puppet 3+) +``` +or +```puppet +class { 'ntp': + server => 'your ntp server' +} +``` \ No newline at end of file diff --git a/puppet/modules/ntp/manifests/init.pp b/puppet/modules/ntp/manifests/init.pp new file mode 100644 index 0000000..01b3356 --- /dev/null +++ b/puppet/modules/ntp/manifests/init.pp @@ -0,0 +1,15 @@ + +class ntp ( + $server='pool.ntp.org', +){ + package { 'ntpdate': + ensure => installed, + } + + cron { 'ntpdate': + command => "/usr/sbin/ntpdate $server > /dev/null", + user => 'root', + minute => '0', + require => Package['ntpdate'], + } +} diff --git a/puppet/modules/ntp/tests/init.pp b/puppet/modules/ntp/tests/init.pp new file mode 100644 index 0000000..9f87de7 --- /dev/null +++ b/puppet/modules/ntp/tests/init.pp @@ -0,0 +1 @@ +include ntp diff --git a/puppet/modules/postfix/README.md b/puppet/modules/postfix/README.md new file mode 100644 index 0000000..a40f79b --- /dev/null +++ b/puppet/modules/postfix/README.md @@ -0,0 +1,2 @@ +puppet-postfix +============== \ No newline at end of file diff --git a/puppet/modules/postfix/manifests/init.pp b/puppet/modules/postfix/manifests/init.pp new file mode 100644 index 0000000..6b23887 --- /dev/null +++ b/puppet/modules/postfix/manifests/init.pp @@ -0,0 +1,41 @@ + +class postfix ( + $admin_email, + $server_name=$fqdn, + $mailbox_limit=0 # Zero means no limit +) { + + $postfix_preseed = '/var/cache/debconf/postfix.preseed' + $preseed_cmd = "debconf-set-selections $postfix_preseed" + + file { $postfix_preseed: + ensure => present, + content => template('postfix/postfix.preseed.erb'), + } + + exec { $preseed_cmd: + path => '/usr/bin/', + refreshonly => true, + subscribe => File[$postfix_preseed], + } + + package { 'postfix': + ensure => installed, + require => File[$postfix_preseed], + responsefile => $postfix_preseed, + } + + package { 'mailutils': + ensure => installed, + } + + service {'postfix': + ensure => running, + enable => true, + hasstatus => false, + stop => 'invoke-rc.d postfix stop', + start => 'invoke-rc.d postfix start', + restart => 'invoke-rc.d postfix restart', + require => Package['postfix'] + } +} diff --git a/puppet/modules/postfix/templates/postfix.preseed.erb b/puppet/modules/postfix/templates/postfix.preseed.erb new file mode 100644 index 0000000..4eac2e1 --- /dev/null +++ b/puppet/modules/postfix/templates/postfix.preseed.erb @@ -0,0 +1,17 @@ +postfix postfix/root_address string <%= @admin_email %> +postfix postfix/rfc1035_violation boolean false +postfix postfix/mydomain_warning boolean +postfix postfix/mynetworks string +postfix postfix/mailname string <%= @server_name %> +postfix postfix/tlsmgr_upgrade_warning boolean +postfix postfix/recipient_delim string +postfix postfix/main_mailer_type select Internet Site +postfix postfix/destinations string localhost, <%= @fqdn %>, <%= @hostname %> +postfix postfix/retry_upgrade_warning boolean +postfix postfix/kernel_version_warning boolean +postfix postfix/sqlite_warning boolean +postfix postfix/mailbox_limit string <%= @mailbox_limit %> +postfix postfix/relayhost string +postfix postfix/procmail boolean false +postfix postfix/protocols select all +postfix postfix/chattr boolean false diff --git a/puppet/modules/postfix/tests/init.pp b/puppet/modules/postfix/tests/init.pp new file mode 100644 index 0000000..5bffcc8 --- /dev/null +++ b/puppet/modules/postfix/tests/init.pp @@ -0,0 +1,2 @@ + +include postfix diff --git a/puppet/modules/ps1/README.md b/puppet/modules/ps1/README.md new file mode 100644 index 0000000..a5f664f --- /dev/null +++ b/puppet/modules/ps1/README.md @@ -0,0 +1,18 @@ +puppet-ps1 +============== + +Class to customize PS1 + +Usage: + class { 'ps1': + color => 'yellow' + } + or + include shell to use default color (red) + +Allowed Colors: + 'green' + 'red' + 'yellow' + + diff --git a/puppet/modules/ps1/manifests/init.pp b/puppet/modules/ps1/manifests/init.pp new file mode 100644 index 0000000..0b75b17 --- /dev/null +++ b/puppet/modules/ps1/manifests/init.pp @@ -0,0 +1,37 @@ +class ps1 ( + $color = 'red' +) { + $color_code = $color ? { + 'red' => '1', + 'green' => '2', + 'yellow' => '3', + default => '1' + } + + $force_color_prompt_cmd = "/bin/sed -i -re '/force_color_prompt=yes/ s/^#//'" + $force_color_prompt_condition = '/bin/grep "#force_color_prompt"' + + $ps1_color_cmd = "/bin/sed -i -re 's/01;3[1-3]m/01;3${color_code}m/'" + $ps1_color_condition = "/bin/grep '01;3${color_code}m'" + + $skel_path = '/etc/skel/.bashrc' + $root_path = '/root/.bashrc' + + # uncomment force_color_prompt in skel + exec { "$force_color_prompt_cmd $skel_path": + onlyif => "$force_color_prompt_condition $skel_path" + } + # uncomment force_color_prompt in root + exec { "$force_color_prompt_cmd $root_path": + onlyif => "$force_color_prompt_condition $root_path" + } + + # change prompt color in skel + exec { "$ps1_color_cmd $skel_path": + unless => "$ps1_color_condition $skel_path", + } + # change prompt color in root + exec { "$ps1_color_cmd $root_path": + unless => "$ps1_color_condition $root_path", + } +} diff --git a/puppet/modules/ps1/test/init.pp b/puppet/modules/ps1/test/init.pp new file mode 100644 index 0000000..2a46ba2 --- /dev/null +++ b/puppet/modules/ps1/test/init.pp @@ -0,0 +1 @@ +include ps1 \ No newline at end of file diff --git a/puppet/modules/timezone/.gitignore b/puppet/modules/timezone/.gitignore new file mode 100644 index 0000000..6ee20c2 --- /dev/null +++ b/puppet/modules/timezone/.gitignore @@ -0,0 +1,2 @@ +pkg/ +*.swp diff --git a/puppet/modules/timezone/LICENSE b/puppet/modules/timezone/LICENSE new file mode 100644 index 0000000..57bc88a --- /dev/null +++ b/puppet/modules/timezone/LICENSE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/puppet/modules/timezone/Modulefile b/puppet/modules/timezone/Modulefile new file mode 100644 index 0000000..e8f0cb9 --- /dev/null +++ b/puppet/modules/timezone/Modulefile @@ -0,0 +1,9 @@ +name 'saz-timezone' +version '1.1.0' + +author 'saz' +license 'Apache License, Version 2.0' +project_page 'https://github.com/saz/puppet-timezone' +source 'git://github.com/saz/puppet-timezone' +summary 'UNKNOWN' +description 'Manage timezone settings via Puppet' diff --git a/puppet/modules/timezone/README.md b/puppet/modules/timezone/README.md new file mode 100644 index 0000000..ce8443d --- /dev/null +++ b/puppet/modules/timezone/README.md @@ -0,0 +1,26 @@ +# puppet-timezone + +Manage timezone settings via Puppet + +## Usage + +### Set timezone to UTC +``` + class { 'timezone': + timezone => 'UTC', + } +``` + +### Set timezone to Europe/Berlin +``` + class { 'timezone': + timezone => 'Europe/Berlin', + } +``` + +## Other class parameters +* ensure: present or absent, default: present +* autoupgrade: true or false, default: false. Auto-upgrade package, if there is a newer version +* package: string, default: OS specific. Set package name, if platform is not supported. +* config_file: string, default: OS specific. Set config_file, if platform is not supported. +* zoneinfo_dir: string, default: OS specific. Set zoneinfo_dir, if platform is not supported. diff --git a/puppet/modules/timezone/manifests/init.pp b/puppet/modules/timezone/manifests/init.pp new file mode 100644 index 0000000..a570785 --- /dev/null +++ b/puppet/modules/timezone/manifests/init.pp @@ -0,0 +1,82 @@ +# Class: timezone +# +# This module manages timezone settings +# +# Parameters: +# [*timezone*] +# The name of the timezone. +# Default: UTC +# +# [*ensure*] +# Ensure if present or absent. +# Default: present +# +# [*autoupgrade*] +# Upgrade package automatically, if there is a newer version. +# Default: false +# +# [*package*] +# Name of the package. +# Only set this, if your platform is not supported or you know, what you're doing. +# Default: auto-set, platform specific +# +# [*config_file*] +# Main configuration file. +# Only set this, if your platform is not supported or you know, what you're doing. +# Default: auto-set, platform specific +# +# [*zoneinfo_dir*] +# Source directory of zoneinfo files. +# Only set this, if your platform is not supported or you know, what you're doing. +# Default: auto-set, platform specific +# +# Actions: +# Installs tzdata and configures timezone +# +# Requires: +# Nothing +# +# Sample Usage: +# class { 'timezone': +# timezone => 'Europe/Berlin', +# } +# +# [Remember: No empty lines between comments and class definition] +class timezone ( + $timezone = 'UTC', + $ensure = 'present', + $autoupgrade = false, + $package = $timezone::params::package, + $config_file = $timezone::params::config_file, + $zoneinfo_dir = $timezone::params::zoneinfo_dir +) inherits timezone::params { + + case $ensure { + /(present)/: { + if $autoupgrade == true { + $package_ensure = 'latest' + } else { + $package_ensure = 'present' + } + $config_ensure = 'link' + } + /(absent)/: { + # Leave package installed, as it is a system dependency + $package_ensure = 'present' + $config_ensure = 'absent' + } + default: { + fail('ensure parameter must be present or absent') + } + } + + package { $package: + ensure => $package_ensure, + } + + file { $config_file: + ensure => $config_ensure, + target => "${zoneinfo_dir}${timezone}", + require => Package[$package], + } +} diff --git a/puppet/modules/timezone/manifests/params.pp b/puppet/modules/timezone/manifests/params.pp new file mode 100644 index 0000000..8b037af --- /dev/null +++ b/puppet/modules/timezone/manifests/params.pp @@ -0,0 +1,12 @@ +class timezone::params { + case $::operatingsystem { + /(Ubuntu|Debian|Gentoo|CentOS|Amazon)/: { + $package = 'tzdata' + $zoneinfo_dir = '/usr/share/zoneinfo/' + $config_file = '/etc/localtime' + } + default: { + fail("Unsupported platform: ${::operatingsystem}") + } + } +} diff --git a/puppet/modules/timezone/spec/spec.opts b/puppet/modules/timezone/spec/spec.opts new file mode 100644 index 0000000..91cd642 --- /dev/null +++ b/puppet/modules/timezone/spec/spec.opts @@ -0,0 +1,6 @@ +--format +s +--colour +--loadby +mtime +--backtrace diff --git a/puppet/modules/timezone/spec/spec_helper.rb b/puppet/modules/timezone/spec/spec_helper.rb new file mode 100644 index 0000000..a4aeeae --- /dev/null +++ b/puppet/modules/timezone/spec/spec_helper.rb @@ -0,0 +1,18 @@ +require 'pathname' +dir = Pathname.new(__FILE__).parent +$LOAD_PATH.unshift(dir, dir + 'lib', dir + '../lib') + +require 'mocha' +require 'puppet' +gem 'rspec', '=1.2.9' +require 'spec/autorun' + +Spec::Runner.configure do |config| + config.mock_with :mocha +end + +# We need this because the RAL uses 'should' as a method. This +# allows us the same behaviour but with a different method name. +class Object + alias :must :should +end diff --git a/puppet/modules/timezone/tests/init.pp b/puppet/modules/timezone/tests/init.pp new file mode 100644 index 0000000..07794dc --- /dev/null +++ b/puppet/modules/timezone/tests/init.pp @@ -0,0 +1 @@ +include timezone diff --git a/puppet/modules/vim/README.md b/puppet/modules/vim/README.md new file mode 100644 index 0000000..39726ef --- /dev/null +++ b/puppet/modules/vim/README.md @@ -0,0 +1,2 @@ +puppet-vim +========== \ No newline at end of file diff --git a/puppet/modules/vim/files/vimrc.local b/puppet/modules/vim/files/vimrc.local new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/puppet/modules/vim/files/vimrc.local diff --git a/puppet/modules/vim/manifests/init.pp b/puppet/modules/vim/manifests/init.pp new file mode 100644 index 0000000..842ebb1 --- /dev/null +++ b/puppet/modules/vim/manifests/init.pp @@ -0,0 +1,17 @@ +class vim ( + $vim_file = 'puppet:///modules/vim/vimrc.local' + ) { + + file { 'editor_vim': + path => '/etc/profile.d/editor.sh', + ensure => present, + content => 'export EDITOR="vim"', + } + + file { 'vimrc': + path => '/etc/vim/vimrc.local', + ensure => present, + source => $vim_file + } + +} \ No newline at end of file diff --git a/puppet/modules/vim/test/init.pp b/puppet/modules/vim/test/init.pp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/puppet/modules/vim/test/init.pp -- libgit2 0.21.2