Repository: certbot/certbot

Issue:
certbot fails with "AttributeError: 'NoneType' object has no attribute 'strip'"
I did the following:
<pre>
sudo yum update
sudo yum install httpd mod_ssl python-certbot-apache
sudo systemctl start httpd
systemctl status httpd
sudo certbot --apache -d example.com -d www.example.com
</pre>

certbot --version
  certbot 0.9.3

rpm --query centos-release
  centos-release-7-3.1611.el7.centos.x86_64

Command line doesn't seem to matter. I tried:
  certbot
  certbot --apache
  sudo certbot --apache -d example.com -d www.example.com

In all cases certbot fails almost immediately with the error:

"AttributeError: 'NoneType' object has no attribute 'strip'"

It shows the blue window and immediately fails.

Here's the letsencrypt.log:

<pre>
2017-02-22 20:21:45,928:DEBUG:certbot.main:Root logging level set at 20
2017-02-22 20:21:45,928:INFO:certbot.main:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2017-02-22 20:21:45,932:DEBUG:certbot.main:certbot version: 0.9.3
2017-02-22 20:21:45,932:DEBUG:certbot.main:Arguments: ['--apache', '-d', 'domain.com', '-d', 'www.domain.com']
2017-02-22 20:21:45,932:DEBUG:certbot.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#apache,PluginEntryPoint#webroot,PluginEntryPoint#null,PluginEntryPoint#manual,PluginEntryPoint#standalone)
2017-02-22 20:21:45,934:DEBUG:certbot.plugins.selection:Requested authenticator apache and installer apache
2017-02-22 20:21:46,202:DEBUG:certbot.main:Exiting abnormally:
Traceback (most recent call last):
  File "/bin/certbot", line 9, in <module>
    load_entry_point('certbot==0.9.3', 'console_scripts', 'certbot')()
  File "/usr/lib/python2.7/site-packages/certbot/main.py", line 776, in main
    return config.func(config, plugins)
  File "/usr/lib/python2.7/site-packages/certbot/main.py", line 502, in run
    installer, authenticator = plug_sel.choose_configurator_plugins(config, plugins, "run")
  File "/usr/lib/python2.7/site-packages/certbot/plugins/selection.py", line 185, in choose_configurator_plugins
    authenticator = installer = pick_configurator(config, req_inst, plugins)
  File "/usr/lib/python2.7/site-packages/certbot/plugins/selection.py", line 25, in pick_configurator
    (interfaces.IAuthenticator, interfaces.IInstaller))
  File "/usr/lib/python2.7/site-packages/certbot/plugins/selection.py", line 77, in pick_plugin
    verified.prepare()
  File "/usr/lib/python2.7/site-packages/certbot/plugins/disco.py", line 220, in prepare
    return [plugin_ep.prepare() for plugin_ep in six.itervalues(self._plugins)]
  File "/usr/lib/python2.7/site-packages/certbot/plugins/disco.py", line 106, in prepare
    self._initialized.prepare()
  File "/usr/lib/python2.7/site-packages/certbot_apache/configurator.py", line 188, in prepare
    self.version)
  File "/usr/lib/python2.7/site-packages/certbot_apache/parser.py", line 58, in __init__
    self.init_modules()
  File "/usr/lib/python2.7/site-packages/certbot_apache/parser.py", line 92, in init_modules
    self.modules.add(self.get_arg(match_name))
  File "/usr/lib/python2.7/site-packages/certbot_apache/parser.py", line 339, in get_arg
    value = value.strip("'\"")
AttributeError: 'NoneType' object has no attribute 'strip'
</pre>

Any help would be appreciated.


Discussion:
It sounds like it couldn't find your LoadModule directory or it was empty?
(for reference here is the code from that release: https://github.com/certbot/certbot/blob/82ac89b850e77481028c1e055cda6cd01501f3a4/certbot-apache/certbot_apache/parser.py#L72 )
@bmw any ideas?
Is there anything that I can do to make it work?
I have uninstalled certbot 0.9.3 and downloaded 0.11.1 with the following commands:

yum remove python-certbot-apache
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
./certbot-auto

And I still get the error. Here's my letsencrypt.log:

<pre>
2017-02-26 17:26:14,668:DEBUG:certbot.main:Root logging level set at 20
2017-02-26 17:26:14,668:INFO:certbot.main:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2017-02-26 17:26:14,668:DEBUG:certbot.main:certbot version: 0.11.1
2017-02-26 17:26:14,668:DEBUG:certbot.main:Arguments: []
2017-02-26 17:26:14,668:DEBUG:certbot.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#nginx,PluginEntryPoint#standalone,PluginEntryPoint#manual,PluginEntryPoint#webroot,PluginEntryPoint#apache,Plu$
2017-02-26 17:26:14,668:DEBUG:certbot.plugins.selection:Requested authenticator None and installer None
2017-02-26 17:26:16,794:DEBUG:certbot.main:Exiting abnormally:
Traceback (most recent call last):
  File "/root/.local/share/letsencrypt/bin/letsencrypt", line 11, in <module>
    sys.exit(main())
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/certbot/main.py", line 882, in main
    return config.func(config, plugins)
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/certbot/main.py", line 599, in run
    installer, authenticator = plug_sel.choose_configurator_plugins(config, plugins, "run")
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/certbot/plugins/selection.py", line 185, in choose_configurator_plugins
    authenticator = installer = pick_configurator(config, req_inst, plugins)
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/certbot/plugins/selection.py", line 25, in pick_configurator
    (interfaces.IAuthenticator, interfaces.IInstaller))
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/certbot/plugins/selection.py", line 77, in pick_plugin
    verified.prepare()
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/certbot/plugins/disco.py", line 228, in prepare
    return [plugin_ep.prepare() for plugin_ep in six.itervalues(self._plugins)]
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/certbot/plugins/disco.py", line 114, in prepare
    self._initialized.prepare()
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/certbot_apache/configurator.py", line 189, in prepare
    self.version)
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/certbot_apache/parser.py", line 58, in __init__
    self.init_modules()
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/certbot_apache/parser.py", line 92, in init_modules
    self.modules.add(self.get_arg(match_name))
  File "/root/.local/share/letsencrypt/lib/python2.7/site-packages/certbot_apache/parser.py", line 339, in get_arg
    value = value.strip("'\"")
AttributeError: 'NoneType' object has no attribute 'strip'</pre>

pinging @bmw again - since I'm at a loss
I still can't seem to get it to work. This is a recent install of an up to date operating system on new hardware. I can't imagine why it's not a slam dunk.
The 0.11.1 release of certbot (including the apache plugin) is now in the EPEL7 repos  @scubanarc  can you please give that a try and see if you still have problems?

Make sure you clear out any pip installed certbot or modules for it before you do
Thanks for the help @hogarthj but it still isn't working.

I made sure that there were no traces of certbot left:

(as root)
<pre>yum remove python2-certbot
pip uninstall certbot
rm -rf /root/.local
updatedb
locate | grep "certbot"
</pre>

Came back clean. Then I installed the 0.11.1 release using yum. It seemed to install fine:

<pre>
yum install python2-certbot-apache
Running transaction
  Installing : python2-future-0.16.0-2.el7.noarch                                                                                                                                                          1/6
  Updating   : python2-acme-0.11.1-1.el7.noarch                                                                                                                                                            2/6
  Installing : python2-certbot-0.11.1-2.el7.noarch                                                                                                                                                         3/6
  Installing : certbot-0.11.1-2.el7.noarch                                                                                                                                                                 4/6
  Installing : python2-certbot-apache-0.11.1-1.el7.noarch                                                                                                                                                  5/6
  Cleanup    : python2-acme-0.9.3-1.el7.noarch                                                                                                                                                             6/6
  Verifying  : python2-certbot-apache-0.11.1-1.el7.noarch                                                                                                                                                  1/6
  Verifying  : python2-certbot-0.11.1-2.el7.noarch                                                                                                                                                         2/6
  Verifying  : python2-acme-0.11.1-1.el7.noarch                                                                                                                                                            3/6
  Verifying  : python2-future-0.16.0-2.el7.noarch                                                                                                                                                          4/6
  Verifying  : certbot-0.11.1-2.el7.noarch                                                                                                                                                                 5/6
  Verifying  : python2-acme-0.9.3-1.el7.noarch                                                                                                                                                             6/6

Installed:
  python2-certbot-apache.noarch 0:0.11.1-1.el7

Dependency Installed:
  certbot.noarch 0:0.11.1-2.el7                                  python2-certbot.noarch 0:0.11.1-2.el7                                  python2-future.noarch 0:0.16.0-2.el7

Dependency Updated:
  python2-acme.noarch 0:0.11.1-1.el7

Complete!</pre>

But certbot still fails no matter what I do, even on an empty command line:

<pre> certbot
Saving debug log to /var/log/letsencrypt/letsencrypt.log
An unexpected error occurred:
AttributeError: 'NoneType' object has no attribute 'strip'
Please see the logfiles in /var/log/letsencrypt for more details.
</pre>

Here's the logfile:
<pre>2017-03-02 16:59:50,931:DEBUG:certbot.main:Root logging level set at 20
2017-03-02 16:59:50,932:INFO:certbot.main:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2017-03-02 16:59:50,932:DEBUG:certbot.main:certbot version: 0.11.1
2017-03-02 16:59:50,932:DEBUG:certbot.main:Arguments: []
2017-03-02 16:59:50,932:DEBUG:certbot.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#apache,PluginEntryPoint#webroot,PluginEntryPoint#null,PluginEntryPoint#manual,PluginEntryPoint#standalone)
2017-03-02 16:59:50,932:DEBUG:certbot.plugins.selection:Requested authenticator None and installer None
2017-03-02 16:59:51,203:DEBUG:certbot.main:Exiting abnormally:
Traceback (most recent call last):
  File "/bin/certbot", line 9, in <module>
    load_entry_point('certbot==0.11.1', 'console_scripts', 'certbot')()
  File "/usr/lib/python2.7/site-packages/certbot/main.py", line 882, in main
    return config.func(config, plugins)
  File "/usr/lib/python2.7/site-packages/certbot/main.py", line 599, in run
    installer, authenticator = plug_sel.choose_configurator_plugins(config, plugins, "run")
  File "/usr/lib/python2.7/site-packages/certbot/plugins/selection.py", line 185, in choose_configurator_plugins
    authenticator = installer = pick_configurator(config, req_inst, plugins)
  File "/usr/lib/python2.7/site-packages/certbot/plugins/selection.py", line 25, in pick_configurator
    (interfaces.IAuthenticator, interfaces.IInstaller))
  File "/usr/lib/python2.7/site-packages/certbot/plugins/selection.py", line 77, in pick_plugin
    verified.prepare()
  File "/usr/lib/python2.7/site-packages/certbot/plugins/disco.py", line 228, in prepare
    return [plugin_ep.prepare() for plugin_ep in six.itervalues(self._plugins)]
  File "/usr/lib/python2.7/site-packages/certbot/plugins/disco.py", line 114, in prepare
    self._initialized.prepare()
  File "/usr/lib/python2.7/site-packages/certbot_apache/configurator.py", line 189, in prepare
    self.version)
  File "/usr/lib/python2.7/site-packages/certbot_apache/parser.py", line 58, in __init__
    self.init_modules()
  File "/usr/lib/python2.7/site-packages/certbot_apache/parser.py", line 92, in init_modules
    self.modules.add(self.get_arg(match_name))
  File "/usr/lib/python2.7/site-packages/certbot_apache/parser.py", line 339, in get_arg
    value = value.strip("'\"")
AttributeError: 'NoneType' object has no attribute 'strip'</pre>

I appreciate any advice you can give.

I think our parser is tripping up parsing your `LoadModule` directives. Assuming your Apache config is in `/etc/httpd`, can you paste the output of `grep -C 1 -r LoadModule /etc/httpd`?

@joohoi, might have some other ideas too.
Sure thing. Here it is:

<pre>
/etc/httpd/conf/httpd.conf-# To be able to use the functionality of a module which was built as a DSO you
/etc/httpd/conf/httpd.conf:# have to place corresponding `LoadModule' lines at this location so the
/etc/httpd/conf/httpd.conf-# directives contained in it are actually available _before_ they are used.
--
/etc/httpd/conf/httpd.conf-# Example:
/etc/httpd/conf/httpd.conf:# LoadModule foo_module modules/mod_foo.so
/etc/httpd/conf/httpd.conf-#
--
/etc/httpd/conf.d/mod_mono.conf-<IfModule !mod_mono.c>
/etc/httpd/conf.d/mod_mono.conf:    LoadModule mono_module /usr/lib64/httpd/modules/mod_mono.so
/etc/httpd/conf.d/mod_mono.conf-</IfModule>
--
/etc/httpd/conf.modules.d/00-base.conf-
/etc/httpd/conf.modules.d/00-base.conf:LoadModule access_compat_module modules/mod_access_compat.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule actions_module modules/mod_actions.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule alias_module modules/mod_alias.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule allowmethods_module modules/mod_allowmethods.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule auth_basic_module modules/mod_auth_basic.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule auth_digest_module modules/mod_auth_digest.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule authn_anon_module modules/mod_authn_anon.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule authn_core_module modules/mod_authn_core.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule authn_dbd_module modules/mod_authn_dbd.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule authn_dbm_module modules/mod_authn_dbm.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule authn_file_module modules/mod_authn_file.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule authn_socache_module modules/mod_authn_socache.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule authz_core_module modules/mod_authz_core.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule authz_dbd_module modules/mod_authz_dbd.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule authz_dbm_module modules/mod_authz_dbm.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule authz_host_module modules/mod_authz_host.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule authz_owner_module modules/mod_authz_owner.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule authz_user_module modules/mod_authz_user.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule autoindex_module modules/mod_autoindex.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule cache_module modules/mod_cache.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule cache_disk_module modules/mod_cache_disk.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule data_module modules/mod_data.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule dbd_module modules/mod_dbd.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule deflate_module modules/mod_deflate.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule dir_module modules/mod_dir.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule dumpio_module modules/mod_dumpio.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule echo_module modules/mod_echo.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule env_module modules/mod_env.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule expires_module modules/mod_expires.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule ext_filter_module modules/mod_ext_filter.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule filter_module modules/mod_filter.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule headers_module modules/mod_headers.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule include_module modules/mod_include.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule info_module modules/mod_info.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule log_config_module modules/mod_log_config.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule logio_module modules/mod_logio.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule mime_magic_module modules/mod_mime_magic.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule mime_module modules/mod_mime.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule negotiation_module modules/mod_negotiation.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule remoteip_module modules/mod_remoteip.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule reqtimeout_module modules/mod_reqtimeout.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule rewrite_module modules/mod_rewrite.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule setenvif_module modules/mod_setenvif.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule slotmem_plain_module modules/mod_slotmem_plain.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule socache_dbm_module modules/mod_socache_dbm.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule socache_memcache_module modules/mod_socache_memcache.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule status_module modules/mod_status.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule substitute_module modules/mod_substitute.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule suexec_module modules/mod_suexec.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule unique_id_module modules/mod_unique_id.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule unixd_module modules/mod_unixd.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule userdir_module modules/mod_userdir.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule version_module modules/mod_version.so
/etc/httpd/conf.modules.d/00-base.conf:LoadModule vhost_alias_module modules/mod_vhost_alias.so
/etc/httpd/conf.modules.d/00-base.conf-
/etc/httpd/conf.modules.d/00-base.conf:#LoadModule buffer_module modules/mod_buffer.so
/etc/httpd/conf.modules.d/00-base.conf:#LoadModule watchdog_module modules/mod_watchdog.so
/etc/httpd/conf.modules.d/00-base.conf:#LoadModule heartbeat_module modules/mod_heartbeat.so
/etc/httpd/conf.modules.d/00-base.conf:#LoadModule heartmonitor_module modules/mod_heartmonitor.so
/etc/httpd/conf.modules.d/00-base.conf:#LoadModule usertrack_module modules/mod_usertrack.so
/etc/httpd/conf.modules.d/00-base.conf:#LoadModule dialup_module modules/mod_dialup.so
/etc/httpd/conf.modules.d/00-base.conf:#LoadModule charset_lite_module modules/mod_charset_lite.so
/etc/httpd/conf.modules.d/00-base.conf:#LoadModule log_debug_module modules/mod_log_debug.so
/etc/httpd/conf.modules.d/00-base.conf:#LoadModule ratelimit_module modules/mod_ratelimit.so
/etc/httpd/conf.modules.d/00-base.conf:#LoadModule reflector_module modules/mod_reflector.so
/etc/httpd/conf.modules.d/00-base.conf:#LoadModule request_module modules/mod_request.so
/etc/httpd/conf.modules.d/00-base.conf:#LoadModule sed_module modules/mod_sed.so
/etc/httpd/conf.modules.d/00-base.conf:#LoadModule speling_module modules/mod_speling.so
/etc/httpd/conf.modules.d/00-base.conf-
--
/etc/httpd/conf.modules.d/00-dav.conf:LoadModule dav_module modules/mod_dav.so
/etc/httpd/conf.modules.d/00-dav.conf:LoadModule dav_fs_module modules/mod_dav_fs.so
/etc/httpd/conf.modules.d/00-dav.conf:LoadModule dav_lock_module modules/mod_dav_lock.so
--
/etc/httpd/conf.modules.d/00-lua.conf:LoadModule lua_module modules/mod_lua.so
--
/etc/httpd/conf.modules.d/00-mpm.conf-# Select the MPM module which should be used by uncommenting exactly
/etc/httpd/conf.modules.d/00-mpm.conf:# one of the following LoadModule lines:
/etc/httpd/conf.modules.d/00-mpm.conf-
--
/etc/httpd/conf.modules.d/00-mpm.conf-# See: http://httpd.apache.org/docs/2.4/mod/prefork.html
/etc/httpd/conf.modules.d/00-mpm.conf:LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
/etc/httpd/conf.modules.d/00-mpm.conf-
--
/etc/httpd/conf.modules.d/00-mpm.conf-#
/etc/httpd/conf.modules.d/00-mpm.conf:#LoadModule mpm_worker_module modules/mod_mpm_worker.so
/etc/httpd/conf.modules.d/00-mpm.conf-
--
/etc/httpd/conf.modules.d/00-mpm.conf-#
/etc/httpd/conf.modules.d/00-mpm.conf:#LoadModule mpm_event_module modules/mod_mpm_event.so
/etc/httpd/conf.modules.d/00-mpm.conf-
--
/etc/httpd/conf.modules.d/00-proxy.conf-# This file configures all the proxy modules:
/etc/httpd/conf.modules.d/00-proxy.conf:LoadModule proxy_module modules/mod_proxy.so
/etc/httpd/conf.modules.d/00-proxy.conf:LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so
/etc/httpd/conf.modules.d/00-proxy.conf:LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
/etc/httpd/conf.modules.d/00-proxy.conf:LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so
/etc/httpd/conf.modules.d/00-proxy.conf:LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so
/etc/httpd/conf.modules.d/00-proxy.conf:LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
/etc/httpd/conf.modules.d/00-proxy.conf:LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
/etc/httpd/conf.modules.d/00-proxy.conf:LoadModule proxy_connect_module modules/mod_proxy_connect.so
/etc/httpd/conf.modules.d/00-proxy.conf:LoadModule proxy_express_module modules/mod_proxy_express.so
/etc/httpd/conf.modules.d/00-proxy.conf:LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
/etc/httpd/conf.modules.d/00-proxy.conf:LoadModule proxy_fdpass_module modules/mod_proxy_fdpass.so
/etc/httpd/conf.modules.d/00-proxy.conf:LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
/etc/httpd/conf.modules.d/00-proxy.conf:LoadModule proxy_http_module modules/mod_proxy_http.so
/etc/httpd/conf.modules.d/00-proxy.conf:LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
/etc/httpd/conf.modules.d/00-proxy.conf:LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
--
/etc/httpd/conf.modules.d/00-systemd.conf-# This file configures systemd module:
/etc/httpd/conf.modules.d/00-systemd.conf:LoadModule systemd_module modules/mod_systemd.so
--
/etc/httpd/conf.modules.d/01-cgi.conf-<IfModule mpm_worker_module>
/etc/httpd/conf.modules.d/01-cgi.conf:   LoadModule cgid_module modules/mod_cgid.so
/etc/httpd/conf.modules.d/01-cgi.conf-</IfModule>
/etc/httpd/conf.modules.d/01-cgi.conf-<IfModule mpm_event_module>
/etc/httpd/conf.modules.d/01-cgi.conf:   LoadModule cgid_module modules/mod_cgid.so
/etc/httpd/conf.modules.d/01-cgi.conf-</IfModule>
/etc/httpd/conf.modules.d/01-cgi.conf-<IfModule mpm_prefork_module>
/etc/httpd/conf.modules.d/01-cgi.conf:   LoadModule cgi_module modules/mod_cgi.so
/etc/httpd/conf.modules.d/01-cgi.conf-</IfModule>
--
/etc/httpd/conf.modules.d/10-fcgid.conf:LoadModule fcgid_module modules/mod_fcgid.so
--
/etc/httpd/conf.modules.d/00-ssl.conf:LoadModule ssl_module modules/mod_ssl.so
--
/etc/httpd/conf.modules.d/10-php.conf-<IfModule prefork.c>
/etc/httpd/conf.modules.d/10-php.conf:  LoadModule php5_module modules/libphp5.so
/etc/httpd/conf.modules.d/10-php.conf-</IfModule>
</pre>

This is a pretty fresh install and I have not edited much, so it should be pretty stock.
@joohoi @bmw Thanks for your help so far. I'm running out of time on my existing cert and would really love to get this working. Any suggestions?
I'm sorry it's taking a bit to get hold of this @scubanarc . I'm currently AFK, but taking a wild guess, it could be the comment in httpd.conf,  you could try removing the line:
```# have to place corresponding `LoadModule'```

We'll get down to the actual reason and fix it properly on the Certbot side, but this could remedy the situation at hand.
Removing that line didn't seem to help, but I have some more debug info for you guys. I modified /usr/lib/python2.7/site-packages/certbot_apache/parser.py and added: print(match_name) on line 92 like this:

<pre>            for match_name, match_filename in itertools.izip(
                    iterator, iterator):
                print(match_name)
                self.modules.add(self.get_arg(match_name))</pre>

This let me see what the last module processed was before the error. So I learned that the bug is most likely related to mod_mono.conf:

<pre>/files/etc/httpd/conf.d/mod_mono.conf/IfModule/directive/arg[1]</pre>

Here's the contents of mod_mono.conf:

<pre># mod_mono.conf

# Achtung! This file may be overwritten
# Use 'include mod_mono.conf' from other configuration file
# to load mod_mono module.

MonoAutoApplication enabled
MonoServerPath "/usr/bin/mod-mono-server4"

<IfModule !mod_mono.c>
   LoadModule mono_module /usr/lib64/httpd/modules/mod_mono.so
</IfModule>

<IfModule mod_headers.c>
    Header set X-Powered-By "Mono"
</IfModule>

AddType application/x-asp-net .aspx
AddType application/x-asp-net .asmx
AddType application/x-asp-net .ashx
AddType application/x-asp-net .asax
AddType application/x-asp-net .ascx
AddType application/x-asp-net .soap
AddType application/x-asp-net .rem
AddType application/x-asp-net .axd
AddType application/x-asp-net .cs
AddType application/x-asp-net .vb
AddType application/x-asp-net .master
AddType application/x-asp-net .sitemap
AddType application/x-asp-net .resources
AddType application/x-asp-net .skin
AddType application/x-asp-net .browser
AddType application/x-asp-net .webinfo
AddType application/x-asp-net .resx
AddType application/x-asp-net .licx
AddType application/x-asp-net .csproj
AddType application/x-asp-net .vbproj
AddType application/x-asp-net .config
AddType application/x-asp-net .Config
AddType application/x-asp-net .dll
DirectoryIndex index.aspx
DirectoryIndex Default.aspx
DirectoryIndex default.aspx
</pre>

That's an auto-generated file. I tried commenting out the IfModule blocks which definitely fixed the parser.py problem, but then created some new expected errors because certbot was not able to understand the mod_mono.conf file.
SUCCESS!

Even more info. With a tiny edit in parser.py I was able to make it work and got my cert issued and installed. Here's what I did. In parser.py starting at line 337 inside get_arg():

<pre>        # Note: normal argument may be a quoted variable
        # e.g. strip now, not later
        if value is None:
                value = ''
        value = value.strip("'\"")</pre>

I added a null check to value and assigned an empty string if value is null. Seems to clear up the parse and make it all work.

Should I go through the effort of git and pull request to suggest this, or do one of you want to do it?
This is really confusing to me - it's finding the arg, but then it's returning empty on a get?
When I run locally with augtool I don't get the inserted IfModule, instead I get /files/etc/apache2/sites-available/test4245.conf/directive[3]/arg[1] though I'm not sure if that means anything.
Additionally I'm worried that we have a bug when parsing a directive with multiple arguements. Here we're supposed to make sure to load all the same things as the LoadModule, but we're just plucking the first.
I'd almost say the issue is that we're querying for /files/etc/httpd/conf.d/mod_mono.conf/IfModule/directive/arg since that's how augeas would show it if there was only one arg, but you clearly have output showing it with the [1].
@joohoi do you have thoughts on this? Do you think we're dropping [2]s from our search?
It's been 3 months and no one has added this 2 line change to parser.py that will fix it.

I tried to renew today and this bug was back so I edited parser.py again and this bug went away.

Should I issue a pull request for this simple fix?
@scubanarc yes please - and then if you could tag me and @joohoi in it it'd be really appreciated - thanks for keeping an eye on this. Feel free to close this issue once you open the PR and we can discuss it there!
@scubanarc has this issue gone away with newer issues of certbot? If not are you still planning on opening a PR?
I'm not sure. I have been running with an edited parser.py and have no problems. My certs aren't due until October 28th so I can test then, unless there is a way to test early. I can edit parser.py back to the original and try, but with the certs not due I'm not sure it's a valid test.
Have you updated your version of certbot? If not, it's likely that reverting parser.py will make it fail again.
You can always force renewal early, so you should be able to test whenever you'd like
I did the following:
> yum update
> (verify that parser.py changed, and it did)
> certbot renew --force-renew

And it failed with:

> Attempting to renew cert from /etc/letsencrypt/renewal/domainname.com.conf produced an unexpected error: 'NoneType' object has no attribute 'strip'. Skipping.

I fixed it by editing line 342 in parser.py as before and added the same code as before:

> if value is None:
>         value = ''
> value = value.strip("'\"")

I planned on doing a PR for this but I'm not too familiar with git and I'd rather not mess things up.


Resolving patch:
diff --git a/certbot-apache/certbot_apache/parser.py b/certbot-apache/certbot_apache/parser.py
--- a/certbot-apache/certbot_apache/parser.py
+++ b/certbot-apache/certbot_apache/parser.py
@@ -123,9 +123,14 @@ def init_modules(self):
 
             for match_name, match_filename in six.moves.zip(
                     iterator, iterator):
-                self.modules.add(self.get_arg(match_name))
-                self.modules.add(
-                    os.path.basename(self.get_arg(match_filename))[:-2] + "c")
+                mod_name = self.get_arg(match_name)
+                mod_filename = self.get_arg(match_filename)
+                if mod_name and mod_filename:
+                    self.modules.add(mod_name)
+                    self.modules.add(os.path.basename(mod_filename)[:-2] + "c")
+                else:
+                    logger.debug("Could not read LoadModule directive from " +
+                                 "Augeas path: {0}".format(match_name[6:]))
 
     def update_runtime_variables(self):
         """"
@@ -371,7 +376,10 @@ def get_arg(self, match):
 
         # Note: normal argument may be a quoted variable
         # e.g. strip now, not later
-        value = value.strip("'\"")
+        if not value:
+            return None
+        else:
+            value = value.strip("'\"")
 
         variables = ApacheParser.arg_var_interpreter.findall(value)
 


Test patch:
diff --git a/certbot-apache/certbot_apache/tests/parser_test.py b/certbot-apache/certbot_apache/tests/parser_test.py
--- a/certbot-apache/certbot_apache/tests/parser_test.py
+++ b/certbot-apache/certbot_apache/tests/parser_test.py
@@ -66,6 +66,10 @@ def test_add_dir(self):
         for i, match in enumerate(matches):
             self.assertEqual(self.parser.aug.get(match), str(i + 1))
 
+    def test_empty_arg(self):
+        self.assertEquals(None,
+                          self.parser.get_arg("/files/whatever/nonexistent"))
+
     def test_add_dir_to_ifmodssl(self):
         """test add_dir_to_ifmodssl.
 
@@ -114,6 +118,16 @@ def test_set_locations(self):
             self.assertEqual(results["default"], results["listen"])
             self.assertEqual(results["default"], results["name"])
 
+    @mock.patch("certbot_apache.parser.ApacheParser.find_dir")
+    @mock.patch("certbot_apache.parser.ApacheParser.get_arg")
+    def test_init_modules_bad_syntax(self, mock_arg, mock_find):
+        mock_find.return_value = ["1", "2", "3", "4", "5", "6", "7", "8"]
+        mock_arg.return_value = None
+        with mock.patch("certbot_apache.parser.logger") as mock_logger:
+            self.parser.init_modules()
+            # Make sure that we got None return value and logged the file
+            self.assertTrue(mock_logger.debug.called)
+
     @mock.patch("certbot_apache.parser.ApacheParser._get_runtime_cfg")
     def test_update_runtime_variables(self, mock_cfg):
         mock_cfg.return_value = (