Fix auto-order problem in state.template

Use the highstate renderer so we can add correct ordering and state
metadata prior to processing.
Merge pull request #15667 from cachedout/issue_13146

Fix auto-order problem in state.template