Skip to content

The selection of the nginx setup uninstall method is not functioning correctly #911

@obyivan

Description

@obyivan

Bug Overview

When selecting nginx_setup: uninstall, some tasks are not performed.
defaults/main/main.yml

# Specify whether you want to install NGINX, upgrade to the latest version, or remove NGINX.
# Can be used with `nginx_version` to fine tune control which version of NGINX is installed/used on each playbook execution.
# Using 'install' will install the latest version (or 'nginx_version') of NGINX on a fresh install.
# Using 'upgrade' will upgrade NGINX to the latest version (that matches your 'nginx_version') of NGINX on every playbook execution.
# Using 'uninstall' will remove NGINX from your system.
# Default is install.
nginx_setup: uninstall

Expected Behavior

Expecting that the status of tasks related to deletion will be changed

Steps to Reproduce the Bug

  1. I have deployed/run the NGINX Ansible role using the playbook.yml and custom var_file:
# var_file
nginx_setup: uninstall
  1. The problem, as I understand it in this code
    https://github.com/nginx/ansible-role-nginx/blob/main/tasks/opensource/install-debian.yml#L8C71-L8C79
- name: Show the value of nginx_state
  debug:
    var: nginx_state 

- name: (Debian/Ubuntu) {{ (nginx_setup == 'uninstall') | ternary('Remove', 'Configure') }} NGINX repository
  ansible.builtin.apt_repository:
    filename: nginx
    repo: "{{ item }}"
    update_cache: true
    mode: "0644"
    state: "{{ (nginx_state == 'uninstall') | ternary('absent', 'present') }}"
  loop: "{{ nginx_repository | default(nginx_default_repository_debian) }}"
  when: nginx_manage_repo | bool

nginx_state cannot have the value uninstall.
(nginx_state == 'uninstall') must be fixed on (nginx_setup == 'uninstall')

Environment Details

  • Target deployment platforms: local cluster
  • Target OSs: Ubuntu 24.04
  • Host OS (where you are running Ansible from): Ubuntu 24.04
  • Version of the NGINX Ansible role (or specific commit): 5271d0c
  • Version of Ansible: [e.g. 2.14.5]
  • How is Ansible being managed: CLI
  • Version of Jinja2 (if you are using any templating capability): -

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions