diff --git a/hammer.py b/hammer.py index 7d536fd428..a3dd32fad2 100755 --- a/hammer.py +++ b/hammer.py @@ -59,7 +59,8 @@ SYSTEMS = { '8', ], 'rhel': [ - '8' + '8', + '9', ], 'ubuntu': [ #'16.04', @@ -264,7 +265,7 @@ def get_system_revision(): for l in f.readlines(): if '=' in l: key, val = l.split('=', 1) - vals[key.strip()] = val.strip() + vals[key.strip()] = val.strip().replace('"', '') for i in ['ID', 'ID_LIKE']: if i in vals and vals[i] in SYSTEMS: @@ -280,7 +281,7 @@ def get_system_revision(): if revision is None: raise Exception('cannot determine revision') - if system == 'alpine': + if system in ['alpine', 'rhel']: revision = revision.rsplit('.', 1)[0] else: raise Exception('cannot determine system or its revision') @@ -490,7 +491,7 @@ def install_pkgs(pkgs, timeout=60, env=None, check_times=False, pkg_cache=None): # skip_missing_names_on_install used to detect case when one packet is not found and no error is returned # but we want an error cmd = 'sudo yum install -y --setopt=skip_missing_names_on_install=False' - elif system == 'fedora' or (system in ['centos', 'rhel'] and revision == '8'): + elif system == 'fedora' or (system in ['centos', 'rhel'] and revision in ['8', '9']): cmd = 'sudo dnf -y install' elif system in ['debian', 'ubuntu']: # prepare the command for ubuntu/debian @@ -1268,22 +1269,26 @@ ssl_key = {cert_dir}/kea-client.key execute(cmd) -def _enable_postgresql(system): +def _enable_postgresql(system, revision): if system == 'alpine': execute('sudo rc-update add postgresql') elif system == 'freebsd': execute('sudo sysrc postgresql_enable="yes"') + elif system == 'rhel' and revision == '9': + execute('sudo systemctl enable postgresql-14.service') else: execute('sudo systemctl enable postgresql.service') -def _restart_postgresql(system): +def _restart_postgresql(system, revision): if system == 'freebsd': # redirecting output from start script to /dev/null otherwise the postgresql rc.d script will hang # calling restart instead of start allow hammer.py to pass even if postgresql is already installed execute('sudo service postgresql restart > /dev/null') elif system == 'alpine': execute('sudo /etc/init.d/postgresql restart') + elif system == 'rhel' and revision == '9': + execute('sudo systemctl restart postgresql-14.service') else: execute('sudo systemctl restart postgresql.service') @@ -1297,7 +1302,7 @@ def _change_postgresql_auth_method(connection_type, auth_method, hba_file): connection_type, connection_type, auth_method, hba_file), cwd='/tmp') -def _configure_pgsql(system, features): +def _configure_pgsql(system, features, revision): """ Configure PostgreSQL DB """ # execute() calls will set cwd='/tmp' when switching user to postgres to @@ -1310,6 +1315,8 @@ def _configure_pgsql(system, features): if exitcode != 0: if system == 'centos': execute('sudo postgresql-setup initdb') + elif system == 'rhel' and revision == '9': + execute('sudo postgresql-14-setup initdb') else: execute('sudo postgresql-setup --initdb --unit postgresql') elif system == 'freebsd': @@ -1329,8 +1336,8 @@ def _configure_pgsql(system, features): # the initial start of the postgresql will create the 'postmaster.opts' file execute('sudo test ! -f {}/postmaster.opts && sudo service postgresql onestart || true'.format(var_db_postgres_data)) - _enable_postgresql(system) - _restart_postgresql(system) + _enable_postgresql(system, revision) + _restart_postgresql(system, revision) # Change auth-method to 'md5' on all connections. cmd = "sudo -u postgres psql -t -c 'SHOW hba_file' | xargs" @@ -1350,7 +1357,7 @@ def _configure_pgsql(system, features): {} ' '{}'""".format(auth_header, postgres_auth_line, hba_file)) - _restart_postgresql(system) + _restart_postgresql(system, revision) cmd = """bash -c \"cat <