From a990a72794b91ecac8e463042c12872d465e5200 Mon Sep 17 00:00:00 2001 From: Chithra K <63741367+Chithrak07@users.noreply.github.com> Date: Wed, 4 Jan 2023 04:57:48 +0530 Subject: [PATCH] Download nginx from apt for ubuntu version greater that 22.04 (#11) * Download nginx from apt for ubuntu version higher that 2204 * Test against ubuntu 22.04 * See if we can bypass the error during prepare state * Revert changes * Fix Molecule CI workflow for Ubuntu 22.04 GitHub Actions. * Use the latest molecule-action * Skip role name check Run lint on ubuntu 22.04 * Add role name and namespace so that molecule test doesn't fail * Try addressing new unexplained error from molecule in the pipeline * Try again to get past pipeline error * Revert the commit that did not fix the problem This reverts commit 7ff5391a2e3ecadc857bd8375c3158a2c80d1ad9. * Drop centos testing * Update *very* out of date pip requirements * Try a different entrypoint Tihs works on my local, let's see if github workflow likes it too * Add a line that might help * Fix bad comparison * Try using different images for testing * Bring meta up to date * Update readme * Remove Debian task; we don't use or test it * Switch back to latest * Put Rocky (aka CentOS) test back * Fix typo * Remove cruft * Disambiguate * Update readme Co-authored-by: Dale Anderson --- .github/workflows/molecule.yml | 16 +++++++--------- README.md | 2 +- meta/main.yml | 17 ++++++++++------- molecule/default/molecule.yml | 16 ++++++++++------ requirements.txt | 5 +---- tasks/main.yml | 3 --- tasks/setup-Debian.yml | 5 ----- tasks/setup-RedHat.yml | 4 ++-- tasks/setup-Ubuntu.yml | 16 +++++++++++++--- 9 files changed, 44 insertions(+), 40 deletions(-) delete mode 100644 tasks/setup-Debian.yml diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml index 642c88b..ab940ac 100644 --- a/.github/workflows/molecule.yml +++ b/.github/workflows/molecule.yml @@ -13,11 +13,11 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: "${{ github.repository }}" - name: molecule - uses: robertdebock/molecule-action@2.6.3 + uses: robertdebock/molecule-action@4.0.9 with: command: lint test: @@ -27,18 +27,16 @@ jobs: strategy: matrix: image: - - geerlingguy/docker-ubuntu2004-ansible:latest - - geerlingguy/docker-ubuntu1804-ansible:latest - - geerlingguy/docker-ubuntu1604-ansible:latest - - geerlingguy/docker-centos8-ansible:latest - - geerlingguy/docker-centos7-ansible:latest + - registry.gitlab.com/aussielunix/ansible/molecule-containers/ubuntu:jammy + - registry.gitlab.com/aussielunix/ansible/molecule-containers/ubuntu:focal + - registry.gitlab.com/aussielunix/ansible/molecule-containers/rockylinux:9 steps: - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: path: "${{ github.repository }}" - name: molecule - uses: robertdebock/molecule-action@2.6.3 + uses: robertdebock/molecule-action@4.0.9 with: image: "${{ matrix.image }}" options: parallel diff --git a/README.md b/README.md index f1067db..e0042e9 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Install and configure NGINX for acro hosting environments ## Requirements -* Ubuntu 14.04+ or RedHat/CentOS 6+ +* Ubuntu 18.04+ or CentOS/Red Hat/Rocky Linux 8+ * Your playbook must gather facts ## Role Variables diff --git a/meta/main.yml b/meta/main.yml index 9d1f998..9048a75 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,18 +1,21 @@ --- galaxy_info: - author: Matt Breden - description: Install Nginx on Ubuntu or RedHat/CentOS + author: Matt Breden, Dale Anderson, Chithra K + description: Install NGINX on Ubuntu or Red Hat company: Acro Media Inc. license: GPLv3 min_ansible_version: 2.0 + role_name: nginx + namespace: acromedia platforms: - name: Ubuntu versions: - - trusty - - xenial - - bionic - - name: EL + - jammy # 22.04 + - focal # 20.04 + - bionic # 18.04 + - name: EL # Or CentOS, or Rocky versions: - - 6 + - 8 + - 9 galaxy_tags: [] dependencies: [] diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 025f864..fd98301 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -1,19 +1,23 @@ --- +role_name_check: 1 dependency: name: galaxy driver: name: docker platforms: - name: instance - image: ${MOLECULE_DOCKER_IMAGE:-'geerlingguy/docker-ubuntu1804-ansible:latest'} - command: ${MOLECULE_DOCKER_COMMAND:-""} - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro + image: "registry.gitlab.com/aussielunix/ansible/molecule-containers/${MOLECULE_DISTRO:-ubuntu:jammy}" privileged: true pre_build_image: true + override_command: false + tmpfs: + - /run + - /tmp provisioner: name: ansible -verifier: - name: ansible playbooks: converge: ${MOLECULE_PLAYBOOK:-converge.yml} + env: + ANSIBLE_VERBOSITY: ${MOLECULE_ANSIBLE_VERBOSITY:-0} +verifier: + name: ansible diff --git a/requirements.txt b/requirements.txt index a42a2da..442a8a0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,2 @@ # pip requirements for testing -testinfra==3.4.0 -pytest==5.3.2 -docker==3.4.1 -molecule==2.22 +molecule[docker] diff --git a/tasks/main.yml b/tasks/main.yml index e1b71b5..9ba0d69 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,9 +9,6 @@ - include_tasks: setup-Ubuntu.yml when: ansible_distribution == 'Ubuntu' -- include_tasks: setup-Debian.yml - when: ansible_distribution == 'Debian' - - name: Install NGINX package: name: nginx diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml deleted file mode 100644 index 19a8188..0000000 --- a/tasks/setup-Debian.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- name: Add NGINX PPA so we can get a more recent version than with stock apt - apt_repository: - repo: 'ppa:nginx/stable' - codename: trusty \ No newline at end of file diff --git a/tasks/setup-RedHat.yml b/tasks/setup-RedHat.yml index e4dcac0..820b228 100644 --- a/tasks/setup-RedHat.yml +++ b/tasks/setup-RedHat.yml @@ -1,6 +1,6 @@ --- - name: Ensure nginx is installed. - package: + yum: name: "{{ nginx_package_name }}" - state: present \ No newline at end of file + state: present diff --git a/tasks/setup-Ubuntu.yml b/tasks/setup-Ubuntu.yml index b6763d5..a73058f 100644 --- a/tasks/setup-Ubuntu.yml +++ b/tasks/setup-Ubuntu.yml @@ -1,5 +1,15 @@ --- - -- name: Ensure nginx will reinstall if the PPA was just added. +- name: Add external PPA so we can get newer nginx version than what comes stock. + This was only really necessary on older Ubuntu versions (e.g. trusty and xenial). + Current ubuntu versions ship with a feature-complete nginx. apt_repository: - repo: 'ppa:nginx/stable' \ No newline at end of file + repo: 'ppa:nginx/stable' + codename: '{{ ansible_distribution_release }}' + when: ansible_distribution_version < '22.04' + register: nginx_ppa_add_result + +- name: Refresh apt cache after adding PPA + apt: + update_cache: true + when: nginx_ppa_add_result is defined + and nginx_ppa_add_result.changed