Created
November 24, 2023 10:11
-
-
Save sayan3296/3d2b8a66cd1579752bab487469b828c7 to your computer and use it in GitHub Desktop.
Properly cleanup broken DB after puppet purge and then re-enable puppet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
First step, | |
--> Cascade delete two offending tables | |
--> and delete these migrations i.e. 20090905150132 20101121140000 20201125113903 20200803113803 20200722171017 20200803113531 20200803113903 20211111125003 from schema_migration tables | |
Command to do both at once: | |
# cat << EOF |foreman-rake console | |
User.current = User.anonymous_admin | |
ActiveRecord::Base.connection.drop_table(:hostgroup_puppet_facets, if_exists: true, force: :cascade) | |
ActiveRecord::Base.connection.drop_table(:host_puppet_facets, if_exists: true, force: :cascade) | |
ActiveRecord::SchemaMigration.where(version: %w[20090905150132 20101121140000 20201125113903 20200803113803 20200722171017 20200803113531 20200803113903 20211111125003]).delete_all | |
EOF | |
Verify any tables with "puppet" string are not present: | |
# echo "\dt" | su - postgres -c "psql foreman" | grep puppet | |
Now, try enabling puppet back. Example commands: | |
6.14: | |
# satellite-installer --enable-foreman-cli-puppet --enable-foreman-plugin-puppet --enable-puppet --foreman-proxy-puppet true --foreman-proxy-puppetca true --puppet-server true | |
6.13: | |
# satellite-installer --enable-foreman-plugin-puppet --enable-foreman-cli-puppet --foreman-proxy-puppet true --foreman-proxy-puppetca true --foreman-proxy-content-puppet true --enable-puppet --puppet-server true --puppet-server-foreman-ssl-ca /etc/pki/katello/puppet/puppet_client_ca.crt --puppet-server-foreman-ssl-cert /etc/pki/katello/puppet/puppet_client.crt --puppet-server-foreman-ssl-key /etc/pki/katello/puppet/puppet_client.key | |
If successful, Unset the puppet_proxy and puppet_ca_proxy from all hosts and hostgroups. | |
cat << EOF | foreman-rake console | |
User.current = User.anonymous_admin | |
::Hostgroup.update_all(puppet_proxy_id: nil) if ActiveRecord::Base.connection.column_exists?(:hostgroups, :puppet_proxy_id) | |
::Hostgroup.update_all(puppet_ca_proxy_id: nil) if ActiveRecord::Base.connection.column_exists?(:hostgroups, :puppet_ca_proxy_id) | |
Host::Managed.update_all(puppet_proxy_id: nil) if ActiveRecord::Base.connection.column_exists?(:hosts, :puppet_proxy_id) | |
Host::Managed.update_all(puppet_ca_proxy_id: nil) if ActiveRecord::Base.connection.column_exists?(:hosts, :puppet_ca_proxy_id) | |
EOF | |
If no issues or errors, Restart the services | |
# satellite-maintain service restart | |
And verify that puppet related features are visible for satellite's own smart-proxy\capsule i.e. | |
# hammer capsule info --id 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment