def install(self): """ Method used to install, link, update puppet client. """ c = Common() c.banner() c.client_hosts() hostname = Hostname() hostname.check() l = Logger(c.client_name()) reader = open(self.logfile) startline = len(reader.readlines()) l.event_counter(startline) try: operatingSystem = run("/bin/cat /etc/issue | /usr/bin/awk '{print $1}'") if(operatingSystem=='Debian'): run('aptitude -y update && aptitude -y install puppet') else: print '--->\tOS not supported' sys.exit(0) puppetthread = AddCert() puppetthread.start() puppetthread.join() except Exception, e: print 'error :', e
def __init__(self,hostaddr=None,noop='noop'): """ """ Conf.__init__(self) logfile = self.logfile c = Common() c.banner() c.client_hosts() self.__host=hostaddr self.__noop=noop self.__counter = 0 self.__exclude = 0 self.__reader = open(logfile) self.__startline = len(self.__reader.readlines()) self.__reader.close() l = Logger('initiator') l.logx('-'*70) if self.__host=='all': l.logx('Update command on all hosts executed') self.update_all() l.event_counter(self.__startline) elif re.match(r'^\.\*$',self.__host): print '\n[-]--> please use \'all\' instead of \'.*\'\n' elif re.match(r'.*[\.\*\+\[\]]+.*',self.__host): l.logx('Update regex command (%s) executed' % self.__host) self.reget_host() l.event_counter(self.__startline) else: l.logx('Update command on %s executed' % self.__host) env.host_string=self.__host self.update_host() l.event_counter(self.__startline) l.logx('End of execution')
def remove(self): """ Method used to remove puppet, erase custom facts on puppet client. """ c = Common() c.banner() c.client_hosts() operatingSystem = run("/bin/cat /etc/issue | /usr/bin/awk '{print $1}'") if(operatingSystem=='Debian'): run('aptitude -y purge puppet') run('find /var/lib/puppet -type f -print0 | xargs -0r rm') else: print '--->\tOS not supported' sys.exit(0) try: subprocess.call(['/usr/sbin/puppetca', '--clean', '%s.%s' % (c.client_name(),self.domain)]) except Exception, e: print 'error :', e pass