Skip to content

Install Python Modules offline

|

Installing a python module (any applications) is very easy via a public repo or private repo.

Eg:

sudo apt-get install python-dnspython

But what if your production server do not have internet access and your repo server do not have this package to be installed ? Actually this is very simple as a piece of cake. For example, I am installing dnspython module which I need to use for my DNS queries in some Ansible playbooks.

Refer all Ansible Learning Guides here.

Step 1. We need to download the package from source. (http://www.dnspython.org)

Step 2. Copy the downloaded module file to your server (use scp, ftp etc)

$ ls -lrt dnspython-1.15.0.tar.gz
-rw-r--r-- 1 mygmaa u_048937 144073 Aug 1 16:48 dnspython-1.15.0.tar.g

Step 3. Extract the content

$ gunzip dnspython-1.15.0.tar.gz
$ tar -xvf dnspython-1.15.0.tar
$ ls -l |grep dnspython
drwxr-x--x 6 mygmaa u_048937 4096 Sep 30 2016 dnspython-1.15.0
-rw-r--r-- 1 mygmaa u_048937 911360 Aug 1 16:48 dnspython-1.15.0.ta

Step 4. Install the package. (With privileged access)

# cd dnspython-1.15.0
# python setup.py install

Wait for installation to be finished and test it.

Since I was using this for a DNS check in my playbook; I have tried as below.

- name: Check Console DNS
  debug:
    #msg="Console"
    msg="{{ lookup( 'dig', 'lab-techbeatly','qtype=A' )}}"

And it worked well.

TASK [consolesanitycheck : Check Console DNS] *
ok: [localhost] => {
    "msg": "10.1.10.10"
}

Gineesh has worked as a Systems Engineer, Automation Specialist, and content author. His primary focus is on Ansible Automation, Containerisation (OpenShift & Kubernetes), and Infrastructure as Code (Terraform). (aka Gini Gangadharan - iamgini.com)

Latest posts

Gineesh has worked as a Systems Engineer, Automation Specialist, and content author. His primary focus is on Ansible Automation, Containerisation (OpenShift & Kubernetes), and Infrastructure as Code (Terraform). (aka Gini Gangadharan - iamgini.com)

Comments

1 Response

  1. […] Note: You need to install the other required Python dependencies (e.g., openshift, PyYAML, etc.) for the modules to work. This topic is not in the scope of this article but you can refer to standard procedures (or read how to Install Python Modules offline). […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: