ansible / ansible-modules-core

Ansible modules - these modules ship with ansible
1.3k stars 1.95k forks source link

apache2_module fails for libapache2-mod-proxy-uwsgi #5455

Closed brantlk closed 7 years ago

brantlk commented 7 years ago
ISSUE TYPE
COMPONENT NAME

apache2_module

ANSIBLE VERSION
$ ./ansible --version
ansible 2.2.0.0
  config file = 
  configured module search path = Default w/o overrides
CONFIGURATION

None

OS / ENVIRONMENT

Ubuntu 14.04

SUMMARY

A playbook that was working with ansible 2.1.2.0 started failing when 2.2.0.0 was released. The playbook:

1) apt installs a bunch of packages, including apache2, libapache2-mod-proxy-html, and libapache2-mod-proxy-uwsgi, uwsgi, etc. 2) Uses apache2_module to enable proxy_http

Analysis

The apache2_module module was changed to use apache2ctl -M to list modules in 2.2.0.0, which fails with the playbook due to an oddity of the Ubuntu packages:

But, mod_proxy_uwsgi requires mod_proxy_http to be enabled, and since mod_proxy_uwsgi is enabled but mod_proxy_http is disabled, apache2ctl -M fails with a confusing error (see output below)

See https://github.com/ansible/ansible-modules-core/pull/2417 for the change that added use of apache2ctl -M.

A potential fix is to provide special handling for mod_proxy_uwsgi so that it doesn't use apache2ctl -M or something.

STEPS TO REPRODUCE
- name: Install packages
  become: true
  apt: name={{ item }}
  with_items:
    - apache2
    - git
    - libapache2-mod-proxy-html
    - libapache2-mod-proxy-uwsgi
    - python-dev
    - python-pip
    - python-virtualenv
    - uwsgi-emperor
    - uwsgi-plugin-python

- name: Enable modules for mod_proxy_uwsgi
  become: true
  apache2_module: name={{ item }}
  with_items:
    - proxy_http
  notify:
    - Restart httpd
EXPECTED RESULTS

Expected the old playbook to work.

ACTUAL RESULTS
failed: [default] (item=proxy_http) => {
    "failed": true, 
    "invocation": {
        "module_args": {
            "force": false, 
            "name": "proxy_http", 
            "state": "present"
        }, 
        "module_name": "apache2_module"
    }, 
    "item": "proxy_http", 
    "msg": "Error executing /usr/sbin/apache2ctl: apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/proxy_uwsgi.load: Cannot load /usr/lib/apache2/modules/mod_proxy_uwsgi.so into server: /usr/lib/apache2/modules/mod_proxy_uwsgi.so: undefined symbol: ap_proxy_backend_broke\n"
}

As you can see the error isn't very useful as far as figuring out the problem.

Workaround

The following steps worked around the issue:

- name: Install packages
  become: true
  apt: name={{ item }}
  with_items:
    - apache2
    - git
    - libapache2-mod-proxy-html
    - python-dev
    - python-pip
    - python-virtualenv
    - uwsgi-emperor
    - uwsgi-plugin-python
- name: Enable modules for mod_proxy_uwsgi
  become: true
  apache2_module: name={{ item }}
  with_items:
    - proxy_http
  notify:
    - Restart httpd
- name: Install mod-proxy-uwsgi
  become: true
  apt: name={{ item }}
  with_items:
    - libapache2-mod-proxy-uwsgi
  notify:
    - Restart httpd
ansibot commented 7 years ago

@robinro ping, this issue is waiting for your response. click here for bot help

robinro commented 7 years ago

@brantlk Thanks for reporting this issue.

The core of the problem is the upstream package. If I run apt install apache2 libapache2-mod-proxy-html libapache2-mod-proxy-uwsgi I get

Setting up libapache2-mod-proxy-html (1:2.4.7-1ubuntu4.13) ...
Setting up libapache2-mod-proxy-uwsgi (1.9.17.1-5build5) ...
apache2_invoke: Enable module proxy_uwsgi
Action 'configtest' failed.
The Apache error log may have more information.
apache2_reload: Your configuration is broken. Not restarting Apache 2

So the official installation leaves apache in a state where it can not be started. Please report this bug to ubuntu. There is a related bugreport (and supposed fix) in debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=785610

Since this is a bug upstream and you already have a workaround I'll close this as wontfix

There is currently another issue discussing the use of apachectl -M: #5328 Maybe there will be a nicer workaround that you could also use in this case.