SHARE
TWEET

Untitled

a guest Mar 9th, 2018 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mkdir -p puppetcode/{manifests,modules}/ ; mkdir -p puppetcode/modules/nginx/{manifests,files,templates}/
  2.  
  3.  
  4. put this into Vagrantfile:
  5.  
  6. Vagrant.configure("2") do |config|
  7.   config.vm.provision "puppet" do |puppet|
  8.     puppet.manifests_path = "puppetcode/manifests"
  9.     puppet.manifest_file = "site.pp"
  10.     puppet.module_path = "puppetcode/modules"
  11.   end
  12. end
  13.  
  14.  
  15.  
  16. put this into puppetcode/manifests/site.pp:
  17.  
  18. node default {
  19.  include nginx
  20. }
  21.  
  22.  
  23.  
  24. put this into puppetcode/modules/nginx/manifests/init.pp
  25.  
  26. class nginx {
  27.  
  28.   file { "/etc/yum.repos.d/epel.repo":
  29.     owner   => 'root',
  30.     group   => 'root',
  31.     mode    => '0644',
  32.     source  => "puppet:///modules/nginx/epel.repo",
  33.   }
  34.  
  35.   package { 'nginx':
  36.     ensure => present,
  37.     require => File['/etc/yum.repos.d/epel.repo'],
  38.     install_options => ['--enablerepo', 'epel'],
  39.   }
  40.  
  41.   file { '/etc/nginx/conf.d/webpage.conf':
  42.     content => template('nginx/webpage.conf.erb'),
  43.     require => Package['nginx'],
  44.     notify  => Service['nginx'],
  45.   }
  46.  
  47.   file { "/var/www":
  48.     ensure  => directory,
  49.     owner   => 'root',
  50.     group   => 'root',
  51.     mode    => '0755',
  52.   }
  53.  
  54.   file { "/var/www/index.html":
  55.     owner   => 'root',
  56.     group   => 'root',
  57.     mode    => '0644',
  58.     source  => "puppet:///modules/nginx/index.html",
  59.     require => File['/var/www'],
  60.   }
  61.  
  62.   service { 'nginx':
  63.     ensure     => running,
  64.     enable     => true,
  65.     hasrestart => true,
  66.     subscribe  => File['/etc/nginx/conf.d/webpage.conf'],
  67.     require    => Package['nginx'],
  68.   }
  69.  
  70.   service { 'iptables':
  71.     ensure     => stopped,
  72.   }
  73.  
  74. }
  75.  
  76.  
  77. put this into puppetcode/modules/nginx/templates/webpage.conf.erb
  78.  
  79. server {
  80.     listen   80;
  81.     server_name <% @fqdn %>;
  82.     access_log /var/log/nginx/access.log;
  83.     error_log /var/log/nginx/error.log;
  84.     root /var/www;
  85.  
  86.     index index.php index.html;
  87.  
  88.     location / {
  89.         try_files $uri $uri/ /index.php?$args ;
  90.     }
  91.     location ~ \.php$ {
  92.         fastcgi_pass unix:/var/run/php5-fpm.sock;
  93.         fastcgi_index index.php;
  94.         include fastcgi_params;
  95.         fastcgi_read_timeout 300;
  96.     }
  97. }
  98.  
  99.  
  100. put this into puppetcode/modules/nginx/files/epel.repo
  101.  
  102. [epel]
  103. name=Extra Packages for Enterprise Linux 6 - $basearch
  104. baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
  105. failovermethod=priority
  106. enabled=1
  107. gpgcheck=0
  108.  
  109.  
  110. put this into puppetcode/modules/nginx/files/index.html
  111.     https://raw.githubusercontent.com/puppetlabs/exercise-webpage/master/index.html
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top