示例#1
0
	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
示例#2
0
	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')