-
Notifications
You must be signed in to change notification settings - Fork 284
Support fromrepo in pkg.installed states #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Testing done - works nicely. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally like the idea of using the fromrepo
with use_upstream_repo
setting.
Unfortunately, these changes do not resolve #133, but break support for upstream on all distros. Also, the fromrepo
parameter works differently on apt-based systems. Please take a look at my comments below.
postgres/server/init.sls
Outdated
- refresh: True | ||
- require: | ||
- pkgrepo: postgresql-repo | ||
{%- endif %} | ||
|
||
{%- do includes.append('postgres.upstream') %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have already substituted the includes
list above, so this line has no effect and the postgres.upstream
states would never be included. It is always better to keep definition and logic around includes
statements at the top of SLS file. That looks simpler and makes debugging easier. By removing a single if
statement you don't make the code more readable or "optimized".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In support of opinions in #125, its good idea to removing some Jinja in SLS/YML files. These sentiments, which I tend to agree with, can only be addressed in baby steps. No issue here.
I moved this includes down few lines in the code - its the first occurance so surely takes effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw you did it differently in the client.sls
. In THAT case it would work, despite not looking pretty though...
Please double check: moving do includes.append...
statement here would break calling the single state like salt-call state.apply postgres.server
. The postgres.upstream
SLS would be never included this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The server SLS is more tricky due to includes
Jinja. And reviewing this, maybe the following Jinja must move below postgresql.server.pkg.installed
so indent(2) is applied?
{%- if includes -%}
include:
{{ includes|yaml(false)|indent(2) }}
{%- endif %}
The usage of salt.apply
is new for me. I'll will report back.
postgres/client.sls
Outdated
# Install PostgreSQL client and libraries | ||
|
||
postgresql-client-libs: | ||
pkg.installed: | ||
- pkgs: {{ pkgs }} | ||
{%- if postgres.use_upstream_repo %} | ||
{%- if postgres.pkg_repo.name %} | ||
- fromrepo: {{ postgres.pkg_repo.name }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of the fromrepo
usage would work for YUM etc, but not for APT. Please check out the docs.
You need to provide distribution codename for Debian-based distros. Better to do it by exposing parameter dist
in codenamemap.yaml
file and use pkg_repo.name
only as a fallback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is good feedback. I have only tested on YUM system, so good catch. I appreciate your PR reviews @vutny, they are always sharp and helpful to community!! I'll do more testing and see if this blocks the PR.
The latest commit works on Ubuntu, Fedora, Centos7, and OpenSUSE, for downstream. OpenSuse 42.3
Ubuntu
Centos
|
The |
The only For next test, using upstream, I plan to set |
Oh yes! Sure thing, I meant |
Testing this today. |
Closing to rebase & submit smaller PRs. Comments here will be adopted. |
New commit done, PR later. |
This PR fixes a bug around repo handling.
When
packagename
exists in multiple repo, settinguse_upstream_repo: True
cannot guarantee upstream package gets installed. This bug was noticed while testing #176 on openSuse with upstreamversion: 9.6
.Also resolves #133