#cloud-config

merge_type:
 - name: list
   settings: [append]
 - name: dict
   settings: [recurse_array]

packages:
  - default-jre-headless
  - git
  - gnupg
  - librarian-puppet
  - puppet
  - rsync

write_files:
  - path: /etc/puppet/code/Puppetfile
    permissions: '0644'
    content: |
      #!/usr/bin/env ruby
      #^syntax detection
      forge "https://forgeapi.puppetlabs.com"
      mod 'cesnet-kerberos',
        :git => 'https://github.com/MetaCenterCloudPuppet/cesnet-kerberos/'
      mod 'cesnet-site_hadoop',
        :git => 'https://github.com/MetaCenterCloudPuppet/cesnet-site_hadoop/'
      mod 'cesnet-hadoop',
        :git => 'https://github.com/MetaCenterCloudPuppet/cesnet-hadoop/'
      mod 'cesnet-hadoop_lib',
        :git => 'https://github.com/MetaCenterCloudPuppet/cesnet-hadoop_lib/'
      mod 'cesnet-hbase',
        :git => 'https://github.com/MetaCenterCloudPuppet/cesnet-hbase/'
      mod 'cesnet-hue',
        :git => 'https://github.com/MetaCenterCloudPuppet/cesnet-hue/'
      mod 'cesnet-hive',
        :git => 'https://github.com/MetaCenterCloudPuppet/cesnet-hive/'
      mod 'cesnet-impala',
        :git => 'https://github.com/MetaCenterCloudPuppet/cesnet-impala/'
      mod 'cesnet-oozie',
        :git => 'https://github.com/MetaCenterCloudPuppet/cesnet-oozie/'
      mod 'cesnet-pig',
        :git => 'https://github.com/MetaCenterCloudPuppet/cesnet-pig/'
      mod 'cesnet-spark',
        :git => 'https://github.com/MetaCenterCloudPuppet/cesnet-spark/'
      mod 'cesnet-zookeeper',
        :git => 'https://github.com/MetaCenterCloudPuppet/cesnet-zookeeper/'
      # compatibility with puppet <= 4.x
      mod 'puppetlabs-apt', '<7.7.1'
      mod 'puppetlabs-mysql', '<10.10.0'

runcmd:
  # workaround for bigtop-utils jsvc
  - d=/usr/lib/jvm/default-java/lib; if test -e "$d" -a ! -e "$d/amd64"; then ln -fsv . "$d/amd64"; fi
  - cd /etc/puppet/code && HOME=/root librarian-puppet install --verbose
  - mkdir /data 2>/dev/null || true
  - egrep '^\s*GSSAPIAuthentication\s+yes' /etc/ssh/sshd_config || echo 'GSSAPIAuthentication yes' >> /etc/ssh/sshd_config
  - service ssh reload
