I don't understand "lost" in the question. It's work you must do. So how can it be lost?
The "theory" behind Agile is that you have a mature infrastructure.
There are two distinct infrastructure issues.
When creating new infrastructure, we build the exploration into the first few sprints. You can't schedule this. You cannot predict the various paths, roadblocks, pitfalls, snares and traps in this. It requires learning. Don't try to predict the time required to lay down a new infrastructure. Stuff will go wrong. If it doesn't, then the infrastructure isn't really "new" -- it's a clone or copy.
Using existing infrastructure -- Server Config and Deployment -- happens with each release, so we do them as frequently as we can.
Some things (like our new firewall) threw real complexities into some releases.
But generally, Config and Deployment -- like a mature infrastructure -- are foundational. They're already part of your process. You're already doing them. How can they be "lost"?
What do you mean by "effort tends to get lost"? What does "lost" mean? You knew you had to do it. You did it. What's lost?
Edit. The idea that this time is "lost" or "not visible" or an "impact" or anything other than business as usual doesn't make any sense, in spite of all the comments.
This is just stuff you do. It's part of the release. It's just work, like development, that you just do.
"A day of migration is a long time" But if that's what it takes, then that's what it takes. You simply allow for it. It's simply a task that you do with every release.
If the schedule is sacred -- and the day of migration is a "problem" -- you have to ask who has the "problem" and what "problem" do they have? Is it a project manager's problem? If so, the schedule has trumped the delivered feature set, and that project manager needs to rethink their view of reality. The user's feature set is real. The schedule is just a nice idea that didn't always work out.