def set_timezone(self, timezone): timezone_path = '/etc/timezone' localtime_path = '/etc/localtime' deployment.remove_file(self.join_root(timezone_path)) deployment.remove_file(self.join_root(localtime_path)) deployment.write(self.join_root(timezone_path), timezone) self.reconfigure_package('tzdata')
def ensure_netplan_enabled(self): # removing self.netplan_systemd_generator_file allows netplan to run at boot. Disabling and # masking of networking.service and setting CONFIGURE_INTERFACES=no disables ifupdown deployment.remove_file(self.netplan_systemd_generator_file) self.chroot('systemctl disable networking.service') self.chroot('systemctl mask networking.service') deployment.replace_line_in_file(self.default_networking, 'CONFIGURE_INTERFACES', 'CONFIGURE_INTERFACES=no')
def ssh_keygen(self, path, key_type, passphrase='', comment='localhost.localdomain'): deployment.remove_file(self.join_root(path)) command = 'ssh-keygen -f %s -t%s -Cpress@%s -N \"%s\"' % ( path, key_type, comment, passphrase) self.chroot(command)
def update_host_keys(self): log.info('Updating SSH host keys') hostname = self.network_configuration.get('hostname', 'localhost.localdomain') for f in glob.glob(self.join_root('/etc/ssh/ssh_host*')): log.info('Removing: %s' % f) deployment.remove_file(f) for key_type in self.ssh_protocol_2_key_types: path = '/etc/ssh/ssh_host_%s_key' % key_type log.info('Creating SSH host key %s' % path) self.ssh_keygen(path, key_type, comment=hostname)
def remove_repo(self, name): path_name = name.lower().replace(" ", "_") log.info('Removing repo file for "{name}"'.format(name=name)) sources_path = self.join_root( '/etc/yum.repos.d/{name}.repo'.format(name=path_name)) deployment.remove_file(sources_path)
def remove_no_start_hack(self): log.info('Removing NOSTART hack') deployment.remove_file(self.join_root(self.__start_hack_path))
def set_timezone(self, timezone): localtime_path = self.join_root('/etc/localtime') deployment.remove_file(localtime_path) zone_info = os.path.join('../usr/share/zoneinfo/', timezone) deployment.create_symlink(zone_info, localtime_path)