nginx(role): simplify installation by removing version spec
We always just want the latest anyway and therefore don't use it, so no need to keep the complexity introduced by that setting. Also merge repo_setup and nginx_install task lists into one nginx_install task list as keeping two files isn't necessary. Finally improving naming a bit.
This commit is contained in:
parent
938ca6d786
commit
9ee5c6542b
5 changed files with 47 additions and 71 deletions
|
@ -1,13 +1,52 @@
|
|||
- name: make sure the `nginx` package is installed
|
||||
- name: gather package facts
|
||||
ansible.builtin.package_facts:
|
||||
manager: apt
|
||||
|
||||
- name: make sure `gnupg` package is installed
|
||||
ansible.builtin.apt:
|
||||
name: nginx={{ nginx__version_spec }}*
|
||||
name: gnupg
|
||||
state: present
|
||||
allow_change_held_packages: true
|
||||
update_cache: true
|
||||
become: true
|
||||
when: "'gnupg' not in ansible_facts.packages"
|
||||
|
||||
- name: apt-mark hold `nginx`
|
||||
ansible.builtin.dpkg_selections:
|
||||
name: nginx
|
||||
selection: hold
|
||||
- name: make sure NGINX signing key is added
|
||||
ansible.builtin.get_url:
|
||||
url: https://nginx.org/keys/nginx_signing.key
|
||||
dest: /etc/apt/trusted.gpg.d/nginx.asc
|
||||
mode: "0644"
|
||||
owner: root
|
||||
group: root
|
||||
become: true
|
||||
|
||||
- name: make sure NGINX APT repository is added
|
||||
ansible.builtin.apt_repository:
|
||||
repo: "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/nginx.asc] https://nginx.org/packages/debian/ {{ ansible_distribution_release }} nginx"
|
||||
state: present
|
||||
become: true
|
||||
|
||||
- name: make sure NGINX APT source repository is added
|
||||
ansible.builtin.apt_repository:
|
||||
repo: "deb-src [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/nginx.asc] https://nginx.org/packages/debian/ {{ ansible_distribution_release }} nginx"
|
||||
state: present
|
||||
become: true
|
||||
|
||||
- name: set up repository pinning to make sure nginx package gets installed from NGINX repositories
|
||||
ansible.builtin.copy:
|
||||
content: |
|
||||
Package: *
|
||||
Pin: origin nginx.org
|
||||
Pin: release o=nginx
|
||||
Pin-Priority: 900
|
||||
dest: /etc/apt/preferences.d/99nginx
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
become: true
|
||||
|
||||
- name: Ensure nginx is installed
|
||||
ansible.builtin.apt:
|
||||
name: nginx
|
||||
state: present
|
||||
update_cache: true
|
||||
become: true
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
- name: gather package facts
|
||||
ansible.builtin.package_facts:
|
||||
manager: apt
|
||||
|
||||
- name: make sure `gnupg` package is installed
|
||||
ansible.builtin.apt:
|
||||
name: gnupg
|
||||
state: present
|
||||
update_cache: true
|
||||
become: true
|
||||
when: "'gnupg' not in ansible_facts.packages"
|
||||
|
||||
- name: make sure NGINX signing key is added
|
||||
ansible.builtin.get_url:
|
||||
url: https://nginx.org/keys/nginx_signing.key
|
||||
dest: /etc/apt/trusted.gpg.d/nginx.asc
|
||||
mode: "0644"
|
||||
owner: root
|
||||
group: root
|
||||
become: true
|
||||
|
||||
- name: make sure NGINX APT repository is added
|
||||
ansible.builtin.apt_repository:
|
||||
repo: "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/nginx.asc] https://nginx.org/packages/debian/ {{ ansible_distribution_release }} nginx"
|
||||
state: present
|
||||
become: true
|
||||
|
||||
- name: make sure NGINX APT source repository is added
|
||||
ansible.builtin.apt_repository:
|
||||
repo: "deb-src [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/nginx.asc] https://nginx.org/packages/debian/ {{ ansible_distribution_release }} nginx"
|
||||
state: present
|
||||
become: true
|
||||
|
||||
- name: set up repository pinning to make sure nginx package gets installed from NGINX repositories
|
||||
ansible.builtin.copy:
|
||||
content: |
|
||||
Package: *
|
||||
Pin: origin nginx.org
|
||||
Pin: release o=nginx
|
||||
Pin-Priority: 900
|
||||
dest: /etc/apt/preferences.d/99nginx
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
become: true
|
Loading…
Add table
Add a link
Reference in a new issue