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

Merge branch 'INFRA-10624' into 'master'

INFRA-10624 Adapt nginx role for Debian/Ubuntu

Closes INFRA-10624

See merge request !1
parents a41ff427 c057e5f8
Branches master
Tags v1.0.0
1 merge request!1INFRA-10624 Adapt nginx role for Debian/Ubuntu
Pipeline #201415 passed
......@@ -9,5 +9,8 @@ galaxy_info:
- name: CentOS
versions:
- 7
- name: Ubuntu
versions:
- jammy
dependencies:
- role: ics-ans-role-repository
......@@ -17,6 +17,10 @@ provisioner:
nginx_vhosts:
- server_name: "ics-ans-role-nginx-default"
root: "/var/www/test"
ics-ans-role-nginx-ubn:
nginx_vhosts:
- server_name: "ics-ans-role-nginx-ubn"
root: "/var/www/html"
scenario:
name: default
verifier:
......@@ -36,3 +40,17 @@ platforms:
command: /sbin/init
groups:
- 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
hosts: all
gather_facts: false
tasks: []
gather_facts: true
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(
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):
......
---
# Variable setup.
- name: Include OS-specific variables.
include_vars: "{{ ansible_os_family }}.yml"
include_vars: "{{ ansible_os_family | lower }}.yml"
- name: Define nginx_user.
set_fact:
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.
- name: Ensure nginx is installed.
- name: Ensure required packages are installed.
package:
name: "{{ nginx_package_name }}"
name:
- "{{ nginx_package_name }}"
state: present
# Vhost configuration.
......@@ -38,5 +39,5 @@
file:
path: "{{ item.root }}"
state: directory
owner: nginx
owner: "{{ nginx_owner }}"
loop: "{{ nginx_vhosts }}"
{% if nginx_user is defined %}
user {{ nginx_user }};
{% endif %}
error_log {{ nginx_error_log }};
pid {{ nginx_pidfile }};
......
......@@ -6,4 +6,4 @@ 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_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