Search code examples
database-connectionpuppet-enterprise

Logging into a PuppetDB instance like a typical SQL instance?


I'm trying to find if there is a way to log into a pe-puppetdb instance like you would with say, a mysql instance. AKA mysql -u username -p I have looked around but am only really seeing the ability to curl into the database but would like to actually interact with it. Is this possible?

I am current using Puppet version 3.7.3 (Puppet Enterprise 3.7.1)


Solution

  • Depending on how PuppetDB is setup, it either using a built-in HSQLDB or Postgres to store its data.

    If you're using Puppet Enterprise, then it's probably going to be the Postgres backend. If that's the case, you can access it just using the psqsl command eg:

    [peter@pe-server]# psql
    psql (9.3.4)
    Type "help" for help.
    
    peter=# \c puppetdb
    You are now connected to database "puppetdb" as user "peter".
    puppetdb=# select * from schema_migrations;
     version |          time
    ---------+-------------------------
           1 | 2015-02-10 18:15:20.853
    
    puppetdb=#
    puppetdb=# \dt
                      List of relations
     Schema |          Name           | Type  |  Owner
    --------+-------------------------+-------+----------
     public | catalog_resources       | table | puppetdb
     public | catalogs                | table | puppetdb
     public | certname_facts          | table | puppetdb
     public | certname_facts_metadata | table | puppetdb
     public | certnames               | table | puppetdb
     public | edges                   | table | puppetdb
     public | environments            | table | puppetdb
     public | latest_reports          | table | puppetdb
     public | reports                 | table | puppetdb
     public | resource_events         | table | puppetdb
     public | resource_params         | table | puppetdb
     public | resource_params_cache   | table | puppetdb
     public | schema_migrations       | table | puppetdb
    (13 rows)
    

    Try running psql -h 127.0.0.1 -p 5432 -U puppetdb -W puppetdb, on your PuppetDB server, changing the username and passwords to those specified from your PE installation.

    Be careful when doing this! You don't want to mess up any data! :)