mardi 24 octobre 2017

bash test cmd fails with too many args

In Puppet provisioning, I do have problems which cause puppet run in every turn. It's masterless configuration using perodic cron job execution.

 exec { 'postgresql::server::database::action1':
        command => "sudo -u postgres psql -d ${db_name} -a -f /opt/folderx/v2/createdb.sql",
        path    => '/usr/pgsql-9.5/bin:/usr/bin:/bin',
        user    => 'root',
        onlyif  => "test $(sudo -u postgres psql -d ${db_name} -c 'SELECT version();' ; echo $?) -ne 0",
    }

Question which is correct syntax to onlyif testing ? In bash shell I will get:

bash: test: too many arguments

Basically I need to test does some tables and functions exist in given $dbame

Aucun commentaire:

Enregistrer un commentaire