【问题标题】:Validate database output using chef inspec使用 chef inspec 验证数据库输出
【发布时间】:2021-04-11 08:27:45
【问题描述】:

在执行以下 postgresql 命令时,如何使用 chef inspec 验证 name 列和 row 列下的输出。

postgres=# select name, setting from pg_settings where (name ~ '_directory$'
postgres(# or name ~ '_tablespace');
         name         |        setting
----------------------+------------------------
 data_directory       | /var/lib/pgsql/10/data
 default_tablespace   |
 log_directory        | log
 stats_temp_directory | pg_stat_tmp
 temp_tablespaces     |
(5 rows)

【问题讨论】:

    标签: database postgresql chef-infra inspec


    【解决方案1】:

    您可以使用 2 个 postgres 资源:

    1. postgres_session 测试针对 PostgreSQL 数据库运行的 SQL 命令

      sql = postgres_session('username', 'password', 'host', 'port')
      describe sql.query('SELECT * FROM pg_shadow WHERE passwd IS NULL;') do
        its('output') { should eq '' }
      end
      
    2. postgres_conf测试PostgreSQL的配置文件内容

      describe postgres_conf do
        its('max_connections') { should eq '5' }
      end
      

    【讨论】:

      猜你喜欢
      • 2021-02-08
      • 2021-05-27
      • 2017-01-27
      • 1970-01-01
      • 2017-12-14
      • 2018-01-12
      • 2016-12-09
      • 1970-01-01
      • 2016-11-02
      相关资源
      最近更新 更多