Installare E Configurare Un Server Rancid Su Centos 7
Total Page:16
File Type:pdf, Size:1020Kb
Backup dispositivi di rete Installare e configurare un server Rancid su CentOS 7 RANCID supporta hardware multiplo come di Cisco, HP, Dell, Juniper e altro ancora. Questo è un sistema open-source e permette di creare creare script personalizzati per creare u proprio questo un archivio personale degli apparati di rete. la modifica del client deve essere effettuata durante la fase di installazione, diversi pacchetti devono essere installati. Supponiamo che abbiate già installato CentOS 7 versione minima e collegata ad internet: Prima di iniziare dobbiamo eseguire l’aggiornamento di tutti i pacchetti di sistema, con i comandi: yum update yum upgrade Installiamo ora tutti i requisiti necessari per permettere a Rancid di funzionare: yum install nano wget ftp telnet mariadb-server mariadb perl tcl expect gcc cvs rcs httpd autoconf php-common php-gd php-pear php-pecl-memcache php-mysql php-xml mod_ssl MySQL-python Terminata l’installazione dei vari componenti avviamo Apache e consentiamo al suo servizio di avviarsi in automatico durante la fase di avvio: systemctl enable httpd.service systemctl start httpd.service Una volta che Apache è abilitato dovremmo vedere la pagina web di esempio da Apache quando digitiamo sul browser l'indirizzo IP del server. Ora abbiamo bisogno di aggiungere un gruppo per l'utente rancid groupadd netadm Successivamente creeremo un utente chiamato rancid e metteremo questo utente sotto il gruppo che abbiamo appena creato, che è netadm. Dovremo insereire l'utente nella home directory usando i seguenti comandi: useradd -g netadm -c "Networking Backups" -d /home/rancid rancid Creare una directory per inserire tutti i file di installazione. mkdir /home/rancid/tar Spostiamoci ora nel folder tar cd /home/rancid/tar Ed eseguiamo il download di Rancid scaricando l’ultima versione al momento disponibile 1 Backup dispositivi di rete wget ftp://ftp.shrubbery.net/pub/rancid/rancid-3.6.2.tar.gz Terminato il download estraiamo il tarball tar -zxvf rancid-3.6.2.tar.gz entriamo nella cartella scompattata di rancid cd rancid-3.6.2 Eseguiamo ora il seguente comando per preparare rancid all’installazione ./configure –prefix=/usr/local/rancid Al termine della preparazione installiamolo con il comando make install Ora dobbiamo copiare e modificare alcuni permessi: cp cloginrc.sample /home/rancid/.cloginrc chmod 0640 /home/rancid/.cloginrc chown -R rancid:netadm /home/rancid/.cloginrc chown -R rancid:netadm /usr/local/rancid/ chmod 775 /usr/local/rancid/ Dobbiamo ora modificare il file di configurazione di rancid e mettere i nostri dispositivi all’interno di gruppi. Cerchiamo "elenco di gruppi di rancid" e rimuoviamo il simbolo cancelletto. Digitiamo poi i gruppi che si vorrebbero creare, per esempio (Router Switch) nano /usr/local/rancid/etc/rancid.conf ... # list of rancid groups LIST_OF_GROUPS="Routers Switches" # more groups... #LIST_OF_GROUPS="$LIST_OF_GROUPS noc billybobisp" #... Switch su l’account Rancid con su rancid 2 Backup dispositivi di rete Eseguire il seguente comando, questo crea un repository CVS con i gruppi appena inseriti nella lista dei gruppi. /usr/local/rancid/bin/rancid-cvs No conflicts created by this import cvs checkout: Updating Routers Directory /usr/local/rancid/var/CVS/Routers/configs added to the repository cvs commit: Examining configs cvs add: scheduling file `router.db' for addition cvs add: use 'cvs commit' to add this file permanently RCS file: /usr/local/rancid/var/CVS/Routers/router.db,v done Checking in router.db; /usr/local/rancid/var/CVS/Routers/router.db,v &amp;lt;-- router.db initial revision: 1.1 done No conflicts created by this import cvs checkout: Updating Switches Directory /usr/local/rancid/var/CVS/Switches/configs added to the repository cvs commit: Examining configs cvs add: scheduling file `router.db' for addition cvs add: use 'cvs commit' to add this file permanently RCS file: /usr/local/rancid/var/CVS/Switches/router.db,v done Checking in router.db; /usr/local/rancid/var/CVS/Switches/router.db,v &amp;lt;-- router.db 3 Backup dispositivi di rete initial revision: 1.1 done Dopo l'esecuzione del comando, se tutto va a buon fine, torneremo alla radice TAR. exit cd /home/rancid/tar/ Successivamente vorremo scaricare la versione ViewVC è 1.1.23. ViewVC (ex ViewCVS) è uno strumento open source per la visualizzazione dei contenuti del CVS e SVN repository utilizzando un browser web. Permette guardando revisioni specifiche di file così come side-by-side diff di diverse revisioni. E 'scritto in Python ed i parametri di visualizzazione possono essere modificati direttamente in un URL utilizzando un'interfaccia in stile REST. wget http://viewvc.tigris.org/files/documents/3330/49392/viewvc-1.1.23.tar.gz Estraiamo il tarball tar -zxvf viewvc-1.1.23.tar.gz Spostiamoci nella cartella ViewVC e lanciamo l’installazione cd viewvc-1.1.23 ./viewvc-install Ora abbiamo bisogno di modificare il file di configurazione ViewVC, fondamentalmente dicendo a ViewVC che il repository che deve visualizzare è in CVS. nano /usr/local/viewvc-1.1.23/viewvc.conf Modifichiamo come segue: ... ## Example: ## cvs_roots = cvsroot: /opt/cvs/repos1, ## anotherroot: /usr/local/cvs/repos2 ## #cvs_roots = cvs: 4 Backup dispositivi di rete ## svn_roots: Specifies each of the Subversion roots (repositories) on ## your system and assigns names to them. Each root should be given by ... ## Example: ## root_parents = /opt/svn: svn, ## /opt/cvs: cvs ## root_parents = /usr/local/rancid/var/CVS : cvs ## default_root: This is the name of the default root. Valid names ... ## Example: ## rcs_dir = /usr/bin/ ## rcs_dir = /usr/local/bin ## cvsnt: Location of cvsnt program. ViewVC can use CVSNT (www.cvsnt.org) ... ## use_rcsparse: Use the rcsparse Python module to retrieve CVS ## repository information instead of invoking rcs utilities [EXPERIMENTAL] ## use_rcsparse = 1 … Dobbiamo ora copiare alcuni file e modificare le autorizzazioni per ViewVC. 5 Backup dispositivi di rete cp /usr/local/viewvc-1.1.23/bin/cgi/*.cgi /var/www/cgi-bin chmod +x /var/www/cgi-bin/*.cgi chown apache:apache /var/www/cgi-bin/*.cgi Per questo esempio useremo HTTP per ViewVC, anche se si potrebbe utilizzare HTTPS basta modificare il file conf di Apache (file HTTPD) nano /etc/httpd/conf/httpd.conf Inseriamo la seguente modifica alla fine del file HTTPD # Custom Rancid Config <VirtualHost *:80> DocumentRoot /var/www ScriptAlias /cgi-bin/ "/var/www/cgi-bin" ScriptAlias /viewvc /var/www/cgi-bin/viewvc.cgi ScriptAlias /query /var/www/cgi-bin/query.cgi <Directory "/var/www/cgi-bin"> AllowOverride None Options None Order allow,deny Allow from all </Directory> </VirtualHost> Abbiamo quasi finito, ora abbiamo bisogno di accendere al database MariaDB che ViewVC utilizza come base di dati, avviamo l'installazione sicura. (Accetta tutti i valori di default e digitare una password di root per MariaDB.) systemctl enable mariadb systemctl start mariadb 6 Backup dispositivi di rete sudo mysql_secure_installation Accediamo a MariaDB per creare un utente per ViewVC. Per accedere al db utilizziamo la password che abbiamo appena creato. mysql -u root -p Digitiamo quanto segue: CREATE USER 'VIEWVC'@'localhost' IDENTIFIED BY 'YourPasswordHere'; GRANT ALL PRIVILEGES ON *.* TO 'VIEWVC'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES; quit Inserire nel file conf del database di ViewVC il nome utente e la password che abbiamo appena creato. (Accettare le impostazioni predefinite) /usr/local/viewvc-1.1.23/bin/make-database MySQL Hostname (leave blank for default): MySQL Port (leave blank for default): MySQL User: VIEWVC MySQL Password: YourPasswordHere ViewVC Database Name [default: ViewVC]: Database created successfully. Don't forget to configure the [cvsdb] section of your viewvc.conf file. Torniamo a logarci in MariaDB come utente root mysql -u root -p Creiamo ora un utente in sola lettura per ViewVC CREATE USER 'VIEWVCRO'@'localhost' IDENTIFIED BY 'YourROPasswordHere'; GRANT SELECT ON ViewVC.* TO 'VIEWVCRO'@'localhost' WITH GRANT OPTION; FLUSH PRIVILEGES; 7 Backup dispositivi di rete quit Ora dobbiamo configurare il file di configurazione ViewVC con i nomo utente e le password a che abbiamo creato in MySQL. nano /usr/local/viewvc-1.1.23/viewvc.conf Cerchiamo cvsdb e modificarlo come per il seguito: ##--------------------------------------------------------------------------- [cvsdb] ## enabled: Enable database integration feature. ## enabled = 1 ## host: Database hostname. Leave unset to use a local Unix socket ## connection. ## host = localhost ## post: Database listening port. ## port = 3306 ## database_name: ViewVC database name. ## database_name = ViewVC 8 Backup dispositivi di rete ## user: Username of user with read/write privileges to the database ## specified by the 'database_name' configuration option. ## user = VIEWVC ## passwd: Password of user with read/write privileges to the database ## specified by the 'database_name' configuration option. ## passwd = YourPasswordHere ## readonly_user: Username of user with read privileges to the database ## specified by the 'database_name' configuration option. ## readonly_user = VIEWVCRO ## readonly_passwd: Password of user with read privileges to the database ## specified by the 'database_name' configuration option. ## readonly_passwd = YourROPasswordHere Eseguire il seguente comando per creare il database. /usr/local/viewvc-1.1.23/bin/cvsdbadmin rebuild /usr/local/rancid/var/CVS/CVSROOT/ Riavviare il server una volta on-line si dovrebbe i repository: http://rancid-servicer-ip/viewvc 9 Backup dispositivi di rete Se vedete