Bug 1305824

Summary: foreman_scap_client crontab entry is not removed when a Compliance Policy is removed
Product: Red Hat Satellite Reporter: David Sanz <dsanzmor>
Component: SCAP PluginAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED DUPLICATE QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.1.6CC: egolov, javier.ramirez, oprazak
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-23 10:01:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David Sanz 2016-02-09 10:34:36 UTC
Description of problem:
Puppet class correctly creates an entry in the root crontab but, if the compliance policy is deleted, the entry is not being removed:


Version-Release number of selected component (if applicable):

# cat /usr/share/puppet/modules/foreman_scap_client/metadata.json 
{
  "name": "isimluk-foreman_scap_client",
  "version": "0.3.6",
  "author": "isimluk",
  "summary": "This puppet module configures foreman_scap_client.",
  "license": "GNU General Public License, version 2 (GPLv2)",
  "source": "https://github.com/OpenSCAP/puppet-foreman_scap_client.git",
  "project_page": "https://github.com/OpenSCAP/puppet-foreman_scap_client",
  "issues_url": "https://github.com/OpenSCAP/puppet-foreman_scap_client/issues",
  "dependencies": [
    { "name": "puppetlabs/stdlib",        "version_requirement": ">= 4.2.0" }
  ]
}

# rpm -qa | grep foreman_scap
rubygem-foreman_scap_client-0.1.0.4-1.el6_6sat.noarch

# rpm -qa | grep foreman_scap
puppet-foreman_scap_client-0.3.3-10.el7sat.noarch


How reproducible:


Steps to Reproduce:
1.Delete the compliance policy in the Satellite WebUI
2.Execute puppet agent -t in the client
3.# crontab -l from the root account

Actual results:
# crontab -l
# HEADER: This file was autogenerated at Tue Feb 09 10:21:06 +0000 2016 by puppet.
# HEADER: While it can still be managed manually, it is definitely not recommended.
# HEADER: Note particularly that the comments starting with 'Puppet Name' should
# HEADER: not be deleted, as doing so could cause duplicate cron jobs.
# Puppet Name: foreman_scap_client_3
0 13 * * * /usr/bin/foreman_scap_client 3

# puppet agent -t
Info: Retrieving plugin
Info: Loading facts in /var/lib/puppet/lib/facter/rh_certificates.rb
Info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb
Info: Loading facts in /var/lib/puppet/lib/facter/pe_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb
Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb
Info: Caching catalog for testrhel.n1data.lan
Warning: The package type's allow_virtual parameter will be changing its default value from false to true in a future release. If you do not want to allow virtual packages, please explicitly set allow_virtual to false.
   (at /usr/lib/ruby/site_ruby/1.8/puppet/type.rb:816:in `set_default')
Info: Applying configuration version '1455013339'
Notice: /Stage[main]/Foreman_scap_client/File[foreman_scap_client]/content: 
--- /etc/foreman_scap_client/config.yaml	2016-02-09 09:29:57.630806269 +0000
+++ /tmp/puppet-file20160209-30050-2f986v-0	2016-02-09 10:22:20.304803075 +0000
@@ -21,10 +21,3 @@
 
 # policy (key is id as in Foreman)
 
-3:
-  :profile: 'xccdf_org.ssgproject.content_profile_common'
-  :content_path: '/var/lib/openscap/content/6298742afc45309f86ac467c0c9a3e433ff505dd3d237dd8cbf72be1a02937bb.xml'
-  # Download path
-  # A path to download SCAP content from proxy
-  :download_path: '/compliance/policies/3/content'
-

Info: /Stage[main]/Foreman_scap_client/File[foreman_scap_client]: Filebucketed /etc/foreman_scap_client/config.yaml to puppet with sum 74da6ab6e27352fbeaecbf0ed46f322b
Notice: /Stage[main]/Foreman_scap_client/File[foreman_scap_client]/content: content changed '{md5}74da6ab6e27352fbeaecbf0ed46f322b' to '{md5}aeeebbd70a42b09128e3304654bd2a14'
Notice: Finished catalog run in 0.20 seconds

# crontab -l
# HEADER: This file was autogenerated at Tue Feb 09 10:21:06 +0000 2016 by puppet.
# HEADER: While it can still be managed manually, it is definitely not recommended.
# HEADER: Note particularly that the comments starting with 'Puppet Name' should
# HEADER: not be deleted, as doing so could cause duplicate cron jobs.
# Puppet Name: foreman_scap_client_3
0 13 * * * /usr/bin/foreman_scap_client 3

# /usr/bin/foreman_scap_client 3
/usr/lib/ruby/gems/1.8/gems/foreman_scap_client-0.1.0.4/lib/foreman_scap_client/client.rb:121:in `ensure_scan_file': undefined method `[]' for nil:NilClass (NoMethodError)
	from /usr/lib/ruby/gems/1.8/gems/foreman_scap_client-0.1.0.4/lib/foreman_scap_client/client.rb:14:in `run'
	from /usr/bin/foreman_scap_client:10

Expected results:
crontab entry removed

Additional info:

Comment 1 Bryan Kearney 2016-07-26 19:05:21 UTC
Moving 6.2 bugs out to sat-backlog.

Comment 2 Ondřej Pražák 2016-11-23 10:01:13 UTC
This was fixed as a part of https://bugzilla.redhat.com/show_bug.cgi?id=1362665
Entries from root crontab were moved to '/etc/cron.d/foreman_scap_client_cron', which is correctly updated by Puppet.

*** This bug has been marked as a duplicate of bug 1362665 ***