saltstack-formulas / mongodb-formula

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

Error on repo management - Ubuntu #61

Closed NathanPrado closed 5 years ago

NathanPrado commented 5 years ago

Ubuntu 18.04 bionic salt 2019.2.0 (Fluorine)

I am having an issue on the mongodb server package installed step:

      ID: mongodb server package repo
Function: pkgrepo.managed
    Name: deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse
  Result: True
 Comment: Configured package repo 'deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse'
 Started: 22:32:46.791737
Duration: 8136.491 ms
 Changes:   

      ID: mongodb server package installed
Function: pkg.installed
    Name: mongodb-org
  Result: False
 Comment: Problem encountered installing package(s). Additional info follows:

          errors:
              - Running scope as unit: run-r57bdebcd75844eab955d7d4450e171f7.scope
                E: The value 'deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse' is invalid for APT::Default-Release as such a release is not available in the sources
 Started: 22:32:54.929000
Duration: 3487.959 ms
 Changes:   

I did a little digging but am still not quite able to diagnose what could be wrong here.

pillar:

mongodb:
  server:
    use_repo: true
    version: 4.0
noelmcloughlin commented 5 years ago

This issue was reported in https://github.com/saltstack-formulas/mongodb-formula/issues/52 but was never fixed (see https://github.com/saltstack-formulas/mongodb-formula/pull/53). Maybe you could fix this via PR.

NathanPrado commented 5 years ago

Glad to, thank you for pointing me to previous references to this issue. I found that this does not have to do with the solution suggested in #53. This actually has to do with the following lines of code in mongodb/server/packages.sls:

  pkg.installed:
    - refresh: True
    - name: {{ mongodb.server.package }}
        {%- if mongodb.server.use_repo %}
    - fromrepo: {{ mongodb.server.repo.name|replace('RELEASE', mongodb.server.version) or None }}
        {%- endif %}

According to this comment when referring to the pkg.installed module, in apt based distros the fromrepo param is used to denote the release not the actual repo reference. Therefore, in my case, this value should be "bionic" referring to the code name of the distro. I have tested as much and have had success just changing the fromrepo line. Moreover, if the entire if block is not present the run succeeds as well.

For my PR, I am thinking of conditionally placing the codename of the OS in that field if Debian/Ubuntu. Thoughts?

noelmcloughlin commented 5 years ago

Yes, that sounds like the only solution here. Does this fix #52?

The cleanest implementation could be to update the if/else block in oscodemap with the following (pseudo) conditional and use that value in the SLS file.

if ... debian...
    from_repo_value: RELEASE
 else
   from_repo_value: {{ mongodb.server.repo.name|replace('RELEASE', mongodb.server.version) or None }}
NathanPrado commented 5 years ago

@noelmcloughlin I seem to be having trouble deploying my changes to a Debian system. The Vagrant set up I have for my Ubuntu machine (which bootstraps and executes Salt) seems to reject the same salt configuration on a Debian box. Any way you would recommend I test on a Debian machine?

In answer to your question I believe the answer in #53 is also needed but I have yet to prove that in testing.

NathanPrado commented 5 years ago

@noelmcloughlin Not sure how I add you as a reviewer but I am pretty confident i solved the issue. Please give it a check when you can - thanks!

myii commented 5 years ago

@NathanPrado Is this resolved by #67? If so, do you mind closing this issue?

noelmcloughlin commented 5 years ago

Hi @NathanPrado Yes, I believe your PR should resolve this. If not, then issue can be reopened. Thanks!!