National security adviser H.R. McMaster has resigned and will be replaced by former US ambassador and Fox News analyst John Bolton.