Skip to content
Snippets Groups Projects
Commit c057e5f8 authored by Carl Lundström's avatar Carl Lundström
Browse files

INFRA-10624 Adapt nginx role for Debian/Ubuntu

parent a41ff427
No related branches found
No related tags found
1 merge request!1INFRA-10624 Adapt nginx role for Debian/Ubuntu
...@@ -9,5 +9,8 @@ galaxy_info: ...@@ -9,5 +9,8 @@ galaxy_info:
- name: CentOS - name: CentOS
versions: versions:
- 7 - 7
- name: Ubuntu
versions:
- jammy
dependencies: dependencies:
- role: ics-ans-role-repository - role: ics-ans-role-repository
...@@ -17,6 +17,10 @@ provisioner: ...@@ -17,6 +17,10 @@ provisioner:
nginx_vhosts: nginx_vhosts:
- server_name: "ics-ans-role-nginx-default" - server_name: "ics-ans-role-nginx-default"
root: "/var/www/test" root: "/var/www/test"
ics-ans-role-nginx-ubn:
nginx_vhosts:
- server_name: "ics-ans-role-nginx-ubn"
root: "/var/www/html"
scenario: scenario:
name: default name: default
verifier: verifier:
...@@ -36,3 +40,17 @@ platforms: ...@@ -36,3 +40,17 @@ platforms:
command: /sbin/init command: /sbin/init
groups: groups:
- molecule_group - molecule_group
- name: ics-ans-role-nginx-ubn
image: registry.esss.lu.se/ics-docker/ubuntu-systemd:22.04
# SYS_ADMIN required to run systemctl
capabilities:
- SYS_ADMIN
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup
tmpfs:
- /run
- /tmp
command: /sbin/init
privileged: true
groups:
- molecule_group
--- ---
- name: Prepare - name: Prepare
hosts: all hosts: all
gather_facts: false gather_facts: true
tasks: []
roles:
- ics-ans-role-repository
tasks:
- name: Ensure required packages are installed.
package:
name:
- 'curl'
state: present
...@@ -7,7 +7,9 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( ...@@ -7,7 +7,9 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
def test_directory_exists(host): def test_directory_exists(host):
assert host.file("/var/www/test").exists file1 = host.file("/var/www/test")
file2 = host.file("/var/www/html")
assert file1.exists or file2.exists
def test_nginx_access(host): def test_nginx_access(host):
......
--- ---
# Variable setup. # Variable setup.
- name: Include OS-specific variables. - name: Include OS-specific variables.
include_vars: "{{ ansible_os_family }}.yml" include_vars: "{{ ansible_os_family | lower }}.yml"
- name: Define nginx_user. - name: Define nginx_user.
set_fact: set_fact:
nginx_user: "{{ __nginx_user }}" nginx_user: "{{ __nginx_user }}"
when: nginx_user is not defined when: nginx_user is not defined and ansible_os_family | lower == 'redhat'
# Setup/install tasks. # Setup/install tasks.
- name: Ensure nginx is installed. - name: Ensure required packages are installed.
package: package:
name: "{{ nginx_package_name }}" name:
- "{{ nginx_package_name }}"
state: present state: present
# Vhost configuration. # Vhost configuration.
...@@ -38,5 +39,5 @@ ...@@ -38,5 +39,5 @@
file: file:
path: "{{ item.root }}" path: "{{ item.root }}"
state: directory state: directory
owner: nginx owner: "{{ nginx_owner }}"
loop: "{{ nginx_vhosts }}" loop: "{{ nginx_vhosts }}"
{% if nginx_user is defined %}
user {{ nginx_user }}; user {{ nginx_user }};
{% endif %}
error_log {{ nginx_error_log }}; error_log {{ nginx_error_log }};
pid {{ nginx_pidfile }}; pid {{ nginx_pidfile }};
......
...@@ -6,4 +6,4 @@ nginx_mime_file_path: /etc/nginx/mime.types ...@@ -6,4 +6,4 @@ nginx_mime_file_path: /etc/nginx/mime.types
nginx_pidfile: /var/run/nginx.pid nginx_pidfile: /var/run/nginx.pid
nginx_vhost_path: /etc/nginx/conf.d nginx_vhost_path: /etc/nginx/conf.d
nginx_default_vhost_path: /etc/nginx/conf.d/default.conf nginx_default_vhost_path: /etc/nginx/conf.d/default.conf
__nginx_user: "nginx" nginx_owner: root
---
root_group: root
nginx_conf_path: /etc/nginx/conf.d
nginx_conf_file_path: /etc/nginx/nginx.conf
nginx_mime_file_path: /etc/nginx/mime.types
nginx_pidfile: /var/run/nginx.pid
nginx_vhost_path: /etc/nginx/conf.d
nginx_default_vhost_path: /etc/nginx/conf.d/default.conf
nginx_owner: "{{ __nginx_user }}"
__nginx_user: "nginx"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment