Use ansible's `yum_repository` module instead of a template file.

Implements ideas from #26 and #35
pull/155/head
Bill ONeill 6 years ago
parent 0010b7e06c
commit e7e9b27c14
No known key found for this signature in database
GPG Key ID: 9D6382ACBC996EBB
  1. 5
      README.md
  2. 3
      defaults/main.yml
  3. 13
      tasks/setup-RedHat.yml
  4. 5
      templates/nginx.repo.j2

@ -145,8 +145,11 @@ Configures Nginx's [`log_format`](http://nginx.org/en/docs/http/ngx_http_log_mod
(For Ubuntu only) Allows you to use the official Nginx PPA instead of the system's package. You can set the version to `stable` or `development`.
nginx_yum_repo_enabled: true
nginx_yum_baseurl: "https://nginx.org/packages/{{ (ansible_distribution == 'CentOS') | ternary('centos', 'rhel') }}/{{ ansible_distribution_major_version }}/$basearch/"
nginx_yum_gpgkeyurl: "https://nginx.org/packages/keys/nginx_signing.key"
nginx_yum_gpgcheck: true
(For RedHat/CentOS only) Set this to `false` to disable the installation of the `nginx` yum repository. This could be necessary if you want the default OS stable packages, or if you use Satellite.
(For RedHat/CentOS only) Set `nginx_yum_repo_enabled` to `false` to disable the installation of the `nginx` yum repository. This could be necessary if you want the default OS stable packages, or if you use Satellite. Alternatively, you can override the yum repo's `baseurl`, `gpgkey`, or `gpgcheck` options.
## Overriding configuration templates

@ -4,6 +4,9 @@ nginx_default_release: ""
# Used only for Redhat installation, enables source Nginx repo.
nginx_yum_repo_enabled: true
nginx_yum_baseurl: "https://nginx.org/packages/{{ (ansible_distribution == 'CentOS') | ternary('centos', 'rhel') }}/{{ ansible_distribution_major_version }}/$basearch/"
nginx_yum_gpgkeyurl: "https://nginx.org/packages/keys/nginx_signing.key"
nginx_yum_gpgcheck: true
# Use the official Nginx PPA for Ubuntu, and the version to use if so.
nginx_ppa_use: false

@ -1,11 +1,12 @@
---
- name: Enable nginx repo.
template:
src: nginx.repo.j2
dest: /etc/yum.repos.d/nginx.repo
owner: root
group: root
mode: 0644
yum_repository:
name: nginx
description: nginx repo
baseurl: "{{ nginx_yum_baseurl }}"
gpgkey: "{{ nginx_yum_gpgkeyurl }}"
gpgcheck: "{{ nginx_yum_gpgcheck }}"
enabled: yes
when: nginx_yum_repo_enabled
- name: Ensure nginx is installed.

@ -1,5 +0,0 @@
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/{{ ansible_distribution_major_version }}/$basearch/
gpgcheck=0
enabled=1