Commit af35b8956f01e6411cb5a8604aa0ba2f4836fd30
1 parent
133f0c6d
Exists in
master
and in
39 other branches
Adding vagrant and initial provisioning to colab
Showing
35 changed files
with
725 additions
and
0 deletions
Show diff stats
.gitignore
@@ -0,0 +1,84 @@ | @@ -0,0 +1,84 @@ | ||
1 | +# -*- mode: ruby -*- | ||
2 | +# vi: set ft=ruby : | ||
3 | + | ||
4 | +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | ||
5 | +VAGRANTFILE_API_VERSION = "2" | ||
6 | + | ||
7 | +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | ||
8 | + # All Vagrant configuration is done here. The most common configuration | ||
9 | + # options are documented and commented below. For a complete reference, | ||
10 | + # please see the online documentation at vagrantup.com. | ||
11 | + | ||
12 | + # Every Vagrant virtual environment requires a box to build off of. | ||
13 | + config.vm.box = "precise64" | ||
14 | + | ||
15 | + # The url from where the 'config.vm.box' box will be fetched if it | ||
16 | + # doesn't already exist on the user's system. | ||
17 | + config.vm.box_url = "http://files.vagrantup.com/precise64.box" | ||
18 | + | ||
19 | + # Create a forwarded port mapping which allows access to a specific port | ||
20 | + # within the machine from a port on the host machine. In the example below, | ||
21 | + # accessing "localhost:8080" will access port 80 on the guest machine. | ||
22 | + config.vm.network :forwarded_port, guest: 80, host: 8080 | ||
23 | + config.vm.network :forwarded_port, guest: 8000, host: 8000 | ||
24 | + | ||
25 | + # Create a private network, which allows host-only access to the machine | ||
26 | + # using a specific IP. | ||
27 | + # config.vm.network :private_network, ip: "192.168.33.10" | ||
28 | + | ||
29 | + # Create a public network, which generally matched to bridged network. | ||
30 | + # Bridged networks make the machine appear as another physical device on | ||
31 | + # your network. | ||
32 | + # config.vm.network :public_network | ||
33 | + | ||
34 | + # If true, then any SSH connections made will enable agent forwarding. | ||
35 | + # Default value: false | ||
36 | + # config.ssh.forward_agent = true | ||
37 | + | ||
38 | + # Share an additional folder to the guest VM. The first argument is | ||
39 | + # the path on the host to the actual folder. The second argument is | ||
40 | + # the path on the guest to mount the folder. And the optional third | ||
41 | + # argument is a set of non-required options. | ||
42 | + # config.vm.synced_folder "../data", "/vagrant_data" | ||
43 | + | ||
44 | + # Provider-specific configuration so you can fine-tune various | ||
45 | + # backing providers for Vagrant. These expose provider-specific options. | ||
46 | + # Example for VirtualBox: | ||
47 | + # | ||
48 | + # config.vm.provider :virtualbox do |vb| | ||
49 | + # # Don't boot with headless mode | ||
50 | + # vb.gui = true | ||
51 | + # | ||
52 | + # # Use VBoxManage to customize the VM. For example to change memory: | ||
53 | + # vb.customize ["modifyvm", :id, "--memory", "1024"] | ||
54 | + # end | ||
55 | + # | ||
56 | + # View the documentation for the provider you're using for more | ||
57 | + # information on available options. | ||
58 | + | ||
59 | + config.vm.provision :shell, :path => "puppet/bootstrap.sh" | ||
60 | + | ||
61 | + # Enable provisioning with Puppet stand alone. Puppet manifests | ||
62 | + # are contained in a directory path relative to this Vagrantfile. | ||
63 | + # You will need to create the manifests directory and a manifest in | ||
64 | + # the file base.pp in the manifests_path directory. | ||
65 | + # | ||
66 | + # An example Puppet manifest to provision the message of the day: | ||
67 | + # | ||
68 | + # # group { "puppet": | ||
69 | + # # ensure => "present", | ||
70 | + # # } | ||
71 | + # # | ||
72 | + # # File { owner => 0, group => 0, mode => 0644 } | ||
73 | + # # | ||
74 | + # # file { '/etc/motd': | ||
75 | + # # content => "Welcome to your Vagrant-built virtual machine! | ||
76 | + # # Managed by Puppet.\n" | ||
77 | + # # } | ||
78 | + # | ||
79 | + config.vm.provision :puppet do |puppet| | ||
80 | + puppet.module_path = "puppet/modules" | ||
81 | + puppet.manifests_path = "puppet/manifests" | ||
82 | + puppet.manifest_file = "init.pp" | ||
83 | + end | ||
84 | +end |
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +#!/bin/bash | ||
2 | + | ||
3 | +PUPPET_VERSION=`dpkg -l | grep puppet-common | awk '{ print $3 }'` | ||
4 | + | ||
5 | +if [ "$PUPPET_VERSION" != '3.2.3-1puppetlabs1' ] ; then | ||
6 | + wget -O /tmp/puppet_apt.deb http://apt.puppetlabs.com/puppetlabs-release-precise.deb &> /dev/null | ||
7 | + dpkg -i /tmp/puppet_apt.deb | ||
8 | + DEBIAN_FRONTEND=noninteractive apt-get update -y | ||
9 | + DEBIAN_FRONTEND=noninteractive apt-get install puppet -y | ||
10 | +fi | ||
11 | + | ||
12 | +cp /vagrant/puppet/hiera.yaml /etc/puppet/hiera.yaml -f |
@@ -0,0 +1,56 @@ | @@ -0,0 +1,56 @@ | ||
1 | +class locale ( | ||
2 | + $locales = 'en_US.UTF-8 pt_BR', | ||
3 | + $lang = 'en_US.UTF-8', | ||
4 | + $language = 'en_US' | ||
5 | +) { | ||
6 | + | ||
7 | + Exec { | ||
8 | + path => ['/usr/bin', '/usr/sbin', '/bin'] | ||
9 | + } | ||
10 | + | ||
11 | + file { '/var/cache/locale': | ||
12 | + ensure => directory, | ||
13 | + mode => '0755', | ||
14 | + owner => 'root', | ||
15 | + } | ||
16 | + | ||
17 | + file { '/var/cache/locale/installed': | ||
18 | + ensure => present, | ||
19 | + mode => '0644', | ||
20 | + owner => 'root', | ||
21 | + content => "${locales}-${lang}-${language}", | ||
22 | + require => File['/var/cache/locale'], | ||
23 | + } | ||
24 | + | ||
25 | + exec { 'install_locales': | ||
26 | + command => "locale-gen ${locales}", | ||
27 | + refreshonly => true, | ||
28 | + subscribe => File['/var/cache/locale/installed'], | ||
29 | + notify => Exec['reload_locales'] | ||
30 | + } | ||
31 | + | ||
32 | + if $lang { | ||
33 | + exec { 'update_default_lang': | ||
34 | + command => "update-locale LANG='${lang}'", | ||
35 | + notify => Exec['reload_locales'], | ||
36 | + refreshonly => true, | ||
37 | + subscribe => File['/var/cache/locale/installed'], | ||
38 | + } | ||
39 | + } | ||
40 | + | ||
41 | + if $language { | ||
42 | + exec { 'update_default_language': | ||
43 | + command => "update-locale LANGUAGE='${language}'", | ||
44 | + notify => Exec['reload_locales'], | ||
45 | + refreshonly => true, | ||
46 | + subscribe => File['/var/cache/locale/installed'], | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
50 | + exec { 'reload_locales': | ||
51 | + command => "dpkg-reconfigure locales", | ||
52 | + refreshonly => true | ||
53 | + } | ||
54 | + | ||
55 | +} | ||
56 | + |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +Puppet ntp | ||
2 | +========== | ||
3 | +Start a cronjob to run every hour ntpdate | ||
4 | + | ||
5 | +Usage | ||
6 | +========== | ||
7 | + | ||
8 | +```puppet | ||
9 | +include ntp # Use default server (pool.ntp.org) or your hiera config (puppet 3+) | ||
10 | +``` | ||
11 | +or | ||
12 | +```puppet | ||
13 | +class { 'ntp': | ||
14 | + server => 'your ntp server' | ||
15 | +} | ||
16 | +``` | ||
0 | \ No newline at end of file | 17 | \ No newline at end of file |
@@ -0,0 +1,15 @@ | @@ -0,0 +1,15 @@ | ||
1 | + | ||
2 | +class ntp ( | ||
3 | + $server='pool.ntp.org', | ||
4 | +){ | ||
5 | + package { 'ntpdate': | ||
6 | + ensure => installed, | ||
7 | + } | ||
8 | + | ||
9 | + cron { 'ntpdate': | ||
10 | + command => "/usr/sbin/ntpdate $server > /dev/null", | ||
11 | + user => 'root', | ||
12 | + minute => '0', | ||
13 | + require => Package['ntpdate'], | ||
14 | + } | ||
15 | +} |
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +include ntp |
@@ -0,0 +1,41 @@ | @@ -0,0 +1,41 @@ | ||
1 | + | ||
2 | +class postfix ( | ||
3 | + $admin_email, | ||
4 | + $server_name=$fqdn, | ||
5 | + $mailbox_limit=0 # Zero means no limit | ||
6 | +) { | ||
7 | + | ||
8 | + $postfix_preseed = '/var/cache/debconf/postfix.preseed' | ||
9 | + $preseed_cmd = "debconf-set-selections $postfix_preseed" | ||
10 | + | ||
11 | + file { $postfix_preseed: | ||
12 | + ensure => present, | ||
13 | + content => template('postfix/postfix.preseed.erb'), | ||
14 | + } | ||
15 | + | ||
16 | + exec { $preseed_cmd: | ||
17 | + path => '/usr/bin/', | ||
18 | + refreshonly => true, | ||
19 | + subscribe => File[$postfix_preseed], | ||
20 | + } | ||
21 | + | ||
22 | + package { 'postfix': | ||
23 | + ensure => installed, | ||
24 | + require => File[$postfix_preseed], | ||
25 | + responsefile => $postfix_preseed, | ||
26 | + } | ||
27 | + | ||
28 | + package { 'mailutils': | ||
29 | + ensure => installed, | ||
30 | + } | ||
31 | + | ||
32 | + service {'postfix': | ||
33 | + ensure => running, | ||
34 | + enable => true, | ||
35 | + hasstatus => false, | ||
36 | + stop => 'invoke-rc.d postfix stop', | ||
37 | + start => 'invoke-rc.d postfix start', | ||
38 | + restart => 'invoke-rc.d postfix restart', | ||
39 | + require => Package['postfix'] | ||
40 | + } | ||
41 | +} |
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +postfix postfix/root_address string <%= @admin_email %> | ||
2 | +postfix postfix/rfc1035_violation boolean false | ||
3 | +postfix postfix/mydomain_warning boolean | ||
4 | +postfix postfix/mynetworks string | ||
5 | +postfix postfix/mailname string <%= @server_name %> | ||
6 | +postfix postfix/tlsmgr_upgrade_warning boolean | ||
7 | +postfix postfix/recipient_delim string | ||
8 | +postfix postfix/main_mailer_type select Internet Site | ||
9 | +postfix postfix/destinations string localhost, <%= @fqdn %>, <%= @hostname %> | ||
10 | +postfix postfix/retry_upgrade_warning boolean | ||
11 | +postfix postfix/kernel_version_warning boolean | ||
12 | +postfix postfix/sqlite_warning boolean | ||
13 | +postfix postfix/mailbox_limit string <%= @mailbox_limit %> | ||
14 | +postfix postfix/relayhost string | ||
15 | +postfix postfix/procmail boolean false | ||
16 | +postfix postfix/protocols select all | ||
17 | +postfix postfix/chattr boolean false |
@@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
1 | +class ps1 ( | ||
2 | + $color = 'red' | ||
3 | +) { | ||
4 | + $color_code = $color ? { | ||
5 | + 'red' => '1', | ||
6 | + 'green' => '2', | ||
7 | + 'yellow' => '3', | ||
8 | + default => '1' | ||
9 | + } | ||
10 | + | ||
11 | + $force_color_prompt_cmd = "/bin/sed -i -re '/force_color_prompt=yes/ s/^#//'" | ||
12 | + $force_color_prompt_condition = '/bin/grep "#force_color_prompt"' | ||
13 | + | ||
14 | + $ps1_color_cmd = "/bin/sed -i -re 's/01;3[1-3]m/01;3${color_code}m/'" | ||
15 | + $ps1_color_condition = "/bin/grep '01;3${color_code}m'" | ||
16 | + | ||
17 | + $skel_path = '/etc/skel/.bashrc' | ||
18 | + $root_path = '/root/.bashrc' | ||
19 | + | ||
20 | + # uncomment force_color_prompt in skel | ||
21 | + exec { "$force_color_prompt_cmd $skel_path": | ||
22 | + onlyif => "$force_color_prompt_condition $skel_path" | ||
23 | + } | ||
24 | + # uncomment force_color_prompt in root | ||
25 | + exec { "$force_color_prompt_cmd $root_path": | ||
26 | + onlyif => "$force_color_prompt_condition $root_path" | ||
27 | + } | ||
28 | + | ||
29 | + # change prompt color in skel | ||
30 | + exec { "$ps1_color_cmd $skel_path": | ||
31 | + unless => "$ps1_color_condition $skel_path", | ||
32 | + } | ||
33 | + # change prompt color in root | ||
34 | + exec { "$ps1_color_cmd $root_path": | ||
35 | + unless => "$ps1_color_condition $root_path", | ||
36 | + } | ||
37 | +} |
@@ -0,0 +1,202 @@ | @@ -0,0 +1,202 @@ | ||
1 | + Apache License | ||
2 | + Version 2.0, January 2004 | ||
3 | + http://www.apache.org/licenses/ | ||
4 | + | ||
5 | + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION | ||
6 | + | ||
7 | + 1. Definitions. | ||
8 | + | ||
9 | + "License" shall mean the terms and conditions for use, reproduction, | ||
10 | + and distribution as defined by Sections 1 through 9 of this document. | ||
11 | + | ||
12 | + "Licensor" shall mean the copyright owner or entity authorized by | ||
13 | + the copyright owner that is granting the License. | ||
14 | + | ||
15 | + "Legal Entity" shall mean the union of the acting entity and all | ||
16 | + other entities that control, are controlled by, or are under common | ||
17 | + control with that entity. For the purposes of this definition, | ||
18 | + "control" means (i) the power, direct or indirect, to cause the | ||
19 | + direction or management of such entity, whether by contract or | ||
20 | + otherwise, or (ii) ownership of fifty percent (50%) or more of the | ||
21 | + outstanding shares, or (iii) beneficial ownership of such entity. | ||
22 | + | ||
23 | + "You" (or "Your") shall mean an individual or Legal Entity | ||
24 | + exercising permissions granted by this License. | ||
25 | + | ||
26 | + "Source" form shall mean the preferred form for making modifications, | ||
27 | + including but not limited to software source code, documentation | ||
28 | + source, and configuration files. | ||
29 | + | ||
30 | + "Object" form shall mean any form resulting from mechanical | ||
31 | + transformation or translation of a Source form, including but | ||
32 | + not limited to compiled object code, generated documentation, | ||
33 | + and conversions to other media types. | ||
34 | + | ||
35 | + "Work" shall mean the work of authorship, whether in Source or | ||
36 | + Object form, made available under the License, as indicated by a | ||
37 | + copyright notice that is included in or attached to the work | ||
38 | + (an example is provided in the Appendix below). | ||
39 | + | ||
40 | + "Derivative Works" shall mean any work, whether in Source or Object | ||
41 | + form, that is based on (or derived from) the Work and for which the | ||
42 | + editorial revisions, annotations, elaborations, or other modifications | ||
43 | + represent, as a whole, an original work of authorship. For the purposes | ||
44 | + of this License, Derivative Works shall not include works that remain | ||
45 | + separable from, or merely link (or bind by name) to the interfaces of, | ||
46 | + the Work and Derivative Works thereof. | ||
47 | + | ||
48 | + "Contribution" shall mean any work of authorship, including | ||
49 | + the original version of the Work and any modifications or additions | ||
50 | + to that Work or Derivative Works thereof, that is intentionally | ||
51 | + submitted to Licensor for inclusion in the Work by the copyright owner | ||
52 | + or by an individual or Legal Entity authorized to submit on behalf of | ||
53 | + the copyright owner. For the purposes of this definition, "submitted" | ||
54 | + means any form of electronic, verbal, or written communication sent | ||
55 | + to the Licensor or its representatives, including but not limited to | ||
56 | + communication on electronic mailing lists, source code control systems, | ||
57 | + and issue tracking systems that are managed by, or on behalf of, the | ||
58 | + Licensor for the purpose of discussing and improving the Work, but | ||
59 | + excluding communication that is conspicuously marked or otherwise | ||
60 | + designated in writing by the copyright owner as "Not a Contribution." | ||
61 | + | ||
62 | + "Contributor" shall mean Licensor and any individual or Legal Entity | ||
63 | + on behalf of whom a Contribution has been received by Licensor and | ||
64 | + subsequently incorporated within the Work. | ||
65 | + | ||
66 | + 2. Grant of Copyright License. Subject to the terms and conditions of | ||
67 | + this License, each Contributor hereby grants to You a perpetual, | ||
68 | + worldwide, non-exclusive, no-charge, royalty-free, irrevocable | ||
69 | + copyright license to reproduce, prepare Derivative Works of, | ||
70 | + publicly display, publicly perform, sublicense, and distribute the | ||
71 | + Work and such Derivative Works in Source or Object form. | ||
72 | + | ||
73 | + 3. Grant of Patent License. Subject to the terms and conditions of | ||
74 | + this License, each Contributor hereby grants to You a perpetual, | ||
75 | + worldwide, non-exclusive, no-charge, royalty-free, irrevocable | ||
76 | + (except as stated in this section) patent license to make, have made, | ||
77 | + use, offer to sell, sell, import, and otherwise transfer the Work, | ||
78 | + where such license applies only to those patent claims licensable | ||
79 | + by such Contributor that are necessarily infringed by their | ||
80 | + Contribution(s) alone or by combination of their Contribution(s) | ||
81 | + with the Work to which such Contribution(s) was submitted. If You | ||
82 | + institute patent litigation against any entity (including a | ||
83 | + cross-claim or counterclaim in a lawsuit) alleging that the Work | ||
84 | + or a Contribution incorporated within the Work constitutes direct | ||
85 | + or contributory patent infringement, then any patent licenses | ||
86 | + granted to You under this License for that Work shall terminate | ||
87 | + as of the date such litigation is filed. | ||
88 | + | ||
89 | + 4. Redistribution. You may reproduce and distribute copies of the | ||
90 | + Work or Derivative Works thereof in any medium, with or without | ||
91 | + modifications, and in Source or Object form, provided that You | ||
92 | + meet the following conditions: | ||
93 | + | ||
94 | + (a) You must give any other recipients of the Work or | ||
95 | + Derivative Works a copy of this License; and | ||
96 | + | ||
97 | + (b) You must cause any modified files to carry prominent notices | ||
98 | + stating that You changed the files; and | ||
99 | + | ||
100 | + (c) You must retain, in the Source form of any Derivative Works | ||
101 | + that You distribute, all copyright, patent, trademark, and | ||
102 | + attribution notices from the Source form of the Work, | ||
103 | + excluding those notices that do not pertain to any part of | ||
104 | + the Derivative Works; and | ||
105 | + | ||
106 | + (d) If the Work includes a "NOTICE" text file as part of its | ||
107 | + distribution, then any Derivative Works that You distribute must | ||
108 | + include a readable copy of the attribution notices contained | ||
109 | + within such NOTICE file, excluding those notices that do not | ||
110 | + pertain to any part of the Derivative Works, in at least one | ||
111 | + of the following places: within a NOTICE text file distributed | ||
112 | + as part of the Derivative Works; within the Source form or | ||
113 | + documentation, if provided along with the Derivative Works; or, | ||
114 | + within a display generated by the Derivative Works, if and | ||
115 | + wherever such third-party notices normally appear. The contents | ||
116 | + of the NOTICE file are for informational purposes only and | ||
117 | + do not modify the License. You may add Your own attribution | ||
118 | + notices within Derivative Works that You distribute, alongside | ||
119 | + or as an addendum to the NOTICE text from the Work, provided | ||
120 | + that such additional attribution notices cannot be construed | ||
121 | + as modifying the License. | ||
122 | + | ||
123 | + You may add Your own copyright statement to Your modifications and | ||
124 | + may provide additional or different license terms and conditions | ||
125 | + for use, reproduction, or distribution of Your modifications, or | ||
126 | + for any such Derivative Works as a whole, provided Your use, | ||
127 | + reproduction, and distribution of the Work otherwise complies with | ||
128 | + the conditions stated in this License. | ||
129 | + | ||
130 | + 5. Submission of Contributions. Unless You explicitly state otherwise, | ||
131 | + any Contribution intentionally submitted for inclusion in the Work | ||
132 | + by You to the Licensor shall be under the terms and conditions of | ||
133 | + this License, without any additional terms or conditions. | ||
134 | + Notwithstanding the above, nothing herein shall supersede or modify | ||
135 | + the terms of any separate license agreement you may have executed | ||
136 | + with Licensor regarding such Contributions. | ||
137 | + | ||
138 | + 6. Trademarks. This License does not grant permission to use the trade | ||
139 | + names, trademarks, service marks, or product names of the Licensor, | ||
140 | + except as required for reasonable and customary use in describing the | ||
141 | + origin of the Work and reproducing the content of the NOTICE file. | ||
142 | + | ||
143 | + 7. Disclaimer of Warranty. Unless required by applicable law or | ||
144 | + agreed to in writing, Licensor provides the Work (and each | ||
145 | + Contributor provides its Contributions) on an "AS IS" BASIS, | ||
146 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
147 | + implied, including, without limitation, any warranties or conditions | ||
148 | + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A | ||
149 | + PARTICULAR PURPOSE. You are solely responsible for determining the | ||
150 | + appropriateness of using or redistributing the Work and assume any | ||
151 | + risks associated with Your exercise of permissions under this License. | ||
152 | + | ||
153 | + 8. Limitation of Liability. In no event and under no legal theory, | ||
154 | + whether in tort (including negligence), contract, or otherwise, | ||
155 | + unless required by applicable law (such as deliberate and grossly | ||
156 | + negligent acts) or agreed to in writing, shall any Contributor be | ||
157 | + liable to You for damages, including any direct, indirect, special, | ||
158 | + incidental, or consequential damages of any character arising as a | ||
159 | + result of this License or out of the use or inability to use the | ||
160 | + Work (including but not limited to damages for loss of goodwill, | ||
161 | + work stoppage, computer failure or malfunction, or any and all | ||
162 | + other commercial damages or losses), even if such Contributor | ||
163 | + has been advised of the possibility of such damages. | ||
164 | + | ||
165 | + 9. Accepting Warranty or Additional Liability. While redistributing | ||
166 | + the Work or Derivative Works thereof, You may choose to offer, | ||
167 | + and charge a fee for, acceptance of support, warranty, indemnity, | ||
168 | + or other liability obligations and/or rights consistent with this | ||
169 | + License. However, in accepting such obligations, You may act only | ||
170 | + on Your own behalf and on Your sole responsibility, not on behalf | ||
171 | + of any other Contributor, and only if You agree to indemnify, | ||
172 | + defend, and hold each Contributor harmless for any liability | ||
173 | + incurred by, or claims asserted against, such Contributor by reason | ||
174 | + of your accepting any such warranty or additional liability. | ||
175 | + | ||
176 | + END OF TERMS AND CONDITIONS | ||
177 | + | ||
178 | + APPENDIX: How to apply the Apache License to your work. | ||
179 | + | ||
180 | + To apply the Apache License to your work, attach the following | ||
181 | + boilerplate notice, with the fields enclosed by brackets "[]" | ||
182 | + replaced with your own identifying information. (Don't include | ||
183 | + the brackets!) The text should be enclosed in the appropriate | ||
184 | + comment syntax for the file format. We also recommend that a | ||
185 | + file or class name and description of purpose be included on the | ||
186 | + same "printed page" as the copyright notice for easier | ||
187 | + identification within third-party archives. | ||
188 | + | ||
189 | + Copyright [yyyy] [name of copyright owner] | ||
190 | + | ||
191 | + Licensed under the Apache License, Version 2.0 (the "License"); | ||
192 | + you may not use this file except in compliance with the License. | ||
193 | + You may obtain a copy of the License at | ||
194 | + | ||
195 | + http://www.apache.org/licenses/LICENSE-2.0 | ||
196 | + | ||
197 | + Unless required by applicable law or agreed to in writing, software | ||
198 | + distributed under the License is distributed on an "AS IS" BASIS, | ||
199 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
200 | + See the License for the specific language governing permissions and | ||
201 | + limitations under the License. | ||
202 | + |
@@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
1 | +name 'saz-timezone' | ||
2 | +version '1.1.0' | ||
3 | + | ||
4 | +author 'saz' | ||
5 | +license 'Apache License, Version 2.0' | ||
6 | +project_page 'https://github.com/saz/puppet-timezone' | ||
7 | +source 'git://github.com/saz/puppet-timezone' | ||
8 | +summary 'UNKNOWN' | ||
9 | +description 'Manage timezone settings via Puppet' |
@@ -0,0 +1,26 @@ | @@ -0,0 +1,26 @@ | ||
1 | +# puppet-timezone | ||
2 | + | ||
3 | +Manage timezone settings via Puppet | ||
4 | + | ||
5 | +## Usage | ||
6 | + | ||
7 | +### Set timezone to UTC | ||
8 | +``` | ||
9 | + class { 'timezone': | ||
10 | + timezone => 'UTC', | ||
11 | + } | ||
12 | +``` | ||
13 | + | ||
14 | +### Set timezone to Europe/Berlin | ||
15 | +``` | ||
16 | + class { 'timezone': | ||
17 | + timezone => 'Europe/Berlin', | ||
18 | + } | ||
19 | +``` | ||
20 | + | ||
21 | +## Other class parameters | ||
22 | +* ensure: present or absent, default: present | ||
23 | +* autoupgrade: true or false, default: false. Auto-upgrade package, if there is a newer version | ||
24 | +* package: string, default: OS specific. Set package name, if platform is not supported. | ||
25 | +* config_file: string, default: OS specific. Set config_file, if platform is not supported. | ||
26 | +* zoneinfo_dir: string, default: OS specific. Set zoneinfo_dir, if platform is not supported. |
@@ -0,0 +1,82 @@ | @@ -0,0 +1,82 @@ | ||
1 | +# Class: timezone | ||
2 | +# | ||
3 | +# This module manages timezone settings | ||
4 | +# | ||
5 | +# Parameters: | ||
6 | +# [*timezone*] | ||
7 | +# The name of the timezone. | ||
8 | +# Default: UTC | ||
9 | +# | ||
10 | +# [*ensure*] | ||
11 | +# Ensure if present or absent. | ||
12 | +# Default: present | ||
13 | +# | ||
14 | +# [*autoupgrade*] | ||
15 | +# Upgrade package automatically, if there is a newer version. | ||
16 | +# Default: false | ||
17 | +# | ||
18 | +# [*package*] | ||
19 | +# Name of the package. | ||
20 | +# Only set this, if your platform is not supported or you know, what you're doing. | ||
21 | +# Default: auto-set, platform specific | ||
22 | +# | ||
23 | +# [*config_file*] | ||
24 | +# Main configuration file. | ||
25 | +# Only set this, if your platform is not supported or you know, what you're doing. | ||
26 | +# Default: auto-set, platform specific | ||
27 | +# | ||
28 | +# [*zoneinfo_dir*] | ||
29 | +# Source directory of zoneinfo files. | ||
30 | +# Only set this, if your platform is not supported or you know, what you're doing. | ||
31 | +# Default: auto-set, platform specific | ||
32 | +# | ||
33 | +# Actions: | ||
34 | +# Installs tzdata and configures timezone | ||
35 | +# | ||
36 | +# Requires: | ||
37 | +# Nothing | ||
38 | +# | ||
39 | +# Sample Usage: | ||
40 | +# class { 'timezone': | ||
41 | +# timezone => 'Europe/Berlin', | ||
42 | +# } | ||
43 | +# | ||
44 | +# [Remember: No empty lines between comments and class definition] | ||
45 | +class timezone ( | ||
46 | + $timezone = 'UTC', | ||
47 | + $ensure = 'present', | ||
48 | + $autoupgrade = false, | ||
49 | + $package = $timezone::params::package, | ||
50 | + $config_file = $timezone::params::config_file, | ||
51 | + $zoneinfo_dir = $timezone::params::zoneinfo_dir | ||
52 | +) inherits timezone::params { | ||
53 | + | ||
54 | + case $ensure { | ||
55 | + /(present)/: { | ||
56 | + if $autoupgrade == true { | ||
57 | + $package_ensure = 'latest' | ||
58 | + } else { | ||
59 | + $package_ensure = 'present' | ||
60 | + } | ||
61 | + $config_ensure = 'link' | ||
62 | + } | ||
63 | + /(absent)/: { | ||
64 | + # Leave package installed, as it is a system dependency | ||
65 | + $package_ensure = 'present' | ||
66 | + $config_ensure = 'absent' | ||
67 | + } | ||
68 | + default: { | ||
69 | + fail('ensure parameter must be present or absent') | ||
70 | + } | ||
71 | + } | ||
72 | + | ||
73 | + package { $package: | ||
74 | + ensure => $package_ensure, | ||
75 | + } | ||
76 | + | ||
77 | + file { $config_file: | ||
78 | + ensure => $config_ensure, | ||
79 | + target => "${zoneinfo_dir}${timezone}", | ||
80 | + require => Package[$package], | ||
81 | + } | ||
82 | +} |
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +class timezone::params { | ||
2 | + case $::operatingsystem { | ||
3 | + /(Ubuntu|Debian|Gentoo|CentOS|Amazon)/: { | ||
4 | + $package = 'tzdata' | ||
5 | + $zoneinfo_dir = '/usr/share/zoneinfo/' | ||
6 | + $config_file = '/etc/localtime' | ||
7 | + } | ||
8 | + default: { | ||
9 | + fail("Unsupported platform: ${::operatingsystem}") | ||
10 | + } | ||
11 | + } | ||
12 | +} |
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
1 | +require 'pathname' | ||
2 | +dir = Pathname.new(__FILE__).parent | ||
3 | +$LOAD_PATH.unshift(dir, dir + 'lib', dir + '../lib') | ||
4 | + | ||
5 | +require 'mocha' | ||
6 | +require 'puppet' | ||
7 | +gem 'rspec', '=1.2.9' | ||
8 | +require 'spec/autorun' | ||
9 | + | ||
10 | +Spec::Runner.configure do |config| | ||
11 | + config.mock_with :mocha | ||
12 | +end | ||
13 | + | ||
14 | +# We need this because the RAL uses 'should' as a method. This | ||
15 | +# allows us the same behaviour but with a different method name. | ||
16 | +class Object | ||
17 | + alias :must :should | ||
18 | +end |
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +include timezone |
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +class vim ( | ||
2 | + $vim_file = 'puppet:///modules/vim/vimrc.local' | ||
3 | + ) { | ||
4 | + | ||
5 | + file { 'editor_vim': | ||
6 | + path => '/etc/profile.d/editor.sh', | ||
7 | + ensure => present, | ||
8 | + content => 'export EDITOR="vim"', | ||
9 | + } | ||
10 | + | ||
11 | + file { 'vimrc': | ||
12 | + path => '/etc/vim/vimrc.local', | ||
13 | + ensure => present, | ||
14 | + source => $vim_file | ||
15 | + } | ||
16 | + | ||
17 | +} | ||
0 | \ No newline at end of file | 18 | \ No newline at end of file |