Sha256: 8fc88b7ae68b832f28b982208dfa6c82033baae78aee8adfc8ff44dcf61b20e9

Contents?: true

Size: 658 Bytes

Versions: 1

Compression:

Stored size: 658 Bytes

Contents

module ForemanAnsible
  # Service to import roles from the filesystem.
  # Should be extracted to a gem that both the proxy and Foreman can use.
  class RolesImporter
    class << self
      def import!
        list_roles_in_fs.each do |role_name|
          role = AnsibleRole.new(:name => role_name)
          next if role.save
          Rails.logger.debug("Failed to save role #{role_name}: "\
                            "#{role.errors.full_messages.join(', ')}")
        end
      end

      private

      def list_roles_in_fs
        Dir.glob('/etc/ansible/roles/*').map do |path|
          path.split('/').last
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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