From a97e0385ba2bfb9e6c814593034fc9275d0dda74 Mon Sep 17 00:00:00 2001 From: Kevin Tham Date: Wed, 15 May 2013 15:08:58 -0700 Subject: [PATCH] Use official nginx apt repo of stable releases for debian/ubuntu --- manifests/package/debian.pp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/manifests/package/debian.pp b/manifests/package/debian.pp index 760bdb9..97314ef 100644 --- a/manifests/package/debian.pp +++ b/manifests/package/debian.pp @@ -14,7 +14,37 @@ # # This class file is not called directly class nginx::package::debian { + $operatingsystem_lowercase = inline_template('<%= operatingsystem.downcase %>') + package { 'nginx': ensure => present, + require => Anchor['nginx::apt_repo'], + } + + anchor { 'nginx::apt_repo' : } + + file { '/etc/apt/sources.list.d/nginx.list': + ensure => present, + content => "deb http://nginx.org/packages/${operatingsystem_lowercase}/ ${::lsbdistcodename} nginx + deb-src http://nginx.org/packages/${operatingsystem_lowercase}/ ${::lsbdistcodename} nginx + ", + mode => '0444', + require => Exec['add_nginx_apt_key'], + before => Anchor['nginx::apt_repo'], + } + + exec { 'add_nginx_apt_key': + command => "/usr/bin/wget http://nginx.org/keys/nginx_signing.key -O - | /usr/bin/apt-key add -", + unless => '/usr/bin/apt-key list | /bin/grep -q nginx', + before => Anchor['nginx::apt_repo'], + } + + exec { 'apt_get_update_for_nginx': + command => '/usr/bin/apt-get update', + timeout => 240, + returns => [ 0, 100 ], + refreshonly => true, + subscribe => File['/etc/apt/sources.list.d/nginx.list'], + before => Anchor['nginx::apt_repo'], } }