configure: restart puppet master before step 1

During the upgrade process, we need to restart Puppet Master to avoid
catalog errors.
Let's do it before step 1 to avoid any error during the upgrade.
Also move detect_os function.

Note: it does not affect the install process.