Yes, it does depend on what follows "to ensure/ensuring".
If it's a gerund, you're talking about the action of "ensure": "Ensuring our success is the most important thing." So the sentence is about the action of making sure. It is also possible to write, "to ensure our success is the most important thing", but that's not a very common form. Still, you are making an action the subject of the sentence.
But if your sentence is something like "to ensure our success we will take these actions", that's two clauses you could swap over: "we will take these actions to ensure our success". So now you see that "to ensure" works as a verb, and is not the subject.