Add a new option for the vhost

We can now specify different Location, with a subset of options. This
will be needed for some of the service vhost, such as Keystone[1].

The layout is pretty simple:
tripleo_httpd_vhost_locations:
  '/my/location':
    - optionName: value
    - optionName2: value2
    - ...

Of course, a new molecule scenario has been added in order to ensure
this new feature is working properly.

[1] https://docs.openstack.org/keystone/yoga/admin/federation/configure_federation.html#configuring-an-httpd-auth-module

Change-Id: I553c1890864f63a32f23d9914df5490ed2577ecb
This commit is contained in:
Cédric Jeanneret 2022-09-21 08:53:03 +02:00
parent 7898061a31
commit b5278e1f2b
6 changed files with 110 additions and 0 deletions

View File

@ -37,6 +37,7 @@ tripleo_httpd_vhost_document_root: '/var/www/cgi-bin'
tripleo_httpd_vhost_error_log_file: "/var/log/httpd/{{ tripleo_httpd_vhost_access_log_name }}_error.log"
tripleo_httpd_vhost_group: 'apache'
tripleo_httpd_vhost_headers: []
tripleo_httpd_vhost_locations: {}
tripleo_httpd_vhost_options:
- '-Indexes'
- '+FollowSymLinks'

View File

@ -0,0 +1,38 @@
---
# Copyright 2022 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Converge
hosts: all
vars:
tripleo_httpd_vhost_service_name: proxy
tripleo_httpd_vhost_user: bar
tripleo_httpd_vhost_proxy: true
tripleo_httpd_vhost_proxy_host: 127.0.0.1
tripleo_httpd_vhost_proxy_port: 8080
tripleo_httpd_config_mods:
headers: []
tripleo_httpd_config_locations:
'/v3/OS-FEDERATION/identity_providers/IDENTITYPROVIDER/protocols/PROTOCOL/auth':
- 'Options': '+Indexes -MultiViews +FollowSymLinks'
- 'Require': 'valid-user'
'/v3/auth/OS-FEDERATION/websso/PROTOCOL':
- 'Header': 'set MyHeader "%D %t"'
roles:
- "tripleo_httpd_vhost"
tasks:
- name: Validate httpd configuration
command: apachectl -t

View File

@ -0,0 +1,27 @@
---
driver:
name: podman
provisioner:
inventory:
hosts:
all:
hosts:
centos:
ansible_python_interpreter: /usr/bin/python3
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
scenario:
name: locations
test_sequence:
- destroy
- create
- prepare
- converge
- destroy
verifier:
name: testinfra

View File

@ -0,0 +1,33 @@
---
# Copyright 2022 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Prepare
hosts: all
roles:
- role: test_deps
test_deps_extra_packages:
- httpd
- mod_ssl
- role: env_data
tasks:
- name: Create bar user
user:
name: bar
- name: Empty default config files
file:
path: /etc/httpd/conf.d
state: absent

View File

@ -0,0 +1,9 @@
# Specific locations
{% for location, options in tripleo_httpd_vhost_locations.items() %}
<Location {{ location }}>
{% for option, value in options.items() %}
{{ option }} {{ value }}
{% endfor %}
</Location>
{% endfor %}
# End of specific locations

View File

@ -11,6 +11,8 @@
Require all granted
</Directory>
{% include 'templates/locations.inc.j2' %}
## Logging
ErrorLog "{{ tripleo_httpd_vhost_error_log_file }}"
ServerSignature Off