Search code examples
ansiblerhelansible-role

Ansible provisioning without internet access


I know that you can setup proxy in Ansible to provision behind corporate network: https://docs.ansible.com/ansible/latest/user_guide/playbooks_environment.html

like this:

environment:
    http_proxy: http://proxy.example.com:8080

Unfortunately in my case there is no access to internet from the server at all. Downloading roles locally and putting them under /roles folder seems solve the role issue, but roles still download packages from the internet when using:

package:
   name: package-name
   state: present

I guess there is no way to make dry/pre run so Ansible downloads all the packages, then push that into repo and run Ansible provision using locally downloaded packages?


Solution

  • This isn't really a question about Ansible, as all Ansible is doing is running the relevant package management system on the target host (i.e. yum, dnf or apt or whatever). So it is a question of what solution the specific package management tool provides, for this case.

    There are a variety of solutions and for example in the Centos/RHEL world you can:

    There is another class of tool generally called an artefact repository. These started out life as tools to store binaries built from code, but have added a bunch of features to act as a proxy and cache packages from a wide variety of sources (OS Packages, PIP, NodeJS, Docker, etc). Two examples that have limited free offerings:

    They of course still need to collect those packages from a source, so at some point those are going to have to be downloaded to placed within these systems.