Sha256: a9cefa93ed50f3199961f24bc2d3a3b4939bf9eb6833f1f2ce8f9826b7b2e931

Contents?: true

Size: 1.77 KB

Versions: 4

Compression:

Stored size: 1.77 KB

Contents

module Pvcglue
  class Packages
    class AptRepos < Pvcglue::Packages
      PASSENGER_SOURCES_LIST_FILENAME = '/etc/apt/sources.list.d/passenger.list'
      PASSENGER_SOURCES_LIST_DATA = 'deb https://oss-binaries.phusionpassenger.com/apt/passenger xenial main'

      def nginx_needed?
        has_roles? %w(lb web)
      end

      def node_js_needed?
        has_roles? %w(web worker)
      end

      def postgresql_needed?
        has_roles? %w(pg)
      end

      def installed?
        get_minion_state(:apt_repos_updated_at)
      end

      def install!
        # These could be refactored into packages.  :)

        if nginx_needed?
          # Reference:  https://www.phusionpassenger.com/library/install/nginx/install/oss/xenial/
          connection.run!(:root, '', 'apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7')
          connection.run!(:root, '', 'apt-get install -y apt-transport-https ca-certificates')
          connection.write_to_file(:root, PASSENGER_SOURCES_LIST_DATA, PASSENGER_SOURCES_LIST_FILENAME)
        end

        if node_js_needed?
          # Reference:  http://tecadmin.net/install-latest-nodejs-npm-on-ubuntu/
          connection.run!(:root, '', 'apt-get install -y apt-transport-https ca-certificates python-software-properties lsb-release')
          connection.run!(:root, '', 'curl -sL https://deb.nodesource.com/setup_7.x | bash -')
        end

        if postgresql_needed?
          connection.run!(:root, '', 'add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main"')
          connection.run!(:root, '', 'wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -')
        end

        set_minion_state(:apt_repos_updated_at, Time.now.utc)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pvcglue-0.9.3 lib/pvcglue/packages/apt_repos.rb
pvcglue-0.9.2 lib/pvcglue/packages/apt_repos.rb
pvcglue-0.9.1 lib/pvcglue/packages/apt_repos.rb
pvcglue-0.9.0 lib/pvcglue/packages/apt_repos.rb