ansible-role-nginx: incorrect repo for AWS ami

Describe the bug Trying to install nginx on an AWS ami To reproduce Steps to reproduce the behavior:

  1. Deploy NGINX role using playbook.yml
  2. Installs the centos/redhat repo
  3. See errors
TASK [nginx : (Install: CentOS/RedHat) Install NGINX] ***************************************************************************************************************************************************************************************
fatal: [xx.xxx.xxx.xxx]: FAILED! => {"changed": false, "msg": "Failure talking to yum: failure: repodata/repomd.xml from nginx: [Errno 256] No more mirrors to try.\nhttps://nginx.org/packages/mainline/centos/NA/x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found"}

Yum update error

failure: repodata/repomd.xml from nginx: [Errno 256] No more mirrors to try. https://nginx.org/packages/mainline/centos/NA/x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found

Expected behavior To install nginx

Your environment:

  • Version of the NGINX Role or specific commit latest

  • Version of Ansible ansible 2.7.9

  • Target deployment platform AMI flavour

$ cat /etc/os-release 
NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2018.03"
PRETTY_NAME="Amazon Linux AMI 2018.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2018.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
$ cat /etc/yum.repos.d/nginx.repo 
[nginx]
baseurl = https://nginx.org/packages/mainline/centos/NA/$basearch/
enabled = 1
gpgcheck = 1
name = NGINX Repository

Probably the path should have 7 instead of NA, maybe the CENTOS version is not detected properly.

I see that that supported OS for opensource version do not include AWS AMI linux, only the Nginx Plus - this could be the issue.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (5 by maintainers)

Most upvoted comments

Feel free to submit it or fork and add this or just add locally.

I’d suggest pre_tasks This will break when Amazon Linux goes with 8Server though.

pre_tasks:

  • set_fact: ansible_distribution_major_version=7 when: ansible_distribution == “Amazon” and ansible_distribution_major_version == “NA”

This is an issue with Amazon Linux not reporting its server version because it’s not open sourced, they just use dates. If they add a way to be compatible with centos (which is where the upstream for Amazon Linux is obviously coming from) then we can use that. Otherwise I’d use an override similar to below.

It is more fully explained here: https://mamchenkov.net/wordpress/2016/07/07/forcing-amazon-linux-ami-compatibility-with-centos-in-ansible/