Skip to content

Fix postgresql#32

Merged
myii merged 19 commits intosaltstack-formulas:masterfrom
tigpas:fix-postgresql
Dec 16, 2019
Merged

Fix postgresql#32
myii merged 19 commits intosaltstack-formulas:masterfrom
tigpas:fix-postgresql

Conversation

@tigpas
Copy link
Copy Markdown
Contributor

@tigpas tigpas commented Dec 8, 2019

In icinga2/postgresql-server.sls, there is icinga2.icinga_web2.postgresql_pkgs used, but the icinga2 variable isn't available. Due the include of map.jinja, it works. Than, we can use the "use_formula" variable from map, and not direct from pillar.

@myii
Copy link
Copy Markdown
Contributor

myii commented Dec 9, 2019

@tigpas Thanks for this series of PRs. In order to evaluate these changes, I'm about to implement semantic-release for this formula, so that we have automated testing running as well. I'm almost done:

As soon as that's merged, please rebase your PRs on top and then we can see how your changes work out.

myii added 10 commits December 10, 2019 17:40
```bash
[202] Jinja statement should have spaces before and after: {% statement %}
icinga2/config.sls:6
{%- for key, value in config.items()%}

[206] Jinja variables should have spaces before and after: {{ var_name }}
icinga2/config.sls:8
          {{key}} "{{ value }}"

[202] Jinja statement should have spaces before and after: {% statement %}
icinga2/config.sls:12
{%- for key, value in config.items()%}

[202] Jinja statement should have spaces before and after: {% statement %}
icinga2/config.sls:55
{%-endmacro%}

[206] Jinja variables should have spaces before and after: {{ var_name }}
icinga2/config.sls:107
{{ path}}:

[202] Jinja statement should have spaces before and after: {% statement %}
icinga2/config.sls:160
{%-     endfor%}

[202] Jinja statement should have spaces before and after: {% statement %}
icinga2/config.sls:181
{%-     endfor%}

[202] Jinja statement should have spaces before and after: {% statement %}
icinga2/config.sls:202
{%-     endfor%}

[202] Jinja statement should have spaces before and after: {% statement %}
icinga2/config.sls:227
{%-       endfor%}

[202] Jinja statement should have spaces before and after: {% statement %}
icinga2/config.sls:230
{%-   endfor%}

[201] Trailing whitespace
icinga2/files/xmpp.conf.jinja:3

[201] Trailing whitespace
icinga2/files/xmpp.conf.jinja:9

[201] Trailing whitespace
icinga2/files/xmpp.conf.jinja:21

[201] Trailing whitespace
icinga2/files/xmpp.conf.jinja:24

[201] Trailing whitespace
icinga2/files/xmpp.conf.jinja:27

[201] Trailing whitespace
icinga2/files/xmpp.conf.jinja:31

[201] Trailing whitespace
icinga2/files/xmpp.conf.jinja:33

[201] Trailing whitespace
icinga2/files/xmpp.conf.jinja:35

[201] Trailing whitespace
icinga2/files/xmpp.conf.jinja:38

[201] Trailing whitespace
icinga2/files/xmpp.conf.jinja:41

[201] Trailing whitespace
icinga2/files/xmpp.conf.jinja:44

[201] Trailing whitespace
icinga2/files/xmpp.conf.jinja:49

[201] Trailing whitespace
icinga2/files/xmpp.conf.jinja:51

[201] Trailing whitespace
icinga2/files/xmpp.conf.jinja:53

[201] Trailing whitespace
icinga2/map.jinja:6
    defaults,

[202] Jinja statement should have spaces before and after: {% statement %}
icinga2/nrpe-server.sls:2
{% set nrpe = salt['pillar.get']('nrpe', salt['pillar.get']('icinga2:lookup::nrpe', {}))%}

[206] Jinja variables should have spaces before and after: {{ var_name }}
icinga2/pgsql-ido.sls:45
    - name: "{{ icinga2.config_dir}}/features-available/ido-pgsql.conf"
```
```bash
icinga2-formula$ yamllint -s .
./pillar.example
  1:1       warning  missing document start "---"  (document-start)
  6:8       warning  missing starting space in comment  (comments)
  20:14     warning  truthy value should be one of [false, true]  (truthy)
  21:18     warning  truthy value should be one of [false, true]  (truthy)
  22:15     warning  truthy value should be one of [false, true]  (truthy)
  23:19     warning  truthy value should be one of [false, true]  (truthy)
  24:19     warning  truthy value should be one of [false, true]  (truthy)
  25:19     warning  truthy value should be one of [false, true]  (truthy)
  26:21     warning  truthy value should be one of [false, true]  (truthy)
  36:18     warning  truthy value should be one of [false, true]  (truthy)
  103:9     warning  comment not indented like content  (comments-indentation)
  109:17    warning  truthy value should be one of [false, true]  (truthy)
  123:15    error    empty value in block mapping  (empty-values)
  124:7     warning  comment not indented like content  (comments-indentation)
  126:14    error    empty value in block mapping  (empty-values)
  127:7     warning  comment not indented like content  (comments-indentation)

./icinga2/osmap.yaml
  1:1       warning  missing document start "---"  (document-start)

./icinga2/defaults.yaml
  1:1       warning  missing document start "---"  (document-start)
  14:27     warning  truthy value should be one of [false, true]  (truthy)
  20:16     error    empty value in block mapping  (empty-values)
  34:16     error    empty value in block mapping  (empty-values)
  51:12     warning  truthy value should be one of [false, true]  (truthy)
  52:16     warning  truthy value should be one of [false, true]  (truthy)
  53:17     warning  truthy value should be one of [false, true]  (truthy)
  54:13     warning  truthy value should be one of [false, true]  (truthy)
  55:17     warning  truthy value should be one of [false, true]  (truthy)
  56:17     warning  truthy value should be one of [false, true]  (truthy)
  57:19     warning  truthy value should be one of [false, true]  (truthy)
  58:17     warning  truthy value should be one of [false, true]  (truthy)
  59:17     warning  truthy value should be one of [false, true]  (truthy)
  60:19     warning  truthy value should be one of [false, true]  (truthy)
  61:15     warning  truthy value should be one of [false, true]  (truthy)

./icinga2/osfamilymap.yaml
  1:1       warning  missing document start "---"  (document-start)
  5:27      warning  truthy value should be one of [false, true]  (truthy)
  16:19     error    empty value in block mapping  (empty-values)
  17:2      error    syntax error: found character '%' that cannot start any token
```
@myii
Copy link
Copy Markdown
Contributor

myii commented Dec 10, 2019

@tigpas FYI, the semantic-release PR is ready: #37.

{% if salt['pillar.get']('icinga2:postgres:use_formula', False) %}
{% from "icinga2/map.jinja" import icinga2 with context %}

{% if icinga2.get('postgres:use_formula', False) %}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've run this against the new testing setup and this change doesn't work (the pillar value is set to use the formula):

The reason for this is due to the current structure of map.jinja, since only the lookup from the pillar is merged into the map:

merge=salt['pillar.get']('icinga2:lookup', {}),

I.e. This if will never run, only the else.

If this PR is going to proceed, the correct resolution would be to merge in the rest of the pillar, as we do in many of our other formulas, such as the template-formula.

@@ -1,4 +1,6 @@
{% if salt['pillar.get']('icinga2:postgres:use_formula', False) %}
{% from "icinga2/map.jinja" import icinga2 with context %}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was absolutely needed. I also noticed this in the semantic-release PR: dece815.

aboe76 and others added 6 commits December 11, 2019 19:50
…antic-release

feat(semantic-release): implement for this formula
# [0.8.0](saltstack-formulas/icinga2-formula@v0.7.1...v0.8.0) (2019-12-11)

### Bug Fixes

* **pgsql-ido.sls:** ensure state `debconf.set` is available ([310b2f5](saltstack-formulas@310b2f5))
* **postgresql-server.sls:** fix missing import ([dece815](saltstack-formulas@dece815))
* **repo:** prepare basic structure for all available platforms ([33f7694](saltstack-formulas@33f7694))
* **salt-lint:** fix all errors (or add to ignores) ([cae6252](saltstack-formulas@cae6252))
* **yamllint:** fix all errors (or add to ignores) ([860f72b](saltstack-formulas@860f72b))

### Documentation

* **readme:** modify according to standard structure ([fb0aca8](saltstack-formulas@fb0aca8))
* **readme:** move to `docs/` directory ([70105f0](saltstack-formulas@70105f0))

### Features

* **repositories.sls:** add inline `stretch-backports` repo ([5353313](saltstack-formulas@5353313))
* **semantic-release:** implement for this formula ([d632339](saltstack-formulas@d632339))

### Tests

* **inspec:** add tests for package, config & service ([da16c4e](saltstack-formulas@da16c4e))
* **pillar:** add for `default` suite based on `pillar.example` ([a1ee8a1](saltstack-formulas@a1ee8a1))
@tigpas
Copy link
Copy Markdown
Contributor Author

tigpas commented Dec 13, 2019

Hi,

thanks for the great testing environment and for #37 .

Yes, I broke the if case in line 3. I reverted it.

Now, It's working with

diff --git a/test/salt/pillar/default.sls b/test/salt/pillar/default.sls
index 8b60d60..8c14efe 100644
--- a/test/salt/pillar/default.sls
+++ b/test/salt/pillar/default.sls
@@ -36,7 +36,7 @@ icinga2:
         ca_file: /etc/ssl/certs/ca-certificates.crt
 
   postgres:
-    use_formula: true  # set to true if you are using postgres-formula
+    use_formula: false # set to true if you are using postgres-formula
 
   nrpe:  # deprecated
     config:

as expected. But I don't understand why https://travis-ci.com/saltstack-formulas/icinga2-formula/jobs/267062799 failed. I can reproduce it locally with the master branche, too.

@myii myii merged commit 9e8485e into saltstack-formulas:master Dec 16, 2019
@myii
Copy link
Copy Markdown
Contributor

myii commented Dec 16, 2019

@tigpas Thanks for updating this. I've run this with a modified test pillar to confirm it is all working OK:

As for the debian-10 failure, there's something getting messed up at the Travis layer because it's working fine locally (CC: @javierbertoli).

I'm thinking that we can adjust the test suites slightly to test both with and without the postgres-formula but I'll leave that for a subsequent PR. I've merged this in the meantime. Thanks for the contribution!

@saltstack-formulas-travis
Copy link
Copy Markdown

🎉 This PR is included in version 0.9.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants