While running the SharePoint 2013 Product Preparation Tool on Windows Server 2012 I got this error:

SharePoint 2013 Preparation Web Server IIS Role configuration error

There was an error during installation.
The tool was unable to install Application Server Role, Web Server (IIS) Role.
[…]
Application Server Role, Web Server (IIS) Role: configuration error.
[…]

You can simply fix this by installing .NET Framework 3.5 Features from Server Manager before running the Product Preparation Tool:

SharePoint 2013 Preparation Install .NET Framework 3.5 Features

After this step make sure to specify the source location (by clicking Specify an alternate source path) of the installation files (usually D:\sources\sxs) because the source files for .NET Framework 3.5 are not copied to the harddrive during Windows setup.

SharePoint 2013 Preparation Install .NET Framework 3.5 Features alternate source path

SharePoint 2013 Preparation Install .NET Framework 3.5 Features alternate source path 2