Out of sync reports are not being delivered

Problem:
I am trying to get out_of_sync reports being sent via email but i don’t get any. I am receiving all the notifications that are available to set up via WEB GUI under each of the user --> Email Preferences tab. However, i would like to get notifications about all the hosts that are out of sync for more than 2 hours. I added cron job under /etc/cron.d/foreman file but i don’t know how to make it to send to recipients. Could you please help me with this since i can’t find a solutions so far.

Expected outcome:
Email received with the list of out_of_sync hosts

Foreman and Proxy versions:
1.17

Foreman and Proxy plugin versions:
1.17

Other relevant data:
I can see reports are being generated under log files but they are not being sent.
Here is the cron file for foreman:

root@techops02:/usr/share/foreman/config# cat /etc/cron.d/foreman 
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

RAILS_ENV=production
FOREMAN_HOME=/usr/share/foreman

# Clean up the session entries in the database
15 23 * * *     foreman    cd ${FOREMAN_HOME} && /usr/sbin/foreman-rake db:sessions:clear >>/var/log/foreman/cron.log 2>&1

# Send out recurring notifications
0 7 * * *       foreman    cd ${FOREMAN_HOME} && /usr/sbin/foreman-rake reports:daily >>/var/log/foreman/cron.log 2>&1
0 5 * * 0       foreman    cd ${FOREMAN_HOME} && /usr/sbin/foreman-rake reports:weekly >>/var/log/foreman/cron.log 2>&1
0 3 1 * *       foreman    cd ${FOREMAN_HOME} && /usr/sbin/foreman-rake reports:monthly >>/var/log/foreman/cron.log 2>&1

# Expire old reports
30 7 * * *      foreman    cd ${FOREMAN_HOME} && /usr/sbin/foreman-rake reports:expire >>/var/log/foreman/cron.log 2>&1

# Collects trends data
*/30 * * * *    foreman    cd ${FOREMAN_HOME} && /usr/sbin/foreman-rake trends:counter >>/var/log/foreman/cron.log 2>&1

# Refreshes ldap usergroups. Can be disabled if you're not using LDAP authentication.
*/30 * * * *    foreman    cd ${FOREMAN_HOME} && /usr/sbin/foreman-rake ldap:refresh_usergroups >>/var/log/foreman/cron.log 2>&1

# Clean expired notification
0 6 * * 0       foreman    cd ${FOREMAN_HOME} && /usr/sbin/foreman-rake notifications:clean >>/var/log/foreman/cron.log 2>&1

# Only use the following cronjob if you're not using the ENC or ActiveRecord-based storeconfigs
# Get the node.rb / ENC script and store at /etc/puppet/node.rb:
#   https://github.com/theforeman/puppet-foreman/blob/master/templates/external_node.rb.erb
# Send facts to Foreman, using the ENC script in a fact pushing only mode
#*/2 * * * *     puppet     /etc/puppet/node.rb --push-facts >>/var/log/foreman/cron.log 2>&1

# Warning: ActiveRecord-based storeconfigs is deprecated from Foreman 1.1 and Puppet 3.0
#   see http://projects.theforeman.org/wiki/foreman/ReleaseNotes#11-stable
# Only use the following cronjob if you're using ActiveRecord storeconfigs!
#*/30 * * * *    foreman    cd ${FOREMAN_HOME} && /usr/sbin/foreman-rake puppet:migrate:populate_hosts >>/var/log/foreman/cron.log 2>&1

# Custom reports
# Cron job that sends out of sync state hosts every two hours
* * * * *       foreman    cd ${FOREMAN_HOME} && /usr/sbin/foreman-rake hosts:scan_out_of_sync hours=2  >>/var/log/foreman/cron.log 2>&1

Here is the log files with reports being generated every minutes as per cronjob:

Found 2 online hosts which are not reporting back:
Name                                    Environment         Last Report
********************************************************************************
techops01.dev.int.luminoso.com          production          17 May 19:58
techops02.dev.int.luminoso.com          production          06 Jul 13:45
..
All out of sync hosts exist in DNS

Found 2 online hosts which are not reporting back:
Name                                    Environment         Last Report
********************************************************************************
techops01.dev.int.luminoso.com          production          17 May 19:58
techops02.dev.int.luminoso.com          production          06 Jul 13:45

One more quick question: Is is possible to set up send email notification per group basis rather than user?

Hello,

Create user and in email setup group email ID as recipient.

Thanks,
DJ

Thank you very much for the one answer. What about out_of_sync reports issue?

Have you configured email settings correctly? Go to Administer -> Settings -> Email (tab) and use Test email button, does it send testing email to your address?

Hope that helps

Hey Marek, thank you for your help. Emails are working as charm now. Could you please help me with the first question about “out of sync” host listed above?

Thank you in advance, Yuri.

I think the only way you get out of sync hosts notifications is through “Config summary” email. There’s not explicit out of sync mail notification as far as I know. What you describe sounds like RFE.

Thank you again Marek. I think i will implement ICINGA (Monitoring tool) check for puppet.lock file and alerting on its existence.

Sincerely, Yuri.