code: def _write_file_iface(iface, data, folder, pattern):
      '''
      Writes a file to disk
      '''
      filename = os.path.join(folder, pattern.format(iface))
      if not os.path.exists(folder):
          msg = '{0} cannot be written. {1} does not exist'
          msg = msg.format(filename, folder)
          log.error(msg)
          raise AttributeError(msg)
      with salt.utils.files.fopen(filename, 'w') as fp_:
          fp_.write(salt.utils.stringutils.to_str(data)f _write_file_iface(iface, data, folder, pattern):
      '''
      Writes a file to disk
      '''
      filename = os.path.join(folder, pattern.format(iface))
      if not os.path.exists(folder):
          msg = '{0} cannot be written. {1} does not exist'
          msg = msg.format(filename, folder)
          log.error(msg)
          raise AttributeError(msg)
      with salt.utils.files.fopen(filename, 'w') as fp_:
          fp_.write(salt.utils.stringutils.to_str(data))
docs: Writes a file to disk