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"
}

Gini Gangadharan

Gineesh Madapparambath | Backpacker, Foodie, Techie | techbeatly.com|rovervibes.com

You may also like...

Leave a Reply

avatar
  Subscribe  
Notify of
%d bloggers like this: