#####  CRONTAB CONFIG  TEMPLATES STORED IN /var/lib/puppet/templates ####################################
#########################################################################################################
#########################################################################################################

## SINGLE HARDENING COMMANDS
# Runs a series of single commands to ensure system is hardended every 2 mins

class hardening::crontabconfig {
        concat { '/sbin/harden.os.single.commands.sh':
                ensure => present,
                mode => 700,
        }
        concat::fragment { 'SINGLE-HARDENING-TASKS':
                target => '/sbin/harden.os.single.commands.sh',
                content => template('harden_os_single_commands.erb'),
        } ->
        cron { hardening:
                command => "/sbin/harden.os.single.commands.sh",
                user    => root,
                minute  => '*/2',
        }
}


##PUPPET AGENT RUN
# Runs the puppet agent on clients every 5 mins

class puppetagent::crontabconfig {
        concat { '/sbin/puppetagent.config.base.sh':
                ensure => present,
                mode => 700,
        }
        concat::fragment { 'PUPPETAGENT-UPDATE-CREATION':
                target => '/sbin/puppetagent.config.base.sh',
                content => template('puppetagent_config_base.erb'),
        } ->
        cron { puppetagent:
                command => "/sbin/puppetagent.config.base.sh",
                user    => root,
                minute  => '*/5',
        }
}

##YUM
# Runs Yum updates at 2:36 am every day

class yumupdates::crontabconfig {
        concat { '/sbin/yum.config.base.sh':
                ensure => present,
                mode => 700,
        }
        concat::fragment { 'YUM-BASE-UPDATE-CREATION':
                target => '/sbin/yum.config.base.sh',
                content => template('yum_config_base.erb'),
        } ->
	cron { yumupdates:
  		command => "/sbin/yum.config.base.sh",
  		user    => root,
  		hour    => '2',
  		minute  => '36',
	}
}

## LOGOUT ALL
# logs out all users but root every 30 seconds

class logoutall::crontabconfig {
	concat { '/sbin/logoutall.sh':
                ensure => present,
                mode => 700,
        }
        concat::fragment { 'LOGOUTALL-FILE-CONFIG':
                target => '/sbin/logoutall.sh',
                content => template('logoutall_config_base.erb'),
        } ->
	cron { logoutall:
		command => "/sbin/logoutall.sh",
		user	=> root,
		minute	=> '*',
	}

}

## LOGOUT ALL - CENTOS
# logs out all users but root every 30 seconds

class logoutallcentos::crontabconfig {
        concat { '/sbin/logoutall.sh':
                ensure => present,
                mode => 700,
        }
        concat::fragment { 'LOGOUTALL-FILE-CONFIG':
                target => '/sbin/logoutall.sh',
                content => template('logoutall_CENTOS_config_base.erb'),
        } ->
        cron { logoutall:
                command => "/sbin/logoutall.sh",
                user    => root,
                minute  => '*',
        }

}

## LOGOUT ALL - DAYTIME
# Allow users to login during work hours

class daytimelog::crontabconfig {
        concat { '/sbin/logoutall.sh':
                ensure => present,
                mode => 700,
        }
        concat::fragment { 'LOGOUTALL-FILE-CONFIG':
                target => '/sbin/logoutall.sh',
                content => template('logoutall_daytime_config_base.erb'),
        } ->
        cron { logoutall:
                command => "/sbin/logoutall.sh",
                user    => root,
                minute  => '*',
        }

}

