From 41f635afaa2d463091397753461ae4ae2f36ad03 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Wed, 15 Jan 2014 15:09:51 -0500 Subject: [PATCH 1/9] Untested code for week 1 --- .gitignore | 3 +++ .librarian/puppet/config | 2 ++ Puppetfile | 6 +++++ Puppetfile.lock | 18 +++++++++++++++ bootstrap.sh | 36 ++++++++++++++++++++++++++++++ files/index.html | 24 ++++++++++++++++++++ files/keys/atomaka | 1 + manifests/site.pp | 47 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 137 insertions(+) create mode 100644 .gitignore create mode 100644 .librarian/puppet/config create mode 100644 Puppetfile create mode 100644 Puppetfile.lock create mode 100644 bootstrap.sh create mode 100644 files/index.html create mode 100644 files/keys/atomaka create mode 100644 manifests/site.pp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b97414 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +modules/* +.tmp/ +modules/ diff --git a/.librarian/puppet/config b/.librarian/puppet/config new file mode 100644 index 0000000..8906163 --- /dev/null +++ b/.librarian/puppet/config @@ -0,0 +1,2 @@ +--- + LIBRARIAN_PUPPET_DESTRUCTIVE: "false" \ No newline at end of file diff --git a/Puppetfile b/Puppetfile new file mode 100644 index 0000000..3727900 --- /dev/null +++ b/Puppetfile @@ -0,0 +1,6 @@ +forge "http://forge.puppetlabs.com" + +mod 'camptocamp/augeas', '0.0.1' +mod 'puppetlabs/apache', '0.10.0' +mod 'saz/ssh', '1.2.0' + diff --git a/Puppetfile.lock b/Puppetfile.lock new file mode 100644 index 0000000..609d6e9 --- /dev/null +++ b/Puppetfile.lock @@ -0,0 +1,18 @@ +FORGE + remote: http://forge.puppetlabs.com + specs: + camptocamp/augeas (0.0.1) + puppetlabs/apache (0.10.0) + puppetlabs/concat (>= 1.0.0) + puppetlabs/stdlib (>= 2.4.0) + puppetlabs/concat (1.1.0-rc1) + puppetlabs/stdlib (>= 3.0.0) + puppetlabs/stdlib (4.1.0) + saz/ssh (1.2.0) + puppetlabs/stdlib (>= 2.2.1) + +DEPENDENCIES + camptocamp/augeas (= 0.0.1) + puppetlabs/apache (= 0.10.0) + saz/ssh (= 1.2.0) + diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100644 index 0000000..2cfe74f --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# TO BE RUN AS ROOT +if [[ $(/usr/bin/id -u) -ne 0 ]]; then + echo "This script must be run as root" + exit +fi + +# SET TIMESTAMP +echo "America/New_York" | tee /etc/timezone +dpkg-reconfigure --frontend noninteractive tzdata + +# UPGRADE ALL CURRENT PACKAGES +apt-get upgrade -y && apt-get dist-upgrade -y + +# INSTALL GIT +apt-get install git + +# INSTALL PUPPET +wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb +dpkg -i puppetlabs-release-precise.deb +apt-get update +apt-get install puppet -y + +gem install librarian-puppet + +# CLONE PUPPET REPOSITORY +cd /tmp +git clone https://github.com/atomaka/tc362.git puppet + +# INSTALL MODULES +cd puppet +librarian-puppet install + +# RUN MANIFEST +puppet manifest apply manifests/site.pp --modulepath=modules/ diff --git a/files/index.html b/files/index.html new file mode 100644 index 0000000..1e5a698 --- /dev/null +++ b/files/index.html @@ -0,0 +1,24 @@ + + + + + Hello World + + + + +

Hello World!

+ + diff --git a/files/keys/atomaka b/files/keys/atomaka new file mode 100644 index 0000000..bf1cf57 --- /dev/null +++ b/files/keys/atomaka @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDRwQ+1wZ4rSIQyAOG/G+4c9tKO4h716hQEiD95hw44TIQ4rdU1xqStEdV+vLgHpk/vFDC1gNlesRGh/PynEObPIbUdAypnSIg6qfLGCD0HcyGqU6dxzynQ8tgA23qLLMxGMG7kPjxSk3LVY6u+I/KHqArJjDqXcns7kN26LimJt4azHBI165Z7q+xuOtgDApdRecyvkIcjrl1oveHjOnVTZl1l78fqr1nTmvHkkeWGHxdM2IE2eFxGEpb6yyjNzxpX8JsFFXJiuq+fa+1Xj7dA3QZjV+BWUfhj2LSoOfWRgxy4oUhxfbDbOC+pBFWEKA1lDnRZ+nBIw1nXmF7hpBOx atomaka@gmail.com diff --git a/manifests/site.pp b/manifests/site.pp new file mode 100644 index 0000000..2a6127e --- /dev/null +++ b/manifests/site.pp @@ -0,0 +1,47 @@ +# USERS +user { 'atomaka': + ensure => 'present', + groups => ['sudo'], + managehome => true, + shell => '/bin/zsh', + require => Package['zsh'], +} +file { '/home/atomaka/.ssh': + ensure => directory, + owner => 'atomaka', + group => 'atomaka', + mode => '0700', + require => User['atomaka'], +} +file { '/home/atomaka/.ssh/authorized_keys': + ensure => present, + owner => 'atomaka', + group => 'atomaka', + mode => '0600', + content => file('/tmp/puppet/files/keys/atoamka'), + require => File['/home/atomaka/.ssh'], +} + +# PACKAGES +package { 'mosh': } +package { 'zsh': } + +# CLASSES +include augeas + +class { 'ssh::server': + require => Class['augeas'], +} +class { 'apache': } + +# CONFIGURATIONS +ssh::server::configline { 'PermitRootLogin': value => 'no' } +ssh::server::configline { 'PasswordAuthentication': value => 'no' } +ssh::server::configline { 'AllowUsers/1': value => 'atomaka' } + +# FILES +file { '/var/www/index.html': + ensure => present, + content => file('/tmp/puppet/files/index.html'), + require => Class['apache'], +} From 3d3b9844e82d39c5b94b2211a5263be4cbbe1866 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Wed, 15 Jan 2014 15:14:13 -0500 Subject: [PATCH 2/9] Fixes from first run * git should be force installed * rubygems not installed by default * puppet manifest = puppet apply --- bootstrap.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index 2cfe74f..71fe15d 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -14,7 +14,10 @@ dpkg-reconfigure --frontend noninteractive tzdata apt-get upgrade -y && apt-get dist-upgrade -y # INSTALL GIT -apt-get install git +apt-get install git -y + +# INSTALL RUBYGEMS +apt-get install rubygems -y # INSTALL PUPPET wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb @@ -33,4 +36,4 @@ cd puppet librarian-puppet install # RUN MANIFEST -puppet manifest apply manifests/site.pp --modulepath=modules/ +puppet apply manifests/site.pp --modulepath=modules/ From 45eb44b27f026a8204a10e157daf3f2d084be998 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Wed, 15 Jan 2014 15:29:46 -0500 Subject: [PATCH 3/9] Allow a specific branch to be checked out --- bootstrap.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bootstrap.sh b/bootstrap.sh index 71fe15d..5be7f24 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,5 +1,9 @@ #!/bin/bash +# BOOSTRAP SCRIPT +# Can take a single param to allow a specific branch to be installed +BRANCH=$1 + # TO BE RUN AS ROOT if [[ $(/usr/bin/id -u) -ne 0 ]]; then echo "This script must be run as root" @@ -29,8 +33,14 @@ gem install librarian-puppet # CLONE PUPPET REPOSITORY cd /tmp +rm -rf puppet git clone https://github.com/atomaka/tc362.git puppet +if [ "$BRANCH" != "" ]; then + git fetch + git checkout $BRANCH +fi + # INSTALL MODULES cd puppet librarian-puppet install From 1f64dd085f46fe6fc78afb5c3913c9b1437a1e4c Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Wed, 15 Jan 2014 15:32:26 -0500 Subject: [PATCH 4/9] Need to be in the correct directory --- bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.sh b/bootstrap.sh index 5be7f24..74c823e 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -35,6 +35,7 @@ gem install librarian-puppet cd /tmp rm -rf puppet git clone https://github.com/atomaka/tc362.git puppet +cd puppet if [ "$BRANCH" != "" ]; then git fetch @@ -42,7 +43,6 @@ if [ "$BRANCH" != "" ]; then fi # INSTALL MODULES -cd puppet librarian-puppet install # RUN MANIFEST From 6ba6bb5df1d5d07fb466c6ba0f2f67aff57d87f1 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Wed, 15 Jan 2014 15:34:42 -0500 Subject: [PATCH 5/9] Fix typo in name --- manifests/site.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/site.pp b/manifests/site.pp index 2a6127e..7218d29 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -18,7 +18,7 @@ file { '/home/atomaka/.ssh/authorized_keys': owner => 'atomaka', group => 'atomaka', mode => '0600', - content => file('/tmp/puppet/files/keys/atoamka'), + content => file('/tmp/puppet/files/keys/atomaka'), require => File['/home/atomaka/.ssh'], } From bfa8138774665f59c688f5f15fa2ba58a27b5baa Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Wed, 15 Jan 2014 15:47:28 -0500 Subject: [PATCH 6/9] Allow password-less sudo --- Puppetfile | 1 + Puppetfile.lock | 2 ++ manifests/site.pp | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/Puppetfile b/Puppetfile index 3727900..a8139da 100644 --- a/Puppetfile +++ b/Puppetfile @@ -3,4 +3,5 @@ forge "http://forge.puppetlabs.com" mod 'camptocamp/augeas', '0.0.1' mod 'puppetlabs/apache', '0.10.0' mod 'saz/ssh', '1.2.0' +mod 'saz/sudo', '2.4.3' diff --git a/Puppetfile.lock b/Puppetfile.lock index 609d6e9..38aec92 100644 --- a/Puppetfile.lock +++ b/Puppetfile.lock @@ -10,9 +10,11 @@ FORGE puppetlabs/stdlib (4.1.0) saz/ssh (1.2.0) puppetlabs/stdlib (>= 2.2.1) + saz/sudo (2.4.3) DEPENDENCIES camptocamp/augeas (= 0.0.1) puppetlabs/apache (= 0.10.0) saz/ssh (= 1.2.0) + saz/sudo (= 2.4.3) diff --git a/manifests/site.pp b/manifests/site.pp index 7218d29..2e138c3 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -28,6 +28,7 @@ package { 'zsh': } # CLASSES include augeas +include sudo class { 'ssh::server': require => Class['augeas'], @@ -39,6 +40,11 @@ ssh::server::configline { 'PermitRootLogin': value => 'no' } ssh::server::configline { 'PasswordAuthentication': value => 'no' } ssh::server::configline { 'AllowUsers/1': value => 'atomaka' } +sudo::conf { 'sudo': + priority => 10, + content => "%sudo ALL=(ALL) NOPASSWD: ALL\n", +} + # FILES file { '/var/www/index.html': ensure => present, From 77bc101271cfbf05a11856b47cdb1161253dea98 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Wed, 15 Jan 2014 16:10:47 -0500 Subject: [PATCH 7/9] Create hello world template --- files/index.html | 62 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/files/index.html b/files/index.html index 1e5a698..87f10c2 100644 --- a/files/index.html +++ b/files/index.html @@ -4,21 +4,65 @@ Hello World + - -

Hello World!

+
+ [16:01:42] + atomaka@162.243.226.212 + ~
+ |-> Hello World +
+
+ [16:02:10] + atomaka@162.243.226.212 + ~
+ |->   +
From d6e060bbcfdb587de48774d9bc8c1e98e66fcd13 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Wed, 15 Jan 2014 16:13:15 -0500 Subject: [PATCH 8/9] Add faux shell error message --- files/index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/files/index.html b/files/index.html index 87f10c2..66c8435 100644 --- a/files/index.html +++ b/files/index.html @@ -56,7 +56,8 @@ [16:01:42] atomaka@162.243.226.212 ~
- |-> Hello World + |-> Hello World
+ zsh: command not found: Hello
[16:02:10] From 9fcc4fcea9b64b3b1308238cbc7c36ff2dd5394f Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Wed, 15 Jan 2014 16:45:04 -0500 Subject: [PATCH 9/9] Add required hello.txt file with IP --- week1/hello.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 week1/hello.txt diff --git a/week1/hello.txt b/week1/hello.txt new file mode 100644 index 0000000..36e741c --- /dev/null +++ b/week1/hello.txt @@ -0,0 +1,4 @@ +162.243.226.212 + +The rest of the week 1 lab assignment can be found in branch +atomaka/feature/week1 and tagged Week 1.