Faidon Liambotis has submitted this change and it was merged.

Change subject: install-server: replace lighttpd with nginx
......................................................................


install-server: replace lighttpd with nginx

nginx won the event-based-webservers war and we're already using it
widely in other parts of the infrastructure. Kill lighttpd here.

This doesn't handle the replacement gracefully within puppet and will
fail if applied directly since both servers will try to bind to port 80.
Since the class is only applied in one host (carbon), it's just simpler
to do it manually.

Update the RSpecs to test for the /srv/index.html file and update the
Rakefile to use wmflib and nginx module.

Change-Id: I71ca70321f847ffc6423b827033650407d82c7ef
---
M modules/install-server/Rakefile
D modules/install-server/files/lighttpd.conf
D modules/install-server/files/logrotate-lighttpd
A modules/install-server/files/nginx.conf
M modules/install-server/manifests/web-server.pp
M modules/install-server/spec/classes/install_server_web_server_spec.rb
6 files changed, 39 insertions(+), 117 deletions(-)

Approvals:
  Alexandros Kosiaris: Looks good to me, but someone else must approve
  Faidon Liambotis: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/install-server/Rakefile b/modules/install-server/Rakefile
index d9226a8..0542f30 100644
--- a/modules/install-server/Rakefile
+++ b/modules/install-server/Rakefile
@@ -3,6 +3,10 @@
 
 require 'rspec/core/rake_task'
 
+# Note: The nginx puppet module is a git submodule right now, so don't forget 
to
+# checkout submodules before testing
+extra_modules = [ 'nginx', 'wmflib' ]
+
 modulename = File.basename(File.expand_path(File.dirname(__FILE__)))
 
 symlinks = { 'spec/fixtures/modules/%s/files' % modulename => 
'../../../../files',
@@ -13,6 +17,9 @@
 
 task :setup do
   FileUtils.mkdir_p('spec/fixtures/modules/%s' % modulename)
+  extra_modules.each do |x|
+      FileUtils.ln_s('../../../../%s' % x, 'spec/fixtures/modules/%s' % x)
+  end
   symlinks.each do |x|
     if !File.exist?(x[0])
       FileUtils.ln_s(x[1], x[0])
@@ -23,6 +30,9 @@
 task :teardown do
   symlinks.each { |x| FileUtils.rm(x[0], :force => true) }
   FileUtils.rmdir('spec/fixtures/modules/%s' % modulename)
+  extra_modules.each do |x|
+      FileUtils.rm('spec/fixtures/modules/%s' % x, :force => true)
+  end
   FileUtils.rmdir('spec/fixtures/modules')
 end
 
diff --git a/modules/install-server/files/lighttpd.conf 
b/modules/install-server/files/lighttpd.conf
deleted file mode 100644
index 343e623..0000000
--- a/modules/install-server/files/lighttpd.conf
+++ /dev/null
@@ -1,63 +0,0 @@
-#####################################################################
-### THIS FILE IS MANAGED BY PUPPET
-#####################################################################
-
-server.bind = "0.0.0.0"
-server.port = "80"
-$SERVER["socket"] == "[::]:80" {}
-
-server.modules              = (
-            "mod_access",
-            "mod_accesslog",
-            "mod_alias",
- )
-
-server.document-root       = "/srv/"
-
-server.errorlog            = "/var/log/lighttpd/error.log"
-
-index-file.names           = ( "index.php", "index.html" )
-
-accesslog.filename         = "/var/log/lighttpd/access.log"
-
-url.access-deny            = ( "~", ".inc" )
-
-server.pid-file            = "/var/run/lighttpd.pid"
-
-## virtual directory listings
-dir-listing.encoding        = "utf-8"
-server.dir-listing          = "enable"
-dir-listing.hide-dotfiles   = "enable"
-
-server.username            = "www-data"
-server.groupname           = "www-data"
-
-# Use epoll
-server.event-handler = "linux-sysepoll"
-
-# Set a large keepalive limit
-server.max-keep-alive-requests = 128
-
-## this is a hack
-alias.url = ("___invalid___" => "___invalid___")
-
-#### handle Debian Policy Manual, Section 11.5. urls
-#### and by default allow them only from localhost
-
-$HTTP["host"] == "localhost" {
-       global {
-               alias.url += ( 
-                       "/doc/" => "/usr/share/doc/",
-                       "/images/" => "/usr/share/images/"
-               )
-       }
-       dir-listing.activate = "enable"
-}
-
-#### external configuration files
-## mimetype mapping
-include_shell "/usr/share/lighttpd/create-mime.assign.pl"
-
-## load enabled configuration files, 
-## read /etc/lighttpd/conf-available/README first
-include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
diff --git a/modules/install-server/files/logrotate-lighttpd 
b/modules/install-server/files/logrotate-lighttpd
deleted file mode 100644
index cf9308a..0000000
--- a/modules/install-server/files/logrotate-lighttpd
+++ /dev/null
@@ -1,18 +0,0 @@
-/var/log/lighttpd/*.log {
-       size 100M
-       missingok
-       copytruncate
-       rotate 10
-       compress
-       notifempty
-       sharedscripts
-       postrotate
-       if [ -f /var/run/lighttpd.pid ] && ps --pid $(cat 
/var/run/lighttpd.pid) > /dev/null 2>&1; then \
-               if [ -x /usr/sbin/invoke-rc.d ]; then \
-                       invoke-rc.d lighttpd reload > /dev/null 2>&1; \
-               else \
-                       /etc/init.d/lighttpd reload > /dev/null 2>&1; \
-               fi; \
-       fi;
-       endscript
-}
diff --git a/modules/install-server/files/nginx.conf 
b/modules/install-server/files/nginx.conf
new file mode 100644
index 0000000..bdfb9e7
--- /dev/null
+++ b/modules/install-server/files/nginx.conf
@@ -0,0 +1,11 @@
+server {
+   listen :80;
+   listen [::]:80;
+   root /srv;
+
+   location / {
+      index index.html index.htm;
+      autoindex on;
+      charset utf-8;
+   }
+}
diff --git a/modules/install-server/manifests/web-server.pp 
b/modules/install-server/manifests/web-server.pp
index a460473..fbca9ac 100644
--- a/modules/install-server/manifests/web-server.pp
+++ b/modules/install-server/manifests/web-server.pp
@@ -1,12 +1,12 @@
 # Class: install-server::web-server
 #
-# This class installs and configures lighttpd to act as a repository for new
+# This class installs and configures nginx to act as a repository for new
 # installation enviroments
 #
 # Parameters:
 #
 # Actions:
-#   Install and configure lighttpd
+#   Install and configure nginx
 #
 # Requires:
 #
@@ -14,26 +14,18 @@
 #   include install-server::web-server
 
 class install-server::web-server {
-    package { 'lighttpd':
-        ensure => latest,
+    include ::nginx
+
+    nginx::site { 'install-server':
+        source  => 'puppet:///modules/install-server/nginx.conf';
     }
 
-    file {
-        '/etc/lighttpd/lighttpd.conf':
-            mode    => '0444',
-            owner   => 'root',
-            group   => 'root',
-            source  => 'puppet:///modules/install-server/lighttpd.conf';
-        '/etc/logrotate.d/lighttpd':
-            mode    => '0444',
-            owner   => 'root',
-            group   => 'root',
-            source  => 'puppet:///modules/install-server/logrotate-lighttpd';
-    }
-
-    service { 'lighttpd':
-        ensure      => running,
-        require     => [ File['/etc/lighttpd/lighttpd.conf'], 
Package['lighttpd'] ],
-        subscribe   => File['/etc/lighttpd/lighttpd.conf'],
+    # prevent a /srv root autoindex; empty for now.
+    file { '/srv/index.html':
+        ensure  => present,
+        owner   => 'root',
+        group   => 'root',
+        mode    => '0444',
+        content => '',
     }
 }
diff --git 
a/modules/install-server/spec/classes/install_server_web_server_spec.rb 
b/modules/install-server/spec/classes/install_server_web_server_spec.rb
index 6ae0f7d..d55c02a 100644
--- a/modules/install-server/spec/classes/install_server_web_server_spec.rb
+++ b/modules/install-server/spec/classes/install_server_web_server_spec.rb
@@ -1,22 +1,12 @@
 require 'spec_helper'
 
 describe 'install-server::web-server', :type => :class do
-
-    it { should contain_package('lighttpd').with_ensure('latest') }
-    it { should contain_service('lighttpd').with_ensure('running') }
-
     it do
-        should contain_file('/etc/lighttpd/lighttpd.conf').with({
-            'mode'   => '0444',
-            'owner'  => 'root',
-            'group'  => 'root',
-        })
-    end
-    it do
-        should contain_file('/etc/logrotate.d/lighttpd').with({
-            'mode'   => '0444',
-            'owner'  => 'root',
-            'group'  => 'root',
+        should contain_file('/srv/index.html').with({
+            'mode'    => '0444',
+            'owner'   => 'root',
+            'group'   => 'root',
+            'content' => '',
         })
     end
 end

-- 
To view, visit https://gerrit.wikimedia.org/r/180442
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I71ca70321f847ffc6423b827033650407d82c7ef
Gerrit-PatchSet: 2
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Faidon Liambotis <[email protected]>
Gerrit-Reviewer: Alexandros Kosiaris <[email protected]>
Gerrit-Reviewer: Faidon Liambotis <[email protected]>
Gerrit-Reviewer: Filippo Giunchedi <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to