0

I'm able to install few python modules on my app servers using ansible. But, when I include python-mysqldb module, it throws the below error.

vagrant@control:~/ansible$ ansible-playbook playbooks/webserver.yml

PLAY [webserver] ***************************************************************

TASK [setup] *******************************************************************
ok: [app02]
ok: [app01]

TASK [install web components] **************************************************
failed: [app02] (item=[u'apache2', u'libapache2-mod-wsgi', u'python-pip', u'python-virtualenv', u'python-mysqldb']) => {"failed": true, "item": ["apache2", "libapache2-mod-wsgi", "python-pip", "python-virtualenv", "python-mysqldb"], "module_stderr": "Shared connection to app02 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_sYzNC_/ansible_module_apt.py\", line 909, in <module>\r\n    main()\r\n  File \"/tmp/ansible_sYzNC_/ansible_module_apt.py\", line 892, in main\r\n    if updated_cache and not retvals['changed']:\r\nKeyError: 'changed'\r\n", "msg": "MODULE FAILURE"}
failed: [app01] (item=[u'apache2', u'libapache2-mod-wsgi', u'python-pip', u'python-virtualenv', u'python-mysqldb']) => {"failed": true, "item": ["apache2", "libapache2-mod-wsgi", "python-pip", "python-virtualenv", "python-mysqldb"], "module_stderr": "Shared connection to app01 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_GKrHoN/ansible_module_apt.py\", line 909, in <module>\r\n    main()\r\n  File \"/tmp/ansible_GKrHoN/ansible_module_apt.py\", line 892, in main\r\n    if updated_cache and not retvals['changed']:\r\nKeyError: 'changed'\r\n", "msg": "MODULE FAILURE"}
    to retry, use: --limit @/home/vagrant/ansible/playbooks/webserver.retry

PLAY RECAP *********************************************************************
app01                      : ok=1    changed=0    unreachable=0    failed=1   
app02                      : ok=1    changed=0    unreachable=0    failed=1   

Ansible playbook :

---
- hosts: webserver
  become: true
  tasks:
    - name: install web components
      apt: name={{item}} state=present update_cache=yes
      with_items:
        - apache2
        - libapache2-mod-wsgi
        - python-pip
        - python-virtualenv
        - python-mysqldb

I'm trying to install few mysql modules on apache app servers but this particular module is blocking me moving forward. I'm clueless at the moment. It would be of great help if someone can help me.

Many Thanks in advance.

harshavmb
  • 3,404
  • 3
  • 21
  • 55
  • Are you able to install it manually? Without Ansible? – Moinuddin Quadri Nov 19 '16 at 15:39
  • Thanks Quadri, but I'm not sure how to install without ansible. Any link you can suggest? I too think some issue with app servers rather ansible. – harshavmb Nov 19 '16 at 15:41
  • I think the issue is that rest of the package you are instaling are debian package and are installed via `apt-get` where as `myql-python` is python package installed via `pip`. You may see: http://stackoverflow.com/questions/25865270/how-to-install-python-mysqldb-module-using-pip as reference. I do not know about *Ansible* but I am pretty sure that the cause of issue is what I mentioned – Moinuddin Quadri Nov 19 '16 at 15:46
  • Seeing below error while installing manually. Install these packages without verification? [y/N] y Err http://archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-common all 5.5.53-0ubuntu0.14.04.1 Could not resolve 'archive.ubuntu.com' Err http://archive.ubuntu.com/ubuntu/ trusty/main zlib1g-dev amd64 1:1.2.8.dfsg-1ubuntu1 Could not resolve 'archive.ubuntu.com' – harshavmb Nov 19 '16 at 15:55
  • any issue with ubuntu repositories? – harshavmb Nov 19 '16 at 15:56
  • Firstly do `sudo apt-get update` and then try installing the libraries – Moinuddin Quadri Nov 19 '16 at 15:57
  • Thanks.. trying now... – harshavmb Nov 19 '16 at 15:57
  • I resolved the issue. It is the firewall issue. Ran sudo ufw disable command and then I'm able to connect to remote repositories. link: http://askubuntu.com/questions/250775/how-do-i-turn-off-the-firewall-in-ubuntu-12-04 Thanks a lot for your help – harshavmb Nov 19 '16 at 16:21
  • You should add that as an answer to your question. May be it will help someone facing the same issue in future :) – Moinuddin Quadri Nov 19 '16 at 16:23
  • 1
    Done.. :) Thanks a lot for your help. – harshavmb Nov 19 '16 at 16:28

1 Answers1

1

After debugging app servers further I came to know the root cause.

App servers were failing to connect to remote repositories. I ran the below command to turn off the firewall as I'm using the vagrant ubuntu boxes.

sudo ufw disable

It may not be the viable option for the ubuntu boxes within an organization as they are bound to firewall policies.

harshavmb
  • 3,404
  • 3
  • 21
  • 55