From c696e87f340a1dcdccc6a941d0781002a1f114be Mon Sep 17 00:00:00 2001 From: Wes Turner Date: Sat, 9 Aug 2014 02:34:01 -0500 Subject: [PATCH] ENH: Add install_from_ppa pillar setting and PPA pkgrepo --- nginx/init.sls | 6 ++++-- nginx/map.jinja | 4 +++- nginx/ng/install.sls | 17 ++++++++++++++++- nginx/package.sls | 17 ++++++++++++++++- pillar.example | 9 ++++++++- 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/nginx/init.sls b/nginx/init.sls index b2659aa..07240ff 100644 --- a/nginx/init.sls +++ b/nginx/init.sls @@ -1,9 +1,11 @@ +{%- set nginx=pillar.get('nginx', {}) %} + include: - nginx.common -{% if pillar.get('nginx', {}).get('user_auth_enabled', true) %} +{% if nginx.get('user_auth_enabled', true) %} - nginx.users {% endif %} -{% if pillar.get('nginx', {}).get('install_from_source') %} +{% if nginx.get('install_from_source') %} - nginx.source {% else %} - nginx.package diff --git a/nginx/map.jinja b/nginx/map.jinja index 74b80e2..b749fab 100644 --- a/nginx/map.jinja +++ b/nginx/map.jinja @@ -1,8 +1,10 @@ {% set nginx = salt['grains.filter_by']({ 'Debian': { + 'package': 'nginx', 'apache_utils': 'apache2-utils', }, 'RedHat': { + 'package': 'nginx', 'apache_utils': 'httpd-tools', }, -}, merge=salt['pillar.get']('nginx:lookup')) %} \ No newline at end of file +}, merge=salt['pillar.get']('nginx:lookup')) %} diff --git a/nginx/ng/install.sls b/nginx/ng/install.sls index f538ccd..4333698 100644 --- a/nginx/ng/install.sls +++ b/nginx/ng/install.sls @@ -5,10 +5,25 @@ {% from 'nginx/ng/map.jinja' import nginx, sls_block with context %} nginx_install: - {% if nginx.from_source %} + {% if nginx.install_from_source %} ## add source compilation here {% else %} pkg.installed: {{ sls_block(nginx.package.opts) }} - name: {{ nginx.lookup.package }} {% endif %} + +{% if salt['grains.get']('os_family') == 'Debian' %} +{% if nginx.install_from_ppa %} +nginx_ppa_repo: + pkgrepo.managed: + - humanname: nginx-ppa-{{ grains['oscodename'] }} + - name: deb http://ppa.launchpad.net/nginx/stable/ubuntu {{ grains['oscodename'] }} main + - file: /etc/apt/sources.list.d/nginx-stable-{{ grains['oscodename'] }}.list + - dist: {{ grains['oscodename'] }} + - keyid: C300EE8C + - keyserver: keyserver.ubuntu.com + - require_in: + - pkg: nginx_install +{% endif %} +{% endif %} diff --git a/nginx/package.sls b/nginx/package.sls index fd5ae0c..300dde7 100644 --- a/nginx/package.sls +++ b/nginx/package.sls @@ -1,3 +1,4 @@ +{% from "nginx/map.jinja" import nginx with context %} {% set use_upstart = pillar.get('nginx', {}).get('use_upstart', true) %} {% if use_upstart %} nginx-old-init: @@ -35,9 +36,23 @@ nginx-old-init-disable: - file: nginx-old-init {% endif %} +{% if salt['grains.get']('os_family') == 'Debian' %} +nginx-ppa-repo: + pkgrepo.managed: + - enabled: {{ salt['pillar.get']('nginx:install_from_ppa', False) }} + - humanname: nginx-ppa-{{ grains['oscodename'] }} + - name: deb http://ppa.launchpad.net/nginx/stable/ubuntu {{ grains['oscodename'] }} main + - file: /etc/apt/sources.list.d/nginx-stable-{{ grains['oscodename'] }}.list + - dist: {{ grains['oscodename'] }} + - keyid: C300EE8C + - keyserver: keyserver.ubuntu.com + - require_in: + - pkg: nginx +{% endif %} + nginx: pkg.installed: - - name: nginx + - name: {{ nginx.package }} {% if use_upstart %} file: - managed diff --git a/pillar.example b/pillar.example index 757b0a4..84bb0f0 100644 --- a/pillar.example +++ b/pillar.example @@ -1,5 +1,6 @@ nginx: install_from_source: True + install_from_ppa: False use_upstart: True user_auth_enabled: True with_luajit: False @@ -13,6 +14,9 @@ nginx: source: http://github.com/agentzh/headers-more-nginx-module/tarball/v0.21 source_hash: sha1=dbf914cbf3f7b6cb7e033fa7b7c49e2f8879113b + lookup: + package: nginx + # ======== # nginx.ng # ======== @@ -30,7 +34,10 @@ nginx: vhost_use_symlink: True # Source compilation is not currently a part of nginx.ng - from_source: False + install_from_source: False + + # Install nginx.ng.lookup.package from the PPA repository + install_from_ppa: True package: opts: {} # this partially exposes parameters of pkg.installed