#
# Cookbook:: irrigate-cron
# Recipe:: etl_repo
#
# Description:
#  This recipe manages configuration needed for legacy ETL repo jobs
#  It is not functional unless included in a role with mounts for /mnt/data

if platform_family?('rhel')
  if node['platform_version'].start_with?('7')

    # There are extra required packages for various scripts to run.
    packages = %w(
      gzip
      unzip
      zip
    )

    packages.each do |name|
      package name
    end

    # Ensure requisite directories are created and writable
    git_directories = %w(
      /var/www
    )

    git_directories.each do |directory_name|
      directory directory_name do
        owner node['git']['owner']
        group node['git']['group']
        mode '0755'
        action :create
      end
    end

    git 'ETL' do
      repository 'git@github.com:/theorchard/etl.git'
      reference 'master'
      destination '/var/www/etl'
      user 'deploy'
      group 'deploy'
      action :checkout
    end

    remote_file 'aws.yml' do
      path '/var/www/etl/php/configs/aws.yml'
      source 'file:///mnt/data/configs/etl/php/aws.yml'
      owner 'deploy'
      group 'deploy'
      mode '755'
    end

  end
end
