def setup_logger(self): path = UserDefaults.log_path() dirname = os.path.dirname(path) if not os.path.exists(dirname): os.makedirs(dirname, 0o770) logger = logging.getLogger('opsmop') logger.setLevel(logging.DEBUG) handler = logging.handlers.RotatingFileHandler(path, maxBytes=1024 * 5000, backupCount=5) formatter = logging.Formatter(UserDefaults.log_format()) handler.setFormatter(formatter) logger.addHandler(handler) return logger
def process_remote_role(self, policy, role): """ Processes one role in any mode """ import dill self.connection_manager.announce_role(role) hosts = role.inventory().hosts() self.connection_manager.add_hosts(hosts) batch_size = role.serial() max_workers = UserDefaults.max_workers() self.compute_max_hostname_length(hosts) self.connection_manager.prepare_for_role(role) self.connect_to_all_hosts(hosts, role, max_workers) self.run_roles_on_all_hosts(hosts, policy, role, batch_size) self.connection_manager.event_loop() self.process_summary(hosts)
def check_host_keys(self): return self.variables.get('opsmop_ssh_check_host_keys', UserDefaults.ssh_check_host_keys())
def sudo_password(self): return self.variables.get('opsmop_sudo_password', UserDefaults.sudo_password())
def sudo_username(self): return self.variables.get('opsmop_sudo_username', UserDefaults.sudo_username())
def check_host_keys(self): return UserDefaults.ssh_check_host_keys()
def sudo_as(self): return (UserDefaults.sudo_username(), UserDefaults.sudo_password())
def ssh_as(self): return (UserDefaults.ssh_username(), UserDefaults.ssh_password())
def python_path(self): return self.variables.get('opsmop_python_path', UserDefaults.python_path())