Sha256: 2fbd3525cc3f2bda13bf2003a326f4ddb3c39bba3fadad7d042ee498cb7f9780

Contents?: true

Size: 648 Bytes

Versions: 1

Compression:

Stored size: 648 Bytes

Contents

module ForemanAnsible
  # Sugar-coating so that playing a list of roles is easier and
  # more understandable, it just requires a host and it figures out the rest
  class RolePlayer
    attr_reader :host

    def initialize(host)
      @host = host
    end

    def play
      return if host.ansible_roles.empty?
      inventory_tempfile = InventoryCreator.new([host]).tempfile
      RunPlaybookJob.new(create_playbook.path,
                         inventory_tempfile.path).enqueue
    end

    private

    def create_playbook
      PlaybookCreator.new(
        host.fqdn,
        host.ansible_roles.map(&:name)).roles_tempfile
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreman_ansible-1.0 app/services/foreman_ansible/role_player.rb