Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ jobs:
box:
- centos/stream9
- centos/stream10
- debian/trixie64
exclude:
- certificate_source: installer
box: centos/stream10
- certificate_source: installer
box: debian/trixie64
include:
- certificate_source: default
security: fapolicyd
Expand Down Expand Up @@ -112,6 +115,7 @@ jobs:
run: |
./foremanctl deploy --certificate-source=${{ matrix.certificate_source }} ${{ matrix.database == 'external' && '--database-mode=external --database-host=database.example.com' || '' }} --foreman-initial-admin-password=changeme --tuning development
- name: Add optional feature - hammer
if: contains(matrix.box, 'centos')
run: |
./foremanctl deploy --add-feature hammer
- name: Add optional feature - foreman-proxy
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Vagrant.configure("2") do |config|
config.vm.synced_folder ".", "/vagrant"
config.vm.synced_folder ".", "/vagrant", disabled: true

config.vm.provision("etc_hosts", type: 'ansible') do |ansible|
ansible.playbook = "development/playbooks/etc_host.yml"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@
chroot: rhel-10-x86_64
when:
- ansible_distribution_major_version == '10'

- name: Refresh package cache
ansible.builtin.package:
update_cache: true
when:
- ansible_os_family == 'Debian'
1 change: 1 addition & 0 deletions development/playbooks/test/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ansible.builtin.package:
name:
- nmap
- curl

- name: Execute tests
gather_facts: false
Expand Down
1 change: 1 addition & 0 deletions src/playbooks/pull-images/pull-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
ansible.builtin.package:
name:
- podman
- netavark

- name: Pull an image
containers.podman.podman_image:
Expand Down
2 changes: 1 addition & 1 deletion src/roles/httpd/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ httpd_pub_dir: /var/www/html/pub
# External authentication configuration
httpd_external_authentication: "{{ external_authentication | default(None) }}"
httpd_ipa_manage_sssd: true
httpd_ipa_keytab: /etc/httpd/conf/http.keytab
httpd_ipa_keytab: "{{ httpd_etc_path }}/conf/http.keytab"
httpd_ipa_pam_service: "{{ external_authentication_pam_service | default('foreman') }}"
httpd_ipa_gssapi_local_name: true
2 changes: 1 addition & 1 deletion src/roles/httpd/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Restart httpd
ansible.builtin.systemd:
name: httpd
name: "{{ httpd_service }}"
state: restarted

- name: Restart sssd
Expand Down
4 changes: 2 additions & 2 deletions src/roles/httpd/tasks/external_auth/cleanup.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Remove external authentication configuration
ansible.builtin.file:
path: "/etc/httpd/conf.d/05-{{ item }}.d/external_auth.conf"
path: "{{ httpd_conf_path}} /05-{{ item }}.d/external_auth.conf"
state: absent
notify:
- Restart httpd
Expand All @@ -11,7 +11,7 @@

- name: Remove Apache module configuration files for IPA authentication
ansible.builtin.file:
path: /etc/httpd/conf.modules.d/55-{{ item }}.conf
path: "{{ httpd_modules_path }}/55-{{ item }}.conf"
state: absent
loop:
- authnz_pam
Expand Down
12 changes: 6 additions & 6 deletions src/roles/httpd/tasks/external_auth/ipa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

- name: Create directory for Apache module configuration
ansible.builtin.file:
path: /etc/httpd/conf.modules.d
path: "{{ httpd_modules_path }}"
state: directory
mode: "0755"

- name: Load Apache modules for IPA authentication
ansible.builtin.copy:
dest: /etc/httpd/conf.modules.d/55-{{ item }}.conf
dest: "{{ httpd_modules_path }}/55-{{ item }}.conf"
content: |
LoadModule {{ item }}_module modules/mod_{{ item }}.so
mode: "0644"
Expand Down Expand Up @@ -66,13 +66,13 @@
- name: Set keytab file permissions
ansible.builtin.file:
path: "{{ httpd_ipa_keytab }}"
owner: apache
group: apache
owner: "{{ httpd_user }}"
group: "{{ httpd_group }}"
mode: "0600"

- name: Create directory for Apache configuration fragments
ansible.builtin.file:
path: /etc/httpd/conf.d/05-{{ item }}.d
path: "{{ httpd_conf_path }}/05-{{ item }}.d"
state: directory
mode: "0755"
loop:
Expand All @@ -82,7 +82,7 @@
- name: Deploy external authentication configuration
ansible.builtin.template:
src: external_auth.conf.j2
dest: /etc/httpd/conf.d/05-{{ item }}.d/external_auth.conf
dest: "{{ httpd_conf_path }}/05-{{ item }}.d/external_auth.conf"
mode: "0644"
notify:
- Restart httpd
Expand Down
24 changes: 15 additions & 9 deletions src/roles/httpd/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
- name: Set OS dependent variables
ansible.builtin.include_vars: "{{ ansible_facts['os_family'] }}.yaml"

- name: Install Apache httpd
ansible.builtin.package:
name:
- httpd
- mod_ssl
name: "{{ httpd_packages }}"
state: present

- name: Set httpd_can_network_connect so Apache can connect to Puma and Gunicorn
Expand All @@ -13,9 +14,14 @@
persistent: true
when: ansible_facts['selinux']['status'] == "enabled"

- name: Enable required modules
community.general.apache2_module:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like pulling in community.general here, but this is something we'd have to consider anyway.
In the Puppet installer, we run with apache::default_mods: false, which wipes all enabled modules and then we enable the ones we need.
We didn't port that detail over to foremanctl, and rely on the OS to enable those modules for us. But it also most probably enables things we do not want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may also want to enable the event MPM in a similar way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like pulling in community.general here, but this is something we'd have to consider anyway.

May I ask why it is bad to use community.general?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly because it's a dependency we don't yet have

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also mentions compatibility:

This does not work on RedHat-based distributions. It does work on Debian- and SuSE-based distributions. Whether it works on others depend on whether the C(a2enmod) and C(a2dismod) tools are available or not.

So configuring Apache with Ansible is certainly worse than what we had with our Puppet module.

name: "{{ item }}"
loop: "{{ httpd_modules }}"

- name: Disable welcome page
ansible.builtin.file:
path: /etc/httpd/conf.d/welcome.conf
path: "{{ httpd_conf_path }}/welcome.conf"
state: absent
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A thought for upgrades and not necessary for this PR: RPM will place this file back. Should we ensure it's empty instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just deploy on Debian, where the package manager is actually sane and respects the choices of the admin ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just put it all in a container /me ducks


- name: Create cert directories
Expand All @@ -31,8 +37,8 @@
ansible.builtin.file:
path: "{{ httpd_pub_dir }}"
state: directory
group: apache
owner: apache
group: "{{ httpd_group }}"
owner: "{{ httpd_user }}"
mode: "0755"

- name: Deploy certificates
Expand Down Expand Up @@ -69,15 +75,15 @@
- name: Configure foreman vhost
ansible.builtin.template:
src: foreman-vhost.conf.j2
dest: /etc/httpd/conf.d/foreman.conf
dest: "{{ httpd_conf_path }}/foreman.conf"
mode: "0644"
notify:
- Restart httpd

- name: Configure foreman-ssl vhost
ansible.builtin.template:
src: foreman-ssl-vhost.conf.j2
dest: /etc/httpd/conf.d/foreman-ssl.conf
dest: "{{ httpd_conf_path }}/foreman-ssl.conf"
mode: "0644"
notify:
- Restart httpd
Expand All @@ -87,6 +93,6 @@

- name: Start Apache httpd
ansible.builtin.service:
name: httpd
name: "{{ httpd_service }}"
state: started
enabled: true
2 changes: 1 addition & 1 deletion src/roles/httpd/tasks/sssd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
path: /etc/sssd/sssd.conf
section: ifp
option: allowed_uids
value: "root, apache"
value: "root, {{ httpd_user }}"
mode: "0600"
notify:
- Restart sssd
Expand Down
6 changes: 3 additions & 3 deletions src/roles/httpd/templates/foreman-ssl-vhost.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
ServerName {{ ansible_facts['fqdn'] }}

## Load additional static includes
IncludeOptional "/etc/httpd/conf.d/05-foreman-ssl.d/*.conf"
IncludeOptional "{{ httpd_conf_path }}/05-foreman-ssl.d/*.conf"

## Logging
ErrorLog "/var/log/httpd/foreman-ssl_error_ssl.log"
ErrorLog "{{ httpd_log_path }}/foreman-ssl_error_ssl.log"
ServerSignature Off
CustomLog "/var/log/httpd/foreman-ssl_access_ssl.log" combined
CustomLog "{{ httpd_log_path }}/foreman-ssl_access_ssl.log" combined

## Request header rules
## as per http://httpd.apache.org/docs/2.4/mod/mod_headers.html#requestheader
Expand Down
6 changes: 3 additions & 3 deletions src/roles/httpd/templates/foreman-vhost.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
ServerName {{ ansible_facts['fqdn'] }}

## Load additional static includes
IncludeOptional "/etc/httpd/conf.d/05-foreman.d/*.conf"
IncludeOptional "{{ httpd_conf_path }}/conf.d/05-foreman.d/*.conf"

## Logging
ErrorLog "/var/log/httpd/foreman_error.log"
ErrorLog "{{ httpd_log_path }}/foreman_error.log"
ServerSignature Off
CustomLog "/var/log/httpd/foreman_access.log" combined
CustomLog "{{ httpd_log_path }}/foreman_access.log" combined

## Request header rules
## as per http://httpd.apache.org/docs/2.4/mod/mod_headers.html#requestheader
Expand Down
15 changes: 15 additions & 0 deletions src/roles/httpd/vars/Debian.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
httpd_packages:
- apache2
httpd_etc_path: /etc/apache2
httpd_conf_path: "{{ httpd_etc_path }}/conf-enabled"
httpd_modules_path: "{{ httpd_etc_path }}/mods-enabled"
httpd_service: apache2
httpd_log_path: /var/log/apache2
httpd_user: www-data
httpd_group: www-data
httpd_modules:
- ssl
- headers
- proxy
- proxy_http
12 changes: 12 additions & 0 deletions src/roles/httpd/vars/RedHat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
httpd_packages:
- httpd
- mod_ssl
httpd_etc_path: /etc/httpd
httpd_conf_path: "{{ httpd_etc_path }}/conf.d"
httpd_modules_path: "{{ httpd_etc_path }}/conf.modules.d"
httpd_service: httpd
httpd_log_path: /var/log/httpd
httpd_user: apache
httpd_group: apache
httpd_modules: []
3 changes: 2 additions & 1 deletion src/roles/pre_install/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
ansible.builtin.package:
name:
- podman
- netavark

- name: Install other dependencies
ansible.builtin.package:
name:
- bash-completion
- python3-cryptography
- python3-libsemanage
- "{{ 'python3-semanage' if ansible_facts['os_family'] == 'Debian' else 'python3-libsemanage' }}"
- python3-psycopg2
- python3-requests
2 changes: 2 additions & 0 deletions tests/foreman_compute_resources_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

@pytest.mark.parametrize("compute_resource", ['AzureRm', 'EC2', 'GCE', 'Libvirt', 'Openstack', 'Vmware'])
def test_foreman_compute_resources(server, compute_resource):
if server.system_info.distribution == 'debian':
pytest.xfail('Hammer is not properly set up on Debian yet')
hammer = server.run("hammer compute-resource create --help | grep provider")
assert hammer.succeeded
assert compute_resource in hammer.stdout
7 changes: 7 additions & 0 deletions tests/hammer_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import pytest


def test_hammer_ping(server):
if server.system_info.distribution == 'debian':
pytest.xfail('Hammer is not properly set up on Debian yet')
hammer = server.run("hammer ping")
assert hammer.succeeded

def test_hammer_organizations_list(server):
if server.system_info.distribution == 'debian':
pytest.xfail('Hammer is not properly set up on Debian yet')
hammer = server.run("hammer organization list")
assert hammer.succeeded
6 changes: 5 additions & 1 deletion tests/httpd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
CURL_CMD = "curl --silent --output /dev/null"

def test_httpd_service(server):
httpd = server.service("httpd")
if server.system_info.distribution == 'debian':
service_name = 'apache2'
else:
service_name = 'httpd'
httpd = server.service(service_name)
assert httpd.is_running
assert httpd.is_enabled

Expand Down