What are the function of Foreman tables?
Environment
- Red Hat Satellite 6.1
Issue
- What are some of main table functions in Foreman?
Resolution
- In preparation to access this information, its required to connect to the correct database.
# su - postgres # su as the postgres user
$ psql foreman
Please see the following solution, to find out more information from candlepin tables.
This This content is not included.solution lists a diagram that shows the connection between the different databases.
-
hosts
This will list all the hosts that have been provisioned through satellite.
select * from hosts; -
To list Content Hosts from foreman, with id and uuid you can run:
select id, uuid from katello_systems;
similar command in hammer is: hammer content-host list --organization-id 1
foreman=# select id, uuid from katello_systems;
id | uuid
-----+--------------------------------------
6 | b89ddc20-3271-4210-89ea-00235329b286
7 | 8eb284b8-2e42-4c32-a08c-6f1579f0de2e
10 | 5ae5791d-2ba8-4bca-9939-34e52a5181bf
-
katello_content_views
A list of content views with their date creation, label, organization-id
select * from katello_content_views -
katello_jobs and katello_job_tasks
A list of tasks and jobs that are currently running, in this example there wasn't any task running.
select * from katello_job_tasks;
select * from katello_jobs;
- katello_content_view_repositories
A list of content views with their creation/update date.
foreman=# select * from katello_content_view_repositories;
id | content_view_id | repository_id | created_at | updated_at
----+-----------------+---------------+----------------------------+----------------------------
1 | 5 | 6 | 2015-06-22 10:49:42.108149 | 2015-06-22 10:49:42.108149
2 | 6 | 5 | 2015-06-22 10:53:32.829736 | 2015-06-22 10:53:32.829736
- foreman_tasks_tasks
We can see the current tasks that are running on foreman, with the following command.
foreman=# select started_at,state,label from foreman_tasks_tasks where state='running';
started_at | state | label
---------------------+---------+---------------------------------------------
2015-10-06 15:14:18 | running | Actions::Candlepin::ListenOnCandlepinEvents
(1 row)
- katello_repositories
We can list the repositories with urls, relative directory of where repository sits, url of where the repository comes from.
select name,cp_label,relative_path,url FROM katello_repositories WHERE NOT url='';
name | cp_label | relative_path | url
- The below command is executed into the database when running a
# hammer task list --searchcommand.
As can be seen its quite a long statement, therefore in some situations it may be easier to use the hammer commands to generate the desired results.
SELECT "foreman_tasks_tasks".* FROM "foreman_tasks_tasks" INNER JOIN "foreman_tasks_locks" ON "foreman_tasks_locks"."task_id" = "foreman_tasks_tasks"."id"
INNER JOIN foreman_tasks_locks AS foreman_tasks_locks_owner
ON (foreman_tasks_locks_owner.task_id = foreman_tasks_tasks.id AND foreman_tasks_locks_owner.resource_type = 'User' AND foreman_tasks_locks_owner.name = 'task_owner')
INNER JOIN users
ON (users.id = foreman_tasks_locks_owner.resource_id)
WHERE (
( "foreman_tasks_tasks"."id" ILIKE '%Synchronize%'
OR "foreman_tasks_tasks"."label" ILIKE '%Synchronize%'
OR "foreman_tasks_tasks"."state" ILIKE '%Synchronize%'
OR "foreman_tasks_tasks"."result" ILIKE '%Synchronize%'
OR "foreman_tasks_tasks"."parent_task_id" ILIKE '%Synchronize%'
OR foreman_tasks_locks."resource_type" ILIKE 'Synchronize'
OR users.login ILIKE 'Synchronize'
or users.firstname ILIKE 'Synchronize'
OR users.login ILIKE 'Synchronize'
or users.firstname ILIKE 'Synchronize' )
)
- Finding operatingsystems and config templates associations using psql
select id,title,hosts_count from operatingsystems;
id | title | hosts_count
----+------------+-------------
3 | RedHat 6.7 | 10
1 | RedHat 6.6 | 8
2 | RedHat 6.5 | 0
This will give you a list of operatingsystems, for instance I may want to find out more info about ID:2
Then you can run
select * from config_templates_operatingsystems;
config_template_id | operatingsystem_id
--------------------+--------------------
31 | 1
31 | 3
31 | 2
14 | 2
14 | 1
14 | 3
and further narrow this down to the operating system I need.
select * from config_templates_operatingsystems where operatingsystem_id = 2;
config_template_id | operatingsystem_id
--------------------+--------------------
31 | 2
14 | 2
Then to list more info about those two config_templates you can do:
select id,name,template_kind_id,locked,vendor from config_templates where id = 31 OR id = 14;
id | name | template_kind_id | locked | vendor
----+-----------------------------+------------------+--------+---------
14 | Kickstart default PXELinux | 1 | f |
31 | Satellite Kickstart Default | 4 | t | Katello
Then you can go to these two templates from gui and unassociate them from the operating_systems.
The association occurs because of the reference from operatingsystems table;
foreman=# \d operatingsystems
Referenced by:
TABLE "config_templates_operatingsystems" CONSTRAINT "config_templates_operatingsystems_operatingsystem_id_fk" FOREIGN KEY (operatingsystem_id) REFERENCES operatingsystems(id)
Diagnostic Steps
- A complete list of tables.
foreman=# \dt
List of relations
Schema | Name | Type | Owner
--------+-------------------------------------------------+-------+---------
public | architectures | table | foreman
public | architectures_operatingsystems | table | foreman
public | audits | table | foreman
public | auth_sources | table | foreman
.....
(138 rows)
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.