Can Ansible use a local repository?
You can set up a proxy. A reverse proxy can be a good choice for this kind of setup. You would configure each machine to use the proxy as its apt/pip repository. The first time a package is requested the proxy downloads it from the internet and stores it, the next machine that requires it will get it from the proxy directly.

One popular choice is Squid. Another one is Nginx, set up in a reverse proxy configuration.

The advantage over mirroring entire repositories is that you'll only get the packages you need. The advantage over having Ansible copy the files is that it acts like the real proxy, dependencies and upgrades and all. But you'll  have to change apt and pip repository configurations. Or "hijack" those repository names through your local DNS.