Sha256: 0e37fe3faea8666397e81b08766b498993d51024bdaa041f187a9476662f365b

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

module DanarchyDeploy
  class Services
    def self.new(deployment, options)
      puts "\n" + self.name

      deployment[:services].each do |service, params|
        puts "Configuring service: #{service}"

        if params[:templates] && !params[:templates].empty?
          puts " > COnfiguring templates for #{service}"
          DanarchyDeploy::Templater.new(params[:templates], options)
        end

        if params[:archives] && !params[:archives].empty?
          puts "\n" + self.name
          puts " > Deploying archives for #{service}"
          DanarchyDeploy::Archiver.new(params[:archives], options)
        end
      end

      deployment
    end

    private
    def self.init(deployment, options)
      puts "\n" + self.name

      deployment[:services].each do |service, params|
        next if !params[:init]
        if options[:first_run] == false
          puts "    ! Not a first-time run! Setting actions to 'reload'.\n\tUse --first-run to run actions: #{params[:init].join(' ,')}\n"
          params[:init] = ['reload']
        end

        params[:init].each do |action|
          puts " > Taking action: #{action} on #{service}"
          command = "systemctl #{action} #{service}"

          if options[:pretend]
            puts "    Fake run: #{command}\n"
          else
            DanarchyDeploy::Helpers.run_command(command, options)
          end
        end
      end

      deployment
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danarchy_deploy-0.1.0 lib/danarchy_deploy/services.rb