apache2: Infinite loop from apache2_mod_auth_cas and apache2_module 'auth_cas' resources

đź‘» Brief Description

Simply using apache2_mod_auth_cas 'auth_cas' results in an infinite loop which eventually causes my chef-client run to fail. Sample logging:

  * directory[/var/cache/mod_auth_cas/] action create (up to date)
  * apache2_mod_auth_cas[auth_cas] action install
    * file[/etc/httpd/conf.d/auth_cas.conf] action create (skipped due to only_if)
    * apache2_module[auth_cas] action enable
      * apache2_mod_auth_cas[default] action install
        * file[/etc/httpd/conf.d/auth_cas.conf] action create (skipped due to only_if)
        * apache2_module[auth_cas] action enable
          * apache2_mod_auth_cas[default] action install
            * file[/etc/httpd/conf.d/auth_cas.conf] action create (skipped due to only_if)
            * apache2_module[auth_cas] action enable
              * apache2_mod_auth_cas[default] action install
                ...

🥞 Cookbook version

depends 'apache2', '~> 8.9.1'

👩‍🍳 Chef-Infra Version

[~]# chef-client --version
Chef Infra Client: 15.15.1

🎩 Platform details

Latest AWS Amazon Linux 2 AMI (ami-0915bcb5fa77e4892)

Steps To Reproduce

Steps to reproduce the behavior:

  1. Add the apache2_mod_auth_cas resource as-is to a wrapper cookbook
  2. Run chef-client
  3. Notice the infinite loop

đźš“ Expected behavior

No infinite looping and successful Chef Infra run.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 28 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Er, my fault I forgot to delete the cached apache2 cookbook which didn’t have your recent change in it.

I confirmed that I am seeing an Apache reload when the directives change.

If I don’t hear back from you within the next day, I’ll just go ahead and release this PR since I think it’s close enough.

@ramereth I was able to get around to testing your branch and confirmed I no longer run into the infinite loop and the generated config file is as expected (i.e. with the added directives).

For reference, here’s a snippet of the check in once I pointed to your branch:

    * yum_package[mod_auth_cas] action install (up to date)
    * directory[purge distro conf.modules.d] action nothing (skipped due to action :nothing)
    * directory[purge distro conf.d] action nothing (skipped due to action :nothing)
    * file[/etc/httpd/conf.d/auth_cas.conf] action create (skipped due to only_if)
    * apache2_module[auth_cas] action enable
      * template[/etc/httpd/mods-available/auth_cas.conf] action create
        - create new file /etc/httpd/mods-available/auth_cas.conf
        - update content in file /etc/httpd/mods-available/auth_cas.conf from none to a25cb9
        --- /etc/httpd/mods-available/auth_cas.conf	2021-03-31 16:39:02.048184444 +0000
        +++ /etc/httpd/mods-available/.chef-auth_cas20210331-2771-ko09zw.conf	2021-03-31 16:39:02.048184444 +0000
        @@ -1,9 +1,18 @@
        +CASCookiePath /var/cache/httpd/mod_auth_cas/
        +CASLoginURL https://cas.example.com/idp/profile/cas/login
        +CASValidateURL https://cas.example.com/idp/profile/cas/serviceValidate
        +CASCookiePath /var/cache/mod_auth_cas/
        +CASDebug Off
        +CASIdleTimeout 3600
        +CASSSOEnabled Off
        +CASTimeout 7200
        +CASVersion 2
      * file[/etc/httpd/mods-available/auth_cas.load] action create
        - create new file /etc/httpd/mods-available/auth_cas.load
        - update content in file /etc/httpd/mods-available/auth_cas.load from none to 769b29
        --- /etc/httpd/mods-available/auth_cas.load	2021-03-31 16:39:02.060184195 +0000
        +++ /etc/httpd/mods-available/.chef-auth_cas20210331-2771-8rijgw.load	2021-03-31 16:39:02.060184195 +0000
        @@ -1 +1,2 @@
        +LoadModule auth_cas_module /usr/lib64/httpd/modules/mod_auth_cas.so
        - change mode from '' to '0644'
      * execute[a2enmod auth_cas] action run
        - execute /usr/sbin/a2enmod auth_cas
    
    * directory[/var/cache/httpd/mod_auth_cas] action create
      - change mode from '0755' to '0700'

Thanks again for your assistance!

Not yet @ramereth, but it’s on my TODO list this week. I will follow up as soon as I can.

@rgriffith if you could test it yourself and make sure it works for you that’d be great. Then I can merge/release it!

@rgriffith ok, I’ve made that change to the PR. Can you please move any further discussion to the PR so we can discuss better in context of code if you need to? Thanks!

@ramereth So you’ll keep those “core” couple that are there currently and allow passing in arbitrary directives? I should be able to make that work.

I’ve narrowed down the problem and will be pushing a fix soon.

I confirmed this is happening. I’m taking a look to see why this is happening.