Hi
You should use conditionals for your task like a when:
to execute your task “when” the condition is true.
In your case, i’d use a when: on network name, and so, if network name is network 1 so my task will update it with value network2 as wanted.
2nd solution if you’re able to retrieve facts (i assume vmware collection does) so maybe you can use a when: on a specific facts (i.e : network name : XXX)
I agree. Ansible works best if you use it as an infastructure-as-code tool (which it basically is). I also prefer PowerCLI for things that I want do do once, like migrating VMs to another portgroup or similar.
Besides, I think ansible isn’t well suited for any if-then-else logic. You can implement it somehow, but it usually feels wrong to me if I do.