AETHER-2697 Separate task for adding apt repository for Nginx
Change-Id: I0b84cb091a4c2926119b0b520a9bc78c309ec5a0
diff --git a/tasks/Debian-repo.yml b/tasks/Debian-repo.yml
new file mode 100644
index 0000000..bab31ff
--- /dev/null
+++ b/tasks/Debian-repo.yml
@@ -0,0 +1,24 @@
+---
+# nginx tasks/Debian-repo.yml
+#
+# SPDX-FileCopyrightText: © 2021 Open Networking Foundation <support@opennetworking.org>
+# SPDX-License-Identifier: Apache-2.0
+
+- name: Install GPG to support adding apt repo keys
+ apt:
+ name: "gpg"
+ state: "present"
+ update_cache: true
+
+# Docs: http://nginx.org/en/linux_packages.html
+- name: Add NGINX apt repo key
+ apt_key:
+ data: "{{ lookup('file','nginx_signing.key') }}"
+ state: "present"
+
+- name: Add NGINX apt repo
+ apt_repository:
+ repo: >-
+ deb http://nginx.org/packages/{{ ansible_lsb['id'] | lower }}
+ {{ ansible_lsb['codename'] }} nginx
+ update_cache: true
diff --git a/tasks/Debian.yml b/tasks/Debian.yml
index 3d1d8e8..9715868 100644
--- a/tasks/Debian.yml
+++ b/tasks/Debian.yml
@@ -4,25 +4,6 @@
# SPDX-FileCopyrightText: © 2020 Open Networking Foundation <support@opennetworking.org>
# SPDX-License-Identifier: Apache-2.0
-- name: Install GPG to support adding apt repo keys
- apt:
- name: "gpg"
- state: "present"
- update_cache: true
-
-# Docs: http://nginx.org/en/linux_packages.html
-- name: Add NGINX apt repo key
- apt_key:
- data: "{{ lookup('file','nginx_signing.key') }}"
- state: "present"
-
-- name: Add NGINX apt repo
- apt_repository:
- repo: >-
- deb http://nginx.org/packages/{{ ansible_lsb['id'] | lower }}
- {{ ansible_lsb['codename'] }} nginx
- update_cache: true
-
- name: Install NGINX packages (Debian)
apt:
name: "{{ nginx_packages }}"
diff --git a/tasks/main.yml b/tasks/main.yml
index b9d7f7b..14ed0a0 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -7,6 +7,10 @@
- name: include OS-specific vars
include_vars: "{{ ansible_os_family }}.yml"
+- name: include OS-specific package repo updates
+ include_tasks: "{{ ansible_os_family }}-repo.yml"
+ when: nginx_add_package_repo | bool
+
- name: include OS-specific tasks
include_tasks: "{{ ansible_os_family }}.yml"