Method: Blower::Context#write

Defined in:
lib/blower/context.rb

#write(string, to, as: user, on: hosts, quiet: false, once: nil) ⇒ Object

Writes a string to a file on the host filesystems.

Parameters:

  • string (String)

    The string to write.

  • to (String)

    The file name to write the string to.

  • on (Array) (defaults to: hosts)

    The hosts to operate on. Defaults to the context’s current host list.

  • as (#to_s) (defaults to: user)

    The remote user to operate as. Defaults to the context’s current user if that is not nil, and the host’s configured user otherwise.

  • quiet (Boolean) (defaults to: false)

    Whether to suppress log messages.

  • once (String) (defaults to: nil)

    If non-nil, only perform the operation if it hasn’t been done before as per #once.



195
196
197
198
199
200
201
202
203
# File 'lib/blower/context.rb', line 195

def write (string, to, as: user, on: hosts, quiet: false, once: nil)
  self.once once, quiet: quiet do
    log.info "write: #{string.bytesize} bytes -> #{to}", quiet: quiet do
      hash_map(hosts) do |host|
        host.write string, to, as: as, quiet: quiet
      end
    end
  end
end