saltstack-formulas / php-formula

http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
57 stars 231 forks source link

[BUG] Modules are not installed #207

Closed AmitChotaliya closed 4 years ago

AmitChotaliya commented 4 years ago

My Setup

Formula commit hash / release tag

64928717709d8235936e6073dbe7fe635f082919

Versions reports (master & minion)

Master Salt Version: Salt: 2018.3.3 Minion Salt Version: Salt: 2018.3.3

Pillar / config used

php:  
  version: "7.3"
  modules:    
    - xml    
    - curl

---

Modules specified are not installed.

Describe the bug

Module list specified in the pillar are not getting installed. I manually installed them and it works fine but If I remove them then the salt highstate is not installing the modules.

Steps to reproduce the bug

Expected behaviour

Attempts to fix the bug

Additional context

I removed all the php modules from the minion, to check if it works with fresh install. It does not work either. Here's the high state output.

----------
          ID: php_install_php
    Function: pkg.installed
        Name: php
      Result: True
     Comment: The following packages were installed/updated: php
     Started: 07:02:44.966187
    Duration: 11419.574 ms
     Changes:
              ----------
              libapache2-mod-php:
                  ----------
                  new:
                      1
                  old:
              libapache2-mod-php7.3:
                  ----------
                  new:
                      7.3.12-1+ubuntu18.04.1+deb.sury.org+1
                  old:
              php:
                  ----------
                  new:
                      2:7.3+70+ubuntu18.04.1+deb.sury.org+6
                  old:
              php-calendar:
                  ----------
                  new:
                      1
                  old:
              php-cli:
                  ----------
                  new:
                      1
                  old:
              php-common:
                  ----------
                  new:
                      2:70+ubuntu18.04.1+deb.sury.org+6
                  old:
              php-ctype:
                  ----------
                  new:
                      1
                  old:
              php-exif:
                  ----------
                  new:
                      1
                  old:
              php-fileinfo:
                  ----------
                  new:
                      1
                  old:
              php-ftp:
                  ----------
                  new:
                      1
                  old:
              php-iconv:
                  ----------
                  new:
                      1
                  old:
              php-json:
                  ----------
                  new:
                      1
                  old:
              php-opcache:
                  ----------
                  new:
                      1
                  old:
              php-pdo:
                  ----------
                  new:
                      1
                  old:
              php-phar:
                  ----------
                  new:
                      1
                  old:
              php-posix:
                  ----------
                  new:
                      1
                  old:
              php-readline:
                  ----------
                  new:
                      1
                  old:
              php-shmop:
                  ----------
                  new:
                      1
                  old:
              php-sockets:
                  ----------
                  new:
                      1
                  old:
              php-sysvmsg:
                  ----------
                  new:
                      1
                  old:
              php-sysvsem:
                  ----------
                  new:
                      1
                  old:
              php-sysvshm:
                  ----------
                  new:
                      1
                  old:
              php-tokenizer:
                  ----------
                  new:
                      1
                  old:
              php7.3:
                  ----------
                  new:
                      7.3.12-1+ubuntu18.04.1+deb.sury.org+1
                  old:
              php7.3-calendar:
                  ----------
                  new:
                      1
                  old:
              php7.3-cli:
                  ----------
                  new:
                      7.3.12-1+ubuntu18.04.1+deb.sury.org+1
                  old:
              php7.3-common:
                  ----------
                  new:
                      7.3.12-1+ubuntu18.04.1+deb.sury.org+1
                  old:
              php7.3-ctype:
                  ----------
                  new:
                      1
                  old:
              php7.3-exif:
                  ----------
                  new:
                      1
                  old:
              php7.3-fileinfo:
                  ----------
                  new:
                      1
                  old:
              php7.3-ftp:
                  ----------
                  new:
                      1
                  old:
              php7.3-gettext:
                  ----------
                  new:
                      1
                  old:
              php7.3-iconv:
                  ----------
                  new:
                      1
                  old:
              php7.3-json:
                  ----------
                  new:
                      7.3.12-1+ubuntu18.04.1+deb.sury.org+1
                  old:
              php7.3-opcache:
                  ----------
                  new:
                      7.3.12-1+ubuntu18.04.1+deb.sury.org+1
                  old:
              php7.3-pdo:
                  ----------
                  new:
                      1
                  old:
              php7.3-phar:
                  ----------
                  new:
                      1
                  old:
              php7.3-posix:
                  ----------
                  new:
                      1
                  old:
              php7.3-readline:
                  ----------
                  new:
                      7.3.12-1+ubuntu18.04.1+deb.sury.org+1
                  old:
              php7.3-shmop:
                  ----------
                  new:
                      1
                  old:
              php7.3-sockets:
                  ----------
                  new:
                      1
                  old:
              php7.3-sysvmsg:
                  ----------
                  new:
                      1
                  old:
              php7.3-sysvsem:
                  ----------
                  new:
                      1
                  old:
              php7.3-sysvshm:
                  ----------
                  new:
                      1
                  old:
              php7.3-tokenizer:
                  ----------
                  new:
                      1
                  old:
              phpapi-20180731:
                  ----------
                  new:
                      1
                  old:
----------
          ID: php_install_mysql
    Function: pkg.installed
        Name: mysql
      Result: True
     Comment: The following packages were installed/updated: php-mysql
     Started: 07:02:56.398242
    Duration: 4407.914 ms
     Changes:
              ----------
              php-mysql:
                  ----------
                  new:
                      2:7.3+70+ubuntu18.04.1+deb.sury.org+6
                  old:
              php-mysqli:
                  ----------
                  new:
                      1
                  old:
              php-mysqlnd:
                  ----------
                  new:
                      1
                  old:
              php-pdo-mysql:
                  ----------
                  new:
                      1
                  old:
              php7.3-mysql:
                  ----------
                  new:
                      7.3.12-1+ubuntu18.04.1+deb.sury.org+1
                  old:
              php7.3-mysqli:
                  ----------
                  new:
                      1
                  old:
              php7.3-mysqlnd:
                  ----------
                  new:
                      1
                  old:
              php7.3-pdo-mysql:
                  ----------
                  new:
                      1
                  old:
AmitChotaliya commented 4 years ago

I was able to solve it by adding the following in the state file.

include:
    - php.curl
    - php.xml

Is this the right way or should the above pillar setup should work?

javierbertoli commented 4 years ago

@AmitChotaliya I'm not using the php:modules but the different states (as you mention you solved it). However, taking a quick look at the code, it should work using the former method.

I think that the issue is a missing variable setting in the modules.sls iterator for the modules.

I submitted a PR (#208 ), can you check if it fixes the issue for you? I don't have a 2018.3.3 setup around, will try to prepare one and try to reproduce the issue. But in the meantime, if you can try that change, I will appreciate it.

myii commented 4 years ago

@AmitChotaliya You didn't mention what you are using in your top.sls. Also the full versions-report would have been helpful. In any case, I've tested with the following in Kitchen and it is working as expected:

      state_top:
        base:
          '*':
            - php
            - php.modules
      pillars:
        php.sls:
          php:
            version: "7.3"
            modules:
              - xml
              - curl

So you'd use the state_top in your top.sls and the pillar (as you've already given above). These are both installed fine, as shown here:

Can you please confirm that at your end so that we can close this issue?


@javierbertoli I don't believe #208 will be required. You can look further up in that link to see some extra debug output I've included. Everything is working fine:

I'm outputting each variable in modules.sls, as shown here:

AmitChotaliya commented 4 years ago

@myii

You are right, it works fine the way you suggested. I did not put the php.modules in the top file. Should the documentation be updated with this information? It is not clear from the documentation.

myii commented 4 years ago

@AmitChotaliya This formula probably does too many things, so the documentation is difficult to untangle. Do you have any suggestions about how it could be improved? It's always good to get a fresh point of view.

javierbertoli commented 4 years ago

@javierbertoli I don't believe #208 will be required.

You're right. On a second read, the variable state is being set in the loop iterator. My bad.