Section 20. Stationary engineers, steam firemen, school teachers and head farmers employed in mental health facilities of the department and, except as otherwise provided by the civil service law and rules, the classified labor service of the department, shall be exempt from chapter thirty-one; provided, however, that whenever, as a condition of receiving federal grants for programs and activities to which the federal standards for a merit system of personnel administration relate, federal requirements make necessary the application of the civil service law and rules to any such position, or to the classified labor service or any portion thereof, said positions or service shall be subject to chapter thirty-one; provided, further, such federal requirements are uniform in all states.