diff --git a/defaults/main/main.yml b/defaults/main/main.yml index 46d28fa..8ad925b 100644 --- a/defaults/main/main.yml +++ b/defaults/main/main.yml @@ -19,6 +19,13 @@ nginx_type: opensource # Default is empty. # nginx_version: =19-1~bionic +# Specify whether you want to maintain your version of NGINX or upgrade to the latest version. +# Can be used with `nginx_version` to achieve fine tune control on which version of NGINX is installed/used on each playbook execution. +# Using 'present' will install the latest version (or 'nginx_version') of NGINX on a fresh install. +# Using 'latest' will upgrade NGINX to the latest version (that matches your 'nginx_version') of NGINX on every playbook execution. +# Default is present. +nginx_state: present + # Specify repository origin for NGINX Open Source. # Options are 'nginx_repository' or 'os_repository'. # Only works if 'nginx_type' is set to 'opensource'. diff --git a/tasks/opensource/install-oss-bsd.yml b/tasks/opensource/install-oss-bsd.yml index c4e4498..b8b5997 100644 --- a/tasks/opensource/install-oss-bsd.yml +++ b/tasks/opensource/install-oss-bsd.yml @@ -22,7 +22,7 @@ - name: "(Install: FreeBSD) Install NGINX package" pkgng: name: "www/nginx{{ nginx_version | default('') }}" - state: present + state: "{{ nginx_state }}" when: nginx_bsd_install_packages notify: "(Handler: All OSs) Start NGINX" @@ -30,7 +30,7 @@ portinstall: name: "www/nginx{{ nginx_version | default('') }}" use_packages: "{{ nginx_bsd_portinstall_use_packages | default(omit) }}" - state: present + state: "{{ nginx_state }}" when: not nginx_bsd_install_packages notify: "(Handler: All OSs) Start NGINX" @@ -43,7 +43,7 @@ openbsd_pkg: name: "nginx{{ nginx_version | default('') }}" build: false - state: present + state: "{{ nginx_state }}" when: nginx_bsd_install_packages notify: "(Handler: All OSs) Start NGINX" @@ -51,7 +51,7 @@ openbsd_pkg: name: "nginx{{ nginx_version | default('') }}" build: true - state: present + state: "{{ nginx_state }}" when: not nginx_bsd_install_packages notify: "(Handler: All OSs) Start NGINX" diff --git a/tasks/opensource/install-oss-linux.yml b/tasks/opensource/install-oss-linux.yml index 701fc64..a705c80 100644 --- a/tasks/opensource/install-oss-linux.yml +++ b/tasks/opensource/install-oss-linux.yml @@ -19,6 +19,6 @@ - name: "(Install: Linux) Install NGINX package" package: name: "nginx{{ nginx_version | default('') }}" - state: present + state: "{{ nginx_state }}" when: nginx_install_from == "os_repository" notify: "(Handler: All OSs) Start NGINX" diff --git a/tasks/opensource/setup-alpine.yml b/tasks/opensource/setup-alpine.yml index 803467d..f5aa5b9 100644 --- a/tasks/opensource/setup-alpine.yml +++ b/tasks/opensource/setup-alpine.yml @@ -25,4 +25,5 @@ apk: name: "nginx{{ nginx_version | default('') }}" repository: "{{ repository }}" + state: "{{ nginx_state }}" notify: "(Handler: All OSs) Start NGINX" diff --git a/tasks/opensource/setup-debian.yml b/tasks/opensource/setup-debian.yml index dcd56f9..9059552 100644 --- a/tasks/opensource/setup-debian.yml +++ b/tasks/opensource/setup-debian.yml @@ -22,4 +22,5 @@ - name: "(Install: Debian/Ubuntu) Install NGINX" apt: name: "nginx{{ nginx_version | default('') }}" + state: "{{ nginx_state }}" notify: "(Handler: All OSs) Start NGINX" diff --git a/tasks/opensource/setup-redhat.yml b/tasks/opensource/setup-redhat.yml index 30e2604..45b19b4 100644 --- a/tasks/opensource/setup-redhat.yml +++ b/tasks/opensource/setup-redhat.yml @@ -25,6 +25,7 @@ - name: "(Install: CentOS/RedHat) Install NGINX" yum: name: "nginx{{ nginx_version | default('') }}" + state: "{{ nginx_state }}" disablerepo: "*" enablerepo: "nginx" notify: "(Handler: All OSs) Start NGINX" diff --git a/tasks/opensource/setup-suse.yml b/tasks/opensource/setup-suse.yml index f40b82c..cc7bef1 100644 --- a/tasks/opensource/setup-suse.yml +++ b/tasks/opensource/setup-suse.yml @@ -17,4 +17,5 @@ - name: "(Install: SUSE) Install NGINX" zypper: name: "nginx{{ nginx_version | default('') }}" + state: "{{ nginx_state }}" notify: "(Handler: All OSs) Start NGINX" diff --git a/tasks/plus/install-plus-bsd.yml b/tasks/plus/install-plus-bsd.yml index 42ae2aa..bc78b64 100644 --- a/tasks/plus/install-plus-bsd.yml +++ b/tasks/plus/install-plus-bsd.yml @@ -24,7 +24,7 @@ - name: "(Install: FreeBSD) Install nginx-plus{{ nginx_version | default('') }}" pkgng: name: "nginx-plus{{ nginx_version | default('') }}" - state: present + state: "{{ nginx_state }}" notify: "(Handler: All OSs) Start NGINX" when: ansible_system == "FreeBSD" diff --git a/tasks/plus/install-plus-linux.yml b/tasks/plus/install-plus-linux.yml index 2bca587..413cbfd 100644 --- a/tasks/plus/install-plus-linux.yml +++ b/tasks/plus/install-plus-linux.yml @@ -14,5 +14,5 @@ - name: "(Install: Linux) Install NGINX Plus" package: name: "nginx-plus{{ nginx_version | default('') }}" - state: present + state: "{{ nginx_state }}" notify: "(Handler: All OSs) Start NGINX"