Skip to content

Commit

Permalink
Update NGINX version to 1.22.1 and add installation checks for variou…
Browse files Browse the repository at this point in the history
…s OS families
  • Loading branch information
mjanez committed Dec 17, 2024
1 parent c04d12e commit 7972cc2
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion playbook/inventories/os_vars/archlinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ postgresql_python3_psycopg: python3-psycopg2

### NGINX packages
nginx_pkg: nginx
nginx_version: 1.20.1
nginx_version: 1.22.1

### systemd
systemd_dir: /usr/lib/systemd
Expand Down
2 changes: 1 addition & 1 deletion playbook/inventories/os_vars/centos-8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ postgresql_python3_psycopg: python3-psycopg2

### NGINX packages
nginx_pkg: nginx
nginx_version: 1.20.1
nginx_version: 1.22.1

### systemd
systemd_dir: /lib/systemd/system
Expand Down
2 changes: 1 addition & 1 deletion playbook/inventories/os_vars/centos-9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ postgresql_python3_psycopg: python3-psycopg2

### NGINX packages
nginx_pkg: nginx
nginx_version: 1.20.1
nginx_version: 1.22.1

### systemd
systemd_dir: /lib/systemd/system
Expand Down
2 changes: 1 addition & 1 deletion playbook/inventories/os_vars/debian-12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ postgresql_python3_psycopg: python3-psycopg2

### NGINX packages
nginx_pkg: nginx
nginx_version: 1.20.1
nginx_version: 1.22.1

### systemd
systemd_dir: /lib/systemd/system
Expand Down
2 changes: 1 addition & 1 deletion playbook/inventories/os_vars/redhat-8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ postgresql_python3_psycopg: python3-psycopg2

### NGINX packages
nginx_pkg: nginx
nginx_version: 1.20.1
nginx_version: 1.22.1

### systemd
systemd_dir: /lib/systemd/system
Expand Down
2 changes: 1 addition & 1 deletion playbook/inventories/os_vars/redhat-9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ postgresql_python3_psycopg: python3-psycopg2

### NGINX packages
nginx_pkg: nginx
nginx_version: 1.20.1
nginx_version: 1.22.1

### systemd
systemd_dir: /lib/systemd/system
Expand Down
2 changes: 1 addition & 1 deletion playbook/inventories/production/hosts.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[ckan_servers]
production_01 ansible_host=192.168.68.01 ansible_user=sudouser ansible_port=222 ansible_ssh_pass=sudouserpassword ansible_connection=ssh
production_01 ansible_connection=local
12 changes: 9 additions & 3 deletions playbook/roles/webserver/tasks/nginx.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
- name: Check if NGINX is installed
command: nginx -v
register: nginx_installed
failed_when: false
changed_when: false

- name: "Install NGINX {{ nginx_version }} (RHEL/CentOS >= 8)"
dnf:
name: "nginx-{{ nginx_version }}"
state: present
update_cache: true
when: ansible_os_family == "RedHat" and ansible_distribution_major_version|int >= 8
when: ansible_os_family == "RedHat" and ansible_distribution_major_version|int >= 8 and nginx_installed.rc != 0

- name: "Install NGINX {{ nginx_version }} (Debian/Ubuntu)"
apt:
name: "nginx={{ nginx_version }}"
state: present
update_cache: true
when: ansible_os_family == "Debian"
when: ansible_os_family == "Debian" and nginx_installed.rc != 0

- name: "Install NGINX {{ nginx_version }} (Arch Linux)"
pacman:
name: "nginx={{ nginx_version }}"
state: present
update_cache: true
when: ansible_os_family == "Archlinux"
when: ansible_os_family == "Archlinux" and nginx_installed.rc != 0

- name: Copy nginx config file
template:
Expand Down

0 comments on commit 7972cc2

Please sign in to comment.