Skip to content
Open
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
13 changes: 13 additions & 0 deletions src/playbooks/tail/metadata.obsah.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
help: |
Show recent logs from Foreman services (similar to foreman-tail)
variables:
services:
parameter: --service
help: Specific service to tail. Can be specified multiple times. Defaults to all services.
action: append
persist: false
lines:
help: Number of recent log lines to show per service.
default: 50
persist: false
49 changes: 49 additions & 0 deletions src/playbooks/tail/tail.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
- name: Show recent Foreman service logs
hosts: quadlet
become: true
gather_facts: true
tags:
- foremanctl_suppress_default_output
vars:
services: []
lines: 50
all_services:
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.

There is a trend of listing services. Something to think about is whether this means we should put them in centralized location.

- foreman
- dynflow-sidekiq@orchestrator
- dynflow-sidekiq@worker
- dynflow-sidekiq@worker-hosts-queue
- pulp-api
- pulp-content
- candlepin
- httpd
- redis
- postgresql
tasks:
- name: Gather service facts
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.

Doesn't line 5 handle that?

ansible.builtin.service_facts:

- name: Determine active services
ansible.builtin.set_fact:
target_services: >-
{{
(services if services | length > 0 else all_services)
| select('in', ansible_facts.services | map('regex_replace', '\.service$', '') | list)
| list
}}

- name: Fetch recent logs
ansible.builtin.command:
cmd: >-
journalctl --no-pager -n {{ lines }} -u {{ item }}
loop: "{{ target_services }}"
register: log_results
changed_when: false

- name: Display logs
ansible.builtin.debug:
msg: "{{ item.stdout_lines }}"
loop: "{{ log_results.results }}"
loop_control:
label: "{{ item.item }}"
when: item.stdout_lines | length > 0