Skip to content

Commit

Permalink
test: Ensure cleanup and proper service state on ostree
Browse files Browse the repository at this point in the history
non-ostree system cleanup will remove the packages, which has
side effects such as stopping and removing services.  Cannot remove
packages on ostree system, so try to do something similar.

Signed-off-by: Rich Megginson <[email protected]>
  • Loading branch information
richm committed Feb 26, 2024
1 parent b08c84a commit 26ddb88
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 15 deletions.
10 changes: 10 additions & 0 deletions tests/tasks/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
- always
- tests::cleanup

- name: Cleanup - services
service:
name: "{{ __cockpit_daemon }}"
state: stopped
enabled: false
when: __cockpit_is_ostree | d(false)
tags:
- always
- tests::cleanup

- name: Cleanup - find certificates
find:
paths: /etc/cockpit/ws-certs.d/
Expand Down
16 changes: 13 additions & 3 deletions tests/tests_certificate_existing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
# yamllint disable rule:line-length
- name: Test using an existing certificate with cockpit
hosts: all
roles:
- role: linux-system-roles.cockpit
tasks:
- name: Include role
include_role:
name: linux-system-roles.cockpit
public: true
vars:
cockpit_packages: minimal
cockpit_cert: /etc/myserver.crt
cockpit_private_key: /etc/myserver.key

tasks:
- name: Collect installed package versions
package_facts:

Expand All @@ -26,6 +28,14 @@
args:
creates: /etc/myserver.crt

# ostree cannot remove packages and cannot cleanup properly
# this works around that issue
- name: Restart cockpit to use the new certificates
service:
name: "{{ __cockpit_daemon }}"
state: restarted
when: __cockpit_is_ostree | d(false)

- name: Test - cockpit works with TLS and expected certificate
# noqa command-instead-of-module
command:
Expand Down
28 changes: 16 additions & 12 deletions tests/tests_certificate_external.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
---
# yamllint disable rule:line-length
# This approach relies on https://github.com/linux-system-roles/certificate/pull/97 and cockpit ≥ 211,
# so it does not work on RHEL/CentOS 7. tests_certificate_runafter.yml covers an approach which
# works everywhere, but has to use a `runafter` script.
- name: Install cockpit
hosts: all
vars:
cockpit_packages: minimal
roles:
- linux-system-roles.cockpit

- name: Generate self-signed certmonger certificate
- name: Test with generated self-signed certmonger certificate
hosts: all
tasks:
- name: Tests
block:
- name: Include role
include_role:
name: linux-system-roles.cockpit
public: true
vars:
cockpit_packages: minimal

- name: Collect installed package versions
package_facts:

Expand All @@ -41,6 +37,14 @@
ca: self-sign
group: cockpit-ws

# ostree cannot remove packages and cannot cleanup properly
# this works around that issue
- name: Restart cockpit to use the new certificates
service:
name: "{{ __cockpit_daemon }}"
state: restarted
when: __cockpit_is_ostree | d(false)

#
# Validate installation
#
Expand Down
9 changes: 9 additions & 0 deletions tests/tests_certificate_internal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
group: cockpit-ws
include_role:
name: linux-system-roles.cockpit
public: true
rescue:
- name: Check the error message
vars:
Expand All @@ -42,6 +43,14 @@
- name: Collect installed package versions
package_facts:
# ostree cannot remove packages and cannot cleanup properly
# this works around that issue
- name: Restart cockpit to use the new certificates
service:
name: "{{ __cockpit_daemon }}"
state: restarted
when: __cockpit_is_ostree | d(false)
# Validate installation
- name: Test - cockpit works with TLS and expected certificate
# noqa command-instead-of-module
Expand Down
9 changes: 9 additions & 0 deletions tests/tests_certificate_runafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
cockpit_packages: minimal
include_role:
name: linux-system-roles.cockpit
public: true

# self-signed is broken (https://github.com/linux-system-roles/certificate/issues/98),
# and has too restrictive keyUsage so that using the certificate as CA is not allowed
Expand Down Expand Up @@ -47,6 +48,14 @@
- name: Validate installation
block:
# ostree cannot remove packages and cannot cleanup properly
# this works around that issue
- name: Restart cockpit to use the new certificates
service:
name: "{{ __cockpit_daemon }}"
state: restarted
when: __cockpit_is_ostree | d(false)

# ugh, is there really no better way to do that?
- name: Get PEM of certmonger's local CA
command:
Expand Down
1 change: 1 addition & 0 deletions tests/tests_port.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- name: Run cockpit role
include_role:
name: linux-system-roles.cockpit
public: true
vars:
cockpit_packages: minimal
cockpit_port: 443
Expand Down

0 comments on commit 26ddb88

Please sign in to comment.