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
11 changes: 10 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ jobs:
security: none
database: internal
box: centos/stream9
- certificate_source: default
security: none
database: internal
iop: disabled
box: debian/trixie64
runs-on: ubuntu-24.04
env:
FOREMANCTL_BASE_BOX: ${{ matrix.box }}
Expand Down Expand Up @@ -143,10 +148,14 @@ jobs:
--tuning development \
--content-import-path /custom/import \
--content-export-path /custom/export
- name: Deploy features
- name: Deploy hammer
if: contains(matrix.box, 'centos')
run: |
./foremanctl deploy \
--add-feature hammer \
- name: Deploy features
run: |
./foremanctl deploy \
--add-feature foreman-proxy \
--add-feature azure-rm \
--add-feature google \
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
DOMAIN = ENV.fetch('VAGRANT_DOMAIN', 'example.com'.freeze)

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
2 changes: 1 addition & 1 deletion src/roles/httpd/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ httpd_listen_backlog: 511
# 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
30 changes: 18 additions & 12 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 @@ -63,7 +69,7 @@
- name: Configure MPM event module
ansible.builtin.template:
src: event.conf.j2
dest: /etc/httpd/conf.modules.d/event.conf
dest: "{{ httpd_modules_path }}/event.conf"
mode: "0644"
notify:
- Restart httpd
Expand All @@ -79,28 +85,28 @@
- 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

- name: Create systemd drop-in directory for httpd
ansible.builtin.file:
path: /etc/systemd/system/httpd.service.d
path: /etc/systemd/system/{{ httpd_service }}.service.d
state: directory
mode: "0755"

- name: Add httpd to foreman.target
ansible.builtin.copy:
dest: /etc/systemd/system/httpd.service.d/foreman-target.conf
dest: /etc/systemd/system/{{ httpd_service }}.service.d/foreman-target.conf
mode: "0644"
content: |
[Install]
Expand All @@ -117,6 +123,6 @@

- name: Start Apache httpd
ansible.builtin.service:
name: httpd
name: "{{ httpd_service }}"
state: started
enabled: true

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Services are enabled by default on Debian, so this line doesn't trigger an "enable" action, and thus the "Add httpd to foreman.target" is never applied (as systemctl enable is where the symlinks are created for the targets). 😿

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 }}/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: []
2 changes: 1 addition & 1 deletion src/roles/images/tasks/deploy_image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
quadlet_filename: "{{ images_definition.name }}"
quadlet_file_mode: "0644"
quadlet_options:
- "Policy=missing"
- "{{ 'Policy=missing' if ansible_facts['os_family'] != 'Debian' else '' }}"
- |
[Service]
Environment=REGISTRY_AUTH_FILE={{ images_registry_auth_file }}
Expand Down
2 changes: 2 additions & 0 deletions src/roles/images/tasks/pull.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
Policy=always
mode: "0644"
loop: "{{ images_deployed_names | default([]) }}"
when:
- ansible_facts['os_family'] != 'Debian'

- name: Run daemon reload
ansible.builtin.systemd:
Expand Down
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,13 +7,14 @@
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
- python3-requests-oauthlib
7 changes: 7 additions & 0 deletions tests/hammer_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
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
Loading
Loading