Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manifests/server/extension.pp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

case $ensure {
'present': {
$command = "CREATE EXTENSION \"${extension}\""
$command = "CREATE EXTENSION \"${extension}\"${if $version and $version != 'latest' { " VERSION \"${version}\"" } else { '' }}"

Check warning on line 57 in manifests/server/extension.pp

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

top-scope variable being used without an explicit namespace (check: variable_scope)

Check warning on line 57 in manifests/server/extension.pp

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

top-scope variable being used without an explicit namespace (check: variable_scope)

Check warning on line 57 in manifests/server/extension.pp

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 7.24, Ruby Ver: 2.7)

top-scope variable being used without an explicit namespace (check: variable_scope)

Check warning on line 57 in manifests/server/extension.pp

View workflow job for this annotation

GitHub Actions / Spec / Spec tests (Puppet: ~> 8.0, Ruby Ver: 3.2)

top-scope variable being used without an explicit namespace (check: variable_scope)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks like the code in the ${} confuse the linter. While this is syntactically correct, that is quite uncommon and I would rather avoid this.

Switching to inline epp would be a valid alternative, something like (untested):

Suggested change
$command = "CREATE EXTENSION \"${extension}\"${if $version and $version != 'latest' { " VERSION \"${version}\"" } else { '' }}"
$command = inline_epp('CREATE EXTENSION "<%= $extension %>"<% if $version and $version != 'latest' { %> VERSION "<%= $version %>"<% } %>', { extension => $extension, version => $version })

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It works as expected, I just had to replace the quotation marks for 'latest' , but it works.

      $command = inline_epp('CREATE EXTENSION "<%= $extension %>"<% if $version and $version != "latest" { %> VERSION "<%= $version %>"<% } %>', { extension => $extension, version => $version })

My output:

...
Notice: /Stage[main]/Profile::Postgresql/Postgresql::Server::Grant[monitoring_execute_pg_ls_waldir]/Postgresql_psql[grant:monitoring_execute_pg_ls_waldir]/command: command changed 'notrun' to 'GRANT EXECUTE ON FUNCTION pg_ls_waldir() TO "monitoring"'
Notice: /Stage[main]/Zabbix::Database/Postgresql::Server::Db[zabbix]/Postgresql::Server::Role[zabbix]/Postgresql_psql[CREATE ROLE zabbix ENCRYPTED PASSWORD ****]/command: changed [redacted] to [redacted]
Notice: /Stage[main]/Zabbix::Database/Postgresql::Server::Db[zabbix]/Postgresql::Server::Database[zabbix]/Postgresql_psql[CREATE DATABASE "zabbix"]/command: command changed 'notrun' to 'CREATE DATABASE "zabbix" WITH TEMPLATE = "template0" ENCODING = \'UTF-8\' LC_COLLATE = \'en_US.UTF-8\' LC_CTYPE = \'en_US.UTF-8\' '
Info: /Stage[main]/Zabbix::Database/Postgresql::Server::Db[zabbix]/Postgresql::Server::Database[zabbix]/Postgresql_psql[CREATE DATABASE "zabbix"]: Scheduling refresh of Postgresql_psql[REVOKE CONNECT ON DATABASE "zabbix" FROM public]
Notice: /Stage[main]/Zabbix::Database/Postgresql::Server::Db[zabbix]/Postgresql::Server::Database[zabbix]/Postgresql_psql[REVOKE CONNECT ON DATABASE "zabbix" FROM public]: Triggered 'refresh' from 1 event
Notice: /Stage[main]/Zabbix::Database/Postgresql::Server::Db[zabbix]/Postgresql::Server::Database[zabbix]/Postgresql_psql[ALTER DATABASE "zabbix" OWNER TO "zabbix"]/command: command changed 'notrun' to 'ALTER DATABASE "zabbix" OWNER TO "zabbix"'
Notice: /Stage[main]/Profile::Postgresql/Postgresql::Server::Extension[timescaledb]/Postgresql_psql[zabbix: CREATE EXTENSION "timescaledb" VERSION "2.23.1"]/command: command changed 'notrun' to 'CREATE EXTENSION "timescaledb" VERSION "2.23.1"'
Notice: /Stage[main]/Profile::Postgresql/Postgresql::Server::Extension[pg_repack]/Postgresql_psql[zabbix: CREATE EXTENSION "pg_repack" VERSION "1.5.3"]/command: command changed 'notrun' to 'CREATE EXTENSION "pg_repack" VERSION "1.5.3"'
...

$unless_mod = undef
$psql_cmd_require = $package_name ? {
undef => $default_psql_require,
Expand Down
Loading