
In this playground we will show you how easy it is to manage your database set-up with Puppet. How you can add and manage tablespaces, and roles. We will also show you one line of Puppet code that makes your database secure.
The playground system contains a pre-installed puppet agent. There is no server available, so to run Puppet, you have to use the puppet apply
command. The playground text will guide you with this.
On the playground system, you will find an Postgres database. We have created it using the pg_profile
module. The playground will guide you in your customisations.
Under this text, you see the working area. You can inspect the system and issue any command you like in the terminal. In the editor window, you can see the Puppet production environment. You can edit anything you wish. The documentation tab shows the documentation for the pg_config
module.
This system will self destruct in about one hour. So please don’t use it to build or create anything you wish to keep!
Ensure databasesAfter you have installed your software and created your primary database, you may need to add some specific databases. You can do this by adding some data to your hiera data. In the editor tab, go to the directory Now add this data to it:
This data tells Puppet to ensure that the databases First Puppet runPuppet runs will read this data and make sure the database is available with the specified properties. Puppet will detect that the database is unknown and create it since we will apply Puppet for the first time with this data.
Let’s inspect the Puppet output. Somewhere near the top you’ll see:
This is the information Puppet provides you about the databases it manages. When you look at the Puppet output, somewhere near the end, you will see this:
So Puppet created the database. Second Puppet runOne of the essential features of Puppet is that it is idempotent. Idempotent means it will not apply changes a second time. So if we rerun Puppet, it should see that the database already exists with the specified properties and do nothing. Let’s verify that and rerun Puppet:
We still see the message at the top that Puppet manages the database, but we no longer have the creation message, just as we expected. Manage database rolesNow let’s add some database roles. Again you only need to add some yaml settings to your hiera data. For managing database users, we can use the hiera key In the editor tab, go to the directory Now add this data to it:
First Puppet runPuppet runs will read this data and make sure the database user is available with the specified properties. Puppet will detect that the user is unknown and create it since we will apply Puppet for the first time with this data.
Let’s inspect the Puppet output. Somewhere near the top you’ll see:
This is the information Puppet provides you about the users it manages. When you look at the Puppet output, somewhere near the end, you will see this:
So Puppet created the database user. Second Puppet runOne of the essential features of Puppet is that it is idempotent. Idempotent means it will not apply changes a second time. So if we rerun Puppet, it should see that the database user already exists with the specified properties and do nothing. Let’s verify that and rerun Puppet:
We still see the message at the top that Puppet manages the user, but we no longer have the creation message, just as we expected. More informationSee the documentation what kind of user properties you can manage with Puppet use. Manage database parametersYou can also manage your database parameters with Puppet. Let’s change the log_connections value for this database from For managing database users, we can use the hiera key In the editor tab, go to the directory Now add this data to it:
First Puppet runPuppet runs will read this data and make sure the parameters are available and have the correct value. Puppet will detect that the parameters have a different value since we will apply Puppet for the first time with this data.
Let’s inspect the Puppet output. Somewhere near the top you’ll see:
This is the information Puppet provides you about the parameters it manages. When you look at the Puppet output, somewhere near the end, you will see this:
So Puppet ensured that both parameters are present and set to the correct value. Second Puppet runOne of the essential features of Puppet is that it is idempotent. Idempotent means it will not apply changes a second time. So if we rerun Puppet, it should see that the database parameters are already set with the correct values and do nothing. Let’s verify that and rerun Puppet:
We still see the message at the top that Puppet manages the user, but we no longer have the creation message, just as we expected. More informationSee the documentation what kind of user properties you can manage with Puppet use. Ensure tablespacesAfter you have installed created your primary roles, and databases, most of the time, you need to have some specific tablespaces. You can do this by adding some data to your hiera data. In the editor tab, go to the directory Now add this data to it:
This data tells Puppet to ensure that path First Puppet runPuppet runs will read this data and make sure the tablespace is available with the specified properties. Puppet will detect that the tablespace is unknown and create it since we will apply Puppet for the first time with this data.
Let’s inspect the Puppet output. Somewhere near the top you’ll see:
This is the information Puppet provides you about the tablespaces it manages. When you look at the Puppet output, somewhere near the end, you will see this:
So Puppet created the tablespace. Second Puppet runOne of the essential features of Puppet is that it is idempotent. Idempotent means it will not apply changes a second time. So if we rerun Puppet, it should see that the tablespace already exists with the specified properties and do nothing. Let’s verify that and rerun Puppet:
We still see the message at the top that Puppet manages the tablespace, but we no longer have the creation message, just as we expected. You like it?Do you like what you see here and want to test this on your own infrastructure? No problem. You can sign up for a free trial. If you have any questions, don’t hesitate to contact us. |
![]() ![]() |