Bug 1596353 - sudo requires a tty while running katello-backup from cron
Summary: sudo requires a tty while running katello-backup from cron
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Backup & Restore
Version: 6.2.13
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: 6.4.0
Assignee: Christine Fouant
QA Contact: Og Maciel
URL:
Whiteboard:
Depends On:
Blocks: 1122832
TreeView+ depends on / blocked
 
Reported: 2018-06-28 16:43 UTC by Mike McCune
Modified: 2021-12-10 16:30 UTC (History)
20 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1540382
Environment:
Last Closed: 2018-10-16 19:14:17 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 22551 0 None None None 2018-06-28 16:43:35 UTC
Red Hat Knowledge Base (Solution) 3346741 0 None None None 2018-06-28 16:43:35 UTC
Red Hat Knowledge Base (Solution) 3354581 0 None None None 2018-06-28 16:43:35 UTC

Comment 3 Martin Korbel 2018-07-19 08:24:33 UTC
Reproducer:

1. In this version satellite is katello-backup deprecated, it was replaced by 'foreman-maintain backup'.

> katello-backup --help

IMPORTANT: katello-backup has been removed in favor of 'foreman-maintain backup'.
This change happened in order to support remote databases and a newer mongo version.
Please update your scripts and/or cron jobs.


2. We can try manually backup
> foreman-maintain backup online -y --skip-pulp-content /tmp/sat-backup
...

Done with backup: 2018-07-19 03:34:12 -0400
**** BACKUP Complete, contents can be found in: /tmp/sat-backup/satellite-backup-2018-07-19-03-33-47 ****
> echo $?
0

3. The same step via cron 
> echo "30 3 * * *  root foreman-maintain backup online -y --skip-pulp-content /tmp/sat-backup >> /tmp/backups.log 2>&1" >> /etc/crontab

  Wait when the time is passed and check the log /tmp/backups.log

> grep FAIL /tmp/backups.log


To this point all works fine. But if we try to use "crontab -e" respectively /var/spool/crontab/root

4.
> crontab -e
add line 
"0 3 * * *  foreman-maintain backup online -y --skip-pulp-content /tmp/sat-backup >> /tmp/backups.log 2>&1"

> grep -B 1 FAIL /tmp/backups.log 
Check if the directory exists and is writable: sh: runuser: command not found
                       [FAIL]


The problem is with $PATH and non-absolute using of runuser. 

I'm not sure if it is reason to FAILQA. Maybe a mention in documentation could help.

Mike, what do you think about that?

Comment 4 Marek Hulan 2018-08-16 12:07:17 UTC
Does it work when you wrap it with `bash -l -c 'foreman-maintain backup online -y --skip-pulp-content /tmp/sat-backup >> /tmp/backups.log 2>&1'`? If that's the case, I'd vote for just raising a doc bug and make this verified.

Comment 5 Martin Korbel 2018-08-17 10:39:49 UTC
VERIFIED on Sat6.4#15
with a small problem mented above

Comment 7 Bryan Kearney 2018-10-16 19:14:17 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:2927


Note You need to log in before you can comment on or make changes to this bug.