-
Notifications
You must be signed in to change notification settings - Fork 282
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
Ensure upstream repo is configured or absent depending on use_upstream_repo
#123
Ensure upstream repo is configured or absent depending on use_upstream_repo
#123
Conversation
Does someone have any comments, objections, test failures? ;) |
855e31b
to
2ed71f6
Compare
|
||
{% if postgres.use_upstream_repo %} |
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.
Why do you remove the conditional include? If I set postgres.use_upstream_repo = False
, makes no sense to me to force a dependency on a state that sets and manages something I explicitely said don't want to use.
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 general, my PR is all about to make upstream.sls
stateful.
And it makes sense when you remove upstream repository configuration.
{% endif %} | ||
- pkgs: {{ pkgs }} | ||
- refresh: {{ 'pkg_repo' in postgres }} | ||
- require: |
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.
Same as in my previous comment, this requirement should either be conditional or, better yet, a require_in
set in the install-postgresql-repo
in the postgres/upstream.sls
file, don't you agree?
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.
Include and requirement statements are enforcing upstream.sls
to clean up repository configuration before doing any further installation.
|
||
{{ codename|default(name, true) }}: | ||
# PostgreSQL packages are mostly downloaded from `main` repo component | ||
pkg_repo: 'deb http://apt.postgresql.org/pub/repos/apt/ {{ name }}-pgdg main {{ version }}' | ||
pkg_repo_humanname: PostgreSQL Official Repository | ||
pkg_repo: 'deb http://apt.postgresql.org/pub/repos/apt {{ name }}-pgdg main {{ upstream_version }}' |
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'd leave {{ version }}
here, as it's clearly being set in the preceeding lines you added, and is more consistent.
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.
Because pkg_repo
parameter is only applicable for upstream repository, there is no point to set it's component name to the version provided by OS distribution.
But the main point here is that this variable also playing its part in removing upstream repository configuration when use_upstream_repo
set to False
.
Basically, upstream.sls
will make sure that upstream deb
source record and GPG key are removed. Because package names from upstream could possibly match the ones from the "stock", it's really important to avoid installation of newer tools or libs which would be incompatible with PostgreSQL server installed from distribution archive.
Sorry, busy days :) All in all, I agree with the idea of this refactoring, but don't like the forced dependency that you now set to the I expect that, if I explicitely include the Now, with the conditional surrounding all the code, I have to both include the sls file and set I personally prefer (and consider it clearer) if you just let If this behaviour has any errors as mentioned in #58, just fix that? |
@javierbertoli Thanks for your valuable feedback! Indeed, I tried to make That seems good and reasonable, but again, install-postgresql-repo:
...
pkgrepo.managed:
- name: {{ postgres.pkg_repo }}
- humanname: {{ postgres.pkg_repo_humanname }}
- baseurl: {{ postgres.pkg_repo_url }}
- gpgcheck: 1
- gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
- require:
- file: install-postgresql-repo
- require_in:
- pkg: postgresql-installed It was added to ensure that packages are not going to be installed if repo configuration has failed. Obviously, this case doesn't work for other states such as That's why I had to redesign this requisite logic. I've moved the conditional check for the I believe this should be much more clear and reliable. As opposite, by having if statements around Since the Even more, if you have If you have any additional questions, I would be happy to answer them. P.S. I will respond to some of you in-line comments to express more details. Thanks. |
As I understand it, install-postgresql-repo:
file.managed:
- name: /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
- source: https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG
- source_hash: md5=78b5db170d33f80ad5a47863a7476b22
pkgrepo.managed:
- name: {{ postgres.pkg_repo }}
- humanname: {{ postgres.pkg_repo_humanname }}
- baseurl: {{ postgres.pkg_repo_url }}
- gpgcheck: 1
- gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
- require:
- file: install-postgresql-repo
- require_in:
- pkg: postgresql-installed
- pkg: install-postgresql-client
- pkg: install-postgres-libpq-dev would be perfectly possible, keep |
@javierbertoli No-no! Of course you can put as many requisites to the state as you want. I've meant that such trick doesn't resolve the current issue with missing requirements for states which not included. If I will try to apply only states from
The similar message I will have when try to apply just This makes the states very much coupled with one another. That's why |
2ed71f6
to
771836b
Compare
@javierbertoli I understood my mistake. I've tried to kill two birds with one stone and have fallen into over-engineering... Thanks for your help to get it! :) @gravyboat Now my PR only does one thing -- it makes Could you please review the changes? Thanks! |
Cool! (Thanks for #124 btw 😄). So now, Then, how about this:
{%- if grains['os_family'] in ('RedHat', 'Debian') %}
# We manage the repo for only these distros
{%- if postgres.use_upstream_repo -%}
# If true, we add it
{%- if grains['os_family'] == 'Debian' %}
# Debian specific stuff
{%- elif grains['os_family'] == 'RedHat' %}
# RedHat specific stuff
{% endif %}
# Common things to do when adding the repo
{% else %}
# We remove the repo
{% endif %}
{% else %}
# We notify that we don't manage this distro
test.show_notification:
- text: |
PostgreSQL does not provide package repository for {{ grains['os_family'] }}
{% endif %} What do you think? |
@javierbertoli Awesome!
I will adjust my code according to your suggestions. And your review was terrific! 😄 Thank you! Any additional thoughts? |
771836b
to
b4edec9
Compare
@vutny, I agree with your suggestions. Perhaps, to cover the cases you mention (about Ubuntu/Debian and similar that might arise), we'd rather use {%- if 'pkg_repo' in postgres %}
# We manage the repo for only these distros
{%- if postgres.use_upstream_repo -%}
# If true, we add it
{%- if grains['os'] in ('Debian', 'some_debian_derivative', 'some_other') %}
# Debian and derivatives that share stuff
{%- elif grains['os'] in ('RedHat', 'CentOS') %}
# RedHat and CentOS specific stuff
{% endif %}
...
... |
@javierbertoli I would like to completely get rid of OS selection logic in the SLS file. I've changed and pushed the code which abstracts In the meanwhile I'll try to set default |
Mmmm... I don't see it. maybe you forgot to |
@javierbertoli Actually I've pushed it yesterday 😄 by just amending my commit b4edec9. Please try to refresh the page or do |
Allright! I've set |
Merged it. Great work, @vutny ! :) Going through this iteration, made me realize that the '*yaml' files are carrying too much logic for files that must let you, at a quick glance, understand what values are being set as default or overriden in each of those files. I'm adding an issue (#125) to address this, with more details. |
Thank you @javierbertoli ! Yep, I agree, it appears too much Jinja code in the lookup maps. |
Hi @gravyboat
The main feature of this PR is to make sure that the
postgres.upstream
state removes Postgres repository configuration and GnuPG key if thepostgres:use_upstream_repo
Pillar set toFalse
.Now such behavior is documented in README.
This PR also resolves issue #58 one more time, there were regressions in previous changes.
Additional improvements:
postgres.upstream
state more reusable, other states could safely usesls
requisite.