From add3bfba0b6f0808183cd4956c212af1634fcc05 Mon Sep 17 00:00:00 2001 From: Alessandro Fael Garcia Date: Thu, 1 Mar 2018 16:15:27 -0800 Subject: [PATCH] Replace get_url module The get_url module has python 2.7 dependencies. This causes errors on distros that have strict python 2.6 dependencies. Replacing the get_url module with a hardcoded code block using the blockinfile module circumvents these errors. --- tasks/plus/setup-debian.yml | 16 ++++++++++++---- tasks/plus/setup-freebsd.yml | 12 +++++++++--- tasks/plus/setup-redhat.yml | 25 +++++++++++++++++++++---- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/tasks/plus/setup-debian.yml b/tasks/plus/setup-debian.yml index ab9995f..5f03a90 100644 --- a/tasks/plus/setup-debian.yml +++ b/tasks/plus/setup-debian.yml @@ -1,11 +1,19 @@ --- - name: "(Install: Debian/Ubuntu) Add NGINX Plus Repository" - shell: printf "deb https://plus-pkgs.nginx.com/{{ ansible_distribution|lower }} `lsb_release -cs` nginx-plus\n" | sudo tee /etc/apt/sources.list.d/nginx-plus.list + apt_repository: + repo: deb https://plus-pkgs.nginx.com/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} nginx-plus + filename: nginx-plus + update_cache: no - name: "(Install: Debian/Ubuntu) Verify NGINX Plus License" - get_url: - url: https://cs.nginx.com/static/files/90nginx - dest: /etc/apt/apt.conf.d/90nginx + blockinfile: + path: /etc/apt/apt.conf.d/90nginx + create: yes + block: | + Acquire::https::plus-pkgs.nginx.com::Verify-Peer "true"; + Acquire::https::plus-pkgs.nginx.com::Verify-Host "true"; + Acquire::https::plus-pkgs.nginx.com::SslCert "/etc/ssl/nginx/nginx-repo.crt"; + Acquire::https::plus-pkgs.nginx.com::SslKey "/etc/ssl/nginx/nginx-repo.key"; - name: "(Install: Debian/Ubuntu) Update APT Cache" apt: diff --git a/tasks/plus/setup-freebsd.yml b/tasks/plus/setup-freebsd.yml index 7ce15c9..6da3600 100644 --- a/tasks/plus/setup-freebsd.yml +++ b/tasks/plus/setup-freebsd.yml @@ -1,8 +1,14 @@ --- - name: "(Install: FreeBSD) Add NGINX Plus Repository" - get_url: - url: https://cs.nginx.com/static/files/nginx-plus.conf - dest: /etc/pkg/nginx-plus.conf + blockinfile: + path: /etc/pkg/nginx-plus.conf + create: yes + block: | + nginx-plus: { + URL: pkg+https://plus-pkgs.nginx.com/freebsd/${ABI}/latest + ENABLED: yes + MIRROR_TYPE: SRV + } - name: "(Install: FreeBSD) Verify NGINX Plus License" blockinfile: diff --git a/tasks/plus/setup-redhat.yml b/tasks/plus/setup-redhat.yml index 46780b4..a6b1f9b 100644 --- a/tasks/plus/setup-redhat.yml +++ b/tasks/plus/setup-redhat.yml @@ -19,7 +19,24 @@ version: "amazon" when: ansible_distribution == "Amazon" -- name: "(Install: CentOS/RedHat/Amazon Linux/Oracle Linux) Add NGINX Plus Repository" - get_url: - url: https://cs.nginx.com/static/files/nginx-plus-{{ version }}.repo - dest: /etc/yum.repos.d/nginx-plus-{{ version }}.repo +- name: "(Install: CentOS/RedHat/Oracle Linux) Add NGINX Plus Repository" + yum_repository: + name: nginx-plus + baseurl: https://plus-pkgs.nginx.com/centos/{{ version }}/$basearch/ + description: NGINX Plus Repository + sslclientcert: /etc/ssl/nginx/nginx-repo.crt + sslclientkey: /etc/ssl/nginx/nginx-repo.key + enabled: yes + gpgcheck: yes + when: ansible_distribution != "Amazon" + +- name: "(Install: Amazon Linux) Add NGINX Plus Repository" + yum_repository: + name: nginx-plus + baseurl: https://plus-pkgs.nginx.com/amzn/$releasever/$basearch + description: NGINX Plus Repository + sslclientcert: /etc/ssl/nginx/nginx-repo.crt + sslclientkey: /etc/ssl/nginx/nginx-repo.key + enabled: yes + gpgcheck: yes + when: ansible_distribution == "Amazon"