From 95e49ce2ee99d3e2c17672c8ba18ecceb8fc013c Mon Sep 17 00:00:00 2001 From: Werner Buck Date: Fri, 4 Sep 2015 14:00:05 +0200 Subject: [PATCH] Fix proper usage of repsitory EL family. Add support for mainline nginx --- README.md | 4 ++++ defaults/main.yml | 2 ++ tasks/setup-RedHat.yml | 14 ++++++++++++-- templates/nginx.centos.repo.j2 | 13 +++++++++++++ templates/nginx.repo.j2 | 5 ----- templates/nginx.rhel.repo.j2 | 13 +++++++++++++ 6 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 templates/nginx.centos.repo.j2 delete mode 100644 templates/nginx.repo.j2 create mode 100644 templates/nginx.rhel.repo.j2 diff --git a/README.md b/README.md index 6e92a26..5274770 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,10 @@ Set as the `proxy_cache_path` directive in the `nginx.conf` file. By default, th (For Debian/Ubuntu only) Allows you to set a different repository for the installation of Nginx. As an example, if you are running Debian's wheezy release, and want to get a newer version of Nginx, you can install the `wheezy-backports` repository and set that value here, and Ansible will use that as the `-t` option while installing Nginx. + nginx_el_install_mainline: yes + +(For Centos/Rhel only) Defaults to no. If true, installs the mainline nginx repository. + ## Dependencies None. diff --git a/defaults/main.yml b/defaults/main.yml index 3a075c0..cee5391 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,8 @@ --- # Used only for Debian/Ubuntu installation, as the -t option for apt. nginx_default_release: "" +# Used only for RHEL/Centos installation. Set to false for mainline repo. +nginx_el_install_mainline: yes nginx_worker_processes: "1" nginx_worker_connections: "1024" diff --git a/tasks/setup-RedHat.yml b/tasks/setup-RedHat.yml index 73f205e..fafe9e7 100644 --- a/tasks/setup-RedHat.yml +++ b/tasks/setup-RedHat.yml @@ -1,11 +1,21 @@ --- -- name: Enable nginx repo. +- name: (RedHat) Enable nginx repo. template: - src: nginx.repo.j2 + src: nginx.rhel.repo.j2 dest: /etc/yum.repos.d/nginx.repo owner: root group: root mode: 0644 + when: ansible_distribution == 'RedHat' + +- name: (Centos) Enable nginx repo. + template: + src: nginx.centos.repo.j2 + dest: /etc/yum.repos.d/nginx.repo + owner: root + group: root + mode: 0644 + when: ansible_distribution == 'CentOS' - name: Ensure nginx is installed. yum: pkg=nginx state=installed enablerepo=nginx diff --git a/templates/nginx.centos.repo.j2 b/templates/nginx.centos.repo.j2 new file mode 100644 index 0000000..010fa9b --- /dev/null +++ b/templates/nginx.centos.repo.j2 @@ -0,0 +1,13 @@ +{% if nginx_el_install_mainline %} +[nginx] +name=nginx repo mainline +baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/ +gpgcheck=0 +enabled=1 +{% else %} +[nginx] +name=nginx repo stable +baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ +gpgcheck=0 +enabled=1 +{% endif %} diff --git a/templates/nginx.repo.j2 b/templates/nginx.repo.j2 deleted file mode 100644 index 9a853b7..0000000 --- a/templates/nginx.repo.j2 +++ /dev/null @@ -1,5 +0,0 @@ -[nginx] -name=nginx repo -baseurl=http://nginx.org/packages/centos/{{ ansible_distribution_major_version }}/$basearch/ -gpgcheck=0 -enabled=1 diff --git a/templates/nginx.rhel.repo.j2 b/templates/nginx.rhel.repo.j2 new file mode 100644 index 0000000..d05ae8d --- /dev/null +++ b/templates/nginx.rhel.repo.j2 @@ -0,0 +1,13 @@ +{% if nginx_el_install_mainline %} +[nginx] +name=nginx repo mainline +baseurl=http://nginx.org/packages/mainline/rhel/$releasever/$basearch/ +gpgcheck=0 +enabled=1 +{% else %} +[nginx] +name=nginx repo stable +baseurl=http://nginx.org/packages/rhel/$releasever/$basearch/ +gpgcheck=0 +enabled=1 +{% endif %}