Browse Source

Merge branch 'master' of bitbucket.org:ikflowdat/installer into FD3-159

Luciano Andrade 7 năm trước cách đây
mục cha
commit
1ef1880831
5 tập tin đã thay đổi với 316 bổ sung28 xóa
  1. 6 5
      docker-compose.yml
  2. 11 0
      grafana.env
  3. 263 0
      tools/mysql/freeradius/schema.sql
  4. 11 0
      tools/playbook.yml
  5. 25 23
      tools/src/Release.php

+ 6 - 5
docker-compose.yml

@@ -284,7 +284,7 @@ services:
     image: fd3_simple_json_endpoint
     ports:
       - 9003:8000
-    build: 
+    build:
       context: ./extra/statsd/endpoint/json
     links:
         - mysql_jsonendpoint:mysql_jsonendpoint
@@ -303,7 +303,7 @@ services:
       - mysql:mysql
     ports:
       - 9000:8000
-    build: 
+    build:
       context: ./extra/statsd/endpoint/mysql
     volumes:
       - ./extra/statsd/endpoint/mysql:/opt/datasource
@@ -316,7 +316,7 @@ services:
       - mongodb:mongodb
     ports:
       - 9002:8000
-    build: 
+    build:
       context: ./extra/statsd/endpoint/mongodb
     volumes:
       - ./extra/statsd/endpoint/mongodb:/opt/datasource
@@ -337,7 +337,7 @@ services:
   statsd:
     restart: always
     image: fd3-statsd-mysql-backend
-    build: 
+    build:
       context: ./extra/statsd/statsd
     ports:
       - "8125:8125/udp"
@@ -367,7 +367,7 @@ services:
       - ./supervisord/bin/fiberlink:/usr/bin/fiberlink
     environment:
       TERM: "xterm"
-  
+
   geoserver:
     build:
       context: ./extra/geoserver/
@@ -396,6 +396,7 @@ services:
             - './extra/nginx/certs:/etc/nginx/certs:ro'
             - './extra/nginx/vhost.d:/etc/nginx/vhost.d'
             - './extra/nginx/share:/usr/share/nginx/html'
+
   redis:
     image: redis:latest
     restart: always

+ 11 - 0
grafana.env

@@ -0,0 +1,11 @@
+CLIENT=''
+VIRTUAL_HOST=grafana.${CLIENT}.flowdat.com
+HTTPS_METHOD=nohttps
+GF_SECURITY_ADMIN_PASSWORD=queRini6
+GF_INSTALL_PLUGINS=grafana-simple-json-datasource
+GF_DEFAULT_THEME=light
+GF_AUTH_ANONYMOUS_ORG_NAME="Main Org."
+GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer
+GF_AUTH_ANONYMOUS_ENABLED=true
+GF_DATABASE_URL="mysql://root:235r2342gtfsw@mysql:3306/grafana"
+GF_SERVER_ROOT_URL=http://${VIRTUAL_HOST}/

+ 263 - 0
tools/mysql/freeradius/schema.sql

@@ -0,0 +1,263 @@
+USE mysql;
+REPLACE INTO user (Host, User, Password) VALUES ('localhost','radius','radpass');
+REPLACE INTO db (Host, Db, User, Select_priv) VALUES ('localhost','radius','radius','Y');
+GRANT USAGE ON * . * TO 'radius'@'localhost' IDENTIFIED BY 'radpass';
+CREATE DATABASE IF NOT EXISTS radius;
+FLUSH PRIVILEGES;
+GRANT ALL PRIVILEGES ON radius . * TO 'radius'@'localhost';
+FLUSH PRIVILEGES;
+
+
+USE radius;
+CREATE TABLE IF NOT EXISTS `badusers` (
+  `id` int(10) NOT NULL AUTO_INCREMENT,
+  `UserName` varchar(30) DEFAULT NULL,
+  `Date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
+  `Reason` varchar(200) DEFAULT NULL,
+  `Admin` varchar(30) DEFAULT '-',
+  PRIMARY KEY (`id`),
+  KEY `UserName` (`UserName`),
+  KEY `Date` (`Date`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `mtotacct`
+--
+
+CREATE TABLE IF NOT EXISTS `mtotacct` (
+  `MTotAcctId` bigint(21) NOT NULL AUTO_INCREMENT,
+  `UserName` varchar(64) NOT NULL DEFAULT '',
+  `AcctDate` date NOT NULL DEFAULT '0000-00-00',
+  `ConnNum` bigint(12) DEFAULT NULL,
+  `ConnTotDuration` bigint(12) DEFAULT NULL,
+  `ConnMaxDuration` bigint(12) DEFAULT NULL,
+  `ConnMinDuration` bigint(12) DEFAULT NULL,
+  `InputOctets` bigint(12) DEFAULT NULL,
+  `OutputOctets` bigint(12) DEFAULT NULL,
+  `NASIPAddress` varchar(15) DEFAULT NULL,
+  PRIMARY KEY (`MTotAcctId`),
+  KEY `UserName` (`UserName`),
+  KEY `AcctDate` (`AcctDate`),
+  KEY `UserOnDate` (`UserName`,`AcctDate`),
+  KEY `NASIPAddress` (`NASIPAddress`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `nas`
+--
+
+CREATE TABLE IF NOT EXISTS `nas` (
+  `id` int(10) NOT NULL AUTO_INCREMENT,
+  `nasname` varchar(128) NOT NULL DEFAULT '',
+  `shortname` varchar(32) DEFAULT NULL,
+  `type` varchar(30) DEFAULT 'other',
+  `ports` int(5) DEFAULT NULL,
+  `secret` varchar(60) NOT NULL DEFAULT 'secret',
+  `community` varchar(50) DEFAULT NULL,
+  `description` varchar(200) DEFAULT 'RADIUS Client',
+  `server` varchar(32) NOT NULL,
+  `acct_enabled` tinyint(1) NOT NULL,
+  PRIMARY KEY (`id`),
+  KEY `nasname` (`nasname`)
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `radacct`
+--
+
+CREATE TABLE IF NOT EXISTS `radacct` (
+  `radacctid` bigint(21) NOT NULL AUTO_INCREMENT,
+  `acctsessionid` varchar(64) NOT NULL DEFAULT '',
+  `acctuniqueid` varchar(32) NOT NULL DEFAULT '',
+  `username` varchar(64) NOT NULL DEFAULT '',
+  `groupname` varchar(64) NOT NULL DEFAULT '',
+  `realm` varchar(64) DEFAULT '',
+  `nasipaddress` varchar(15) NOT NULL DEFAULT '',
+  `nasportid` varchar(15) DEFAULT NULL,
+  `nasporttype` varchar(32) DEFAULT NULL,
+  `acctstarttime` datetime DEFAULT NULL,
+  `acctstoptime` datetime DEFAULT NULL,
+  `acctsessiontime` int(12) DEFAULT NULL,
+  `acctauthentic` varchar(32) DEFAULT NULL,
+  `connectinfo_start` varchar(50) DEFAULT NULL,
+  `connectinfo_stop` varchar(50) DEFAULT NULL,
+  `acctinputoctets` bigint(20) DEFAULT NULL,
+  `acctoutputoctets` bigint(20) DEFAULT NULL,
+  `calledstationid` varchar(50) NOT NULL DEFAULT '',
+  `callingstationid` varchar(50) NOT NULL DEFAULT '',
+  `acctterminatecause` varchar(32) NOT NULL DEFAULT '',
+  `servicetype` varchar(32) DEFAULT NULL,
+  `framedprotocol` varchar(32) DEFAULT NULL,
+  `framedipaddress` varchar(15) NOT NULL DEFAULT '',
+  `acctstartdelay` int(12) DEFAULT NULL,
+  `acctstopdelay` int(12) DEFAULT NULL,
+  `xascendsessionsvrkey` varchar(10) DEFAULT NULL,
+  `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  PRIMARY KEY (`radacctid`),
+  KEY `username` (`username`),
+  KEY `framedipaddress` (`framedipaddress`),
+  KEY `acctsessionid` (`acctsessionid`),
+  KEY `acctsessiontime` (`acctsessiontime`),
+  KEY `acctuniqueid` (`acctuniqueid`),
+  KEY `acctstarttime` (`acctstarttime`),
+  KEY `acctstoptime` (`acctstoptime`),
+  KEY `nasipaddress` (`nasipaddress`)
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `radcheck`
+--
+
+CREATE TABLE IF NOT EXISTS `radcheck` (
+  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `UserName` varbinary(64) NOT NULL DEFAULT '',
+  `Attribute` varchar(32) NOT NULL DEFAULT '',
+  `op` char(2) NOT NULL DEFAULT '==',
+  `Value` varchar(253) NOT NULL DEFAULT '',
+  PRIMARY KEY (`id`),
+  KEY `UserName` (`UserName`(32))
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1 PACK_KEYS=0 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `radgroupcheck`
+--
+
+CREATE TABLE IF NOT EXISTS `radgroupcheck` (
+  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `GroupName` varchar(64) NOT NULL DEFAULT '',
+  `Attribute` varchar(32) NOT NULL DEFAULT '',
+  `op` char(2) NOT NULL DEFAULT '==',
+  `Value` varchar(253) NOT NULL DEFAULT '',
+  PRIMARY KEY (`id`),
+  KEY `GroupName` (`GroupName`(32))
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `radgroupreply`
+--
+
+CREATE TABLE IF NOT EXISTS `radgroupreply` (
+  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `GroupName` varchar(64) NOT NULL DEFAULT '',
+  `Attribute` varchar(32) NOT NULL DEFAULT '',
+  `op` char(2) NOT NULL DEFAULT '=',
+  `Value` varchar(253) NOT NULL DEFAULT '',
+  `prio` int(10) unsigned NOT NULL DEFAULT '0',
+  PRIMARY KEY (`id`),
+  KEY `GroupName` (`GroupName`(32))
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `radpostauth`
+--
+
+CREATE TABLE IF NOT EXISTS `radpostauth` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `username` varchar(64) NOT NULL DEFAULT '',
+  `pass` varchar(64) NOT NULL DEFAULT '',
+  `reply` varchar(32) NOT NULL DEFAULT '',
+  `authdate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+  PRIMARY KEY (`id`)
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `radreply`
+--
+
+CREATE TABLE IF NOT EXISTS `radreply` (
+  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `UserName` varchar(64) NOT NULL DEFAULT '',
+  `Attribute` varchar(32) NOT NULL DEFAULT '',
+  `op` char(2) NOT NULL DEFAULT '=',
+  `Value` varchar(253) NOT NULL DEFAULT '',
+  PRIMARY KEY (`id`),
+  KEY `UserName` (`UserName`(32))
+) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `radusergroup`
+--
+
+CREATE TABLE IF NOT EXISTS `radusergroup` (
+  `username` varchar(64) NOT NULL DEFAULT '',
+  `groupname` varchar(64) NOT NULL DEFAULT '',
+  `priority` int(11) NOT NULL DEFAULT '1',
+  KEY `username` (`username`(32))
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `totacct`
+--
+
+CREATE TABLE IF NOT EXISTS `totacct` (
+  `TotAcctId` bigint(21) NOT NULL AUTO_INCREMENT,
+  `UserName` varchar(64) NOT NULL DEFAULT '',
+  `AcctDate` date NOT NULL DEFAULT '0000-00-00',
+  `ConnNum` bigint(12) DEFAULT NULL,
+  `ConnTotDuration` bigint(12) DEFAULT NULL,
+  `ConnMaxDuration` bigint(12) DEFAULT NULL,
+  `ConnMinDuration` bigint(12) DEFAULT NULL,
+  `InputOctets` bigint(12) DEFAULT NULL,
+  `OutputOctets` bigint(12) DEFAULT NULL,
+  `NASIPAddress` varchar(15) DEFAULT NULL,
+  PRIMARY KEY (`TotAcctId`),
+  KEY `UserName` (`UserName`),
+  KEY `AcctDate` (`AcctDate`),
+  KEY `UserOnDate` (`UserName`,`AcctDate`),
+  KEY `NASIPAddress` (`NASIPAddress`),
+  KEY `NASIPAddressOnDate` (`AcctDate`,`NASIPAddress`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `usergroup`
+--
+
+CREATE TABLE IF NOT EXISTS `usergroup` (
+  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
+  `UserName` varchar(64) NOT NULL DEFAULT '',
+  `GroupName` varchar(64) NOT NULL DEFAULT '',
+  PRIMARY KEY (`id`),
+  KEY `UserName` (`UserName`(32))
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+
+-- --------------------------------------------------------
+
+--
+-- Estructura de tabla para la tabla `userinfo`
+--
+
+CREATE TABLE IF NOT EXISTS `userinfo` (
+  `id` int(10) NOT NULL AUTO_INCREMENT,
+  `UserName` varchar(30) DEFAULT NULL,
+  `Name` varchar(200) DEFAULT NULL,
+  `Mail` varchar(200) DEFAULT NULL,
+  `Department` varchar(200) DEFAULT NULL,
+  `WorkPhone` varchar(200) DEFAULT NULL,
+  `HomePhone` varchar(200) DEFAULT NULL,
+  `Mobile` varchar(200) DEFAULT NULL,
+  PRIMARY KEY (`id`),
+  KEY `UserName` (`UserName`),
+  KEY `Departmet` (`Department`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

+ 11 - 0
tools/playbook.yml

@@ -109,6 +109,17 @@
         name: fd_session
         target: "/tmp/mysql_scripts.sql"
 
+    - copy:
+        src: "{{ playbook_dir }}/freeradius_schema.sql"
+        dest: /tmp/freeradius_schema.sql
+
+    - name: Create freeradius MySQL schema
+      mysql_db:
+        login_password: "{{ lookup('env', 'MYSQL_PASSWORD') }}"
+        state: import
+        name: freeradius
+        target: "/tmp/freeradius_schema.sql"
+
     - name: Create user iksop
       mysql_user:
         name: 'iksop'

+ 25 - 23
tools/src/Release.php

@@ -21,42 +21,52 @@ class Release extends Command
      * @var string Nombre del archivo de log.
      */
     private $_running_log;
+
     /**
      * @var string Contiene la politica de restart de los dockers.
      */
     private $_docker_restart_default;
+
     /**
      * @var array Contiene las variables que se utilizar en la ejecucion del ansible.
      */
     private $_ansible_vars;
+
     /**
      * @var string Contiene el password del usuario root.
      */
     private $_mysql_root_pass;
+
     /**
      * @var string Contiene el usuario de base de datos.
      */
     private $_mysql_user;
+
     /**
      * @var string Contiene la contrasena del  usuario de base de datos.
      */
     private $_mysql_pass;
+
     /**
      * @var DevOps\FileSystem Me permite crear archivos.
      */
     private $_dObj;
+
     /**
      * @var string Contiene el dominio.
      */
     private $_domain;
+
     /**
      * @var string Contiene el nombre del cliente.
      */
     private $_client;
+
     /**
      * @var array Contiene todos los modulos para la instalacion.
      */
     private $_modules_all;
+
     /**
      * @var array Contiene la configuracion de los modulos.
      */
@@ -281,26 +291,31 @@ class Release extends Command
                 $this->writeUserSystem();
 
                 $dObj->file('install.yml')->content(
-                yaml::dump(array(
-                "install_dir" => realpath($dir),
-                'docker_apps' => "base," . implode(",", $this->_ansible_vars),
-                'domain' => $this->_domain,
-                )
-                )
+				yaml::dump(array(
+					"install_dir" => realpath($dir),
+					'docker_apps' => "base," . implode(",", $this->_ansible_vars),
+					'domain' => $this->_domain,
+				)
+			)
                 );
 
                 $dObj->file('ansible.cfg')->content(
-                "[defaults]\n" .
-                "inventory=inventory.ini\n"
+			"[defaults]\n" .
+			"inventory=inventory.ini\n"
+
                 );
                 // copio el playbook
                 copy(getcwd() . "/playbook.yml", $dObj->dirExists()->realpath()->getPath() . "/playbook.yml");
                 // copio el script de base de datos inicial
                 copy(getcwd() . "/mysql_scripts.sql", $dObj->dirExists()->realpath()->getPath() . "/mysql_scripts.sql");
 
+                // copio script mysql schema freeradius
+                copy(getcwd() . "/mysql/freeradius/schema.sql", $dObj->dirExists()->realpath()->getPath() . "/freeradius_schema.sql");
+
                 copy(getcwd() . "/docker-compose.service", $dObj->dirExists()->realpath()->getPath() . "/docker-compose.service");
             } catch (\Throwable $error) {
                 var_dump($error->getTraceAsString(), $error->getCode(), $error->getMessage());
+		throw $error;
             } finally {
                 $this->_dObj = null;
                 $this->_modules = null;
@@ -569,7 +584,6 @@ class Release extends Command
             ->addVolumes("./extra/supervisord/bin/fiberlink", "/usr/bin/fiberlink");
     }
 
-
     function addMySql(FileFormat2 $composer, $config = array())
     {
         $module = "mysql";
@@ -688,20 +702,8 @@ class Release extends Command
         ->image("grafana/grafana")
         ->addLinks("mysql")
         ->restart($this->_docker_restart_default)
-        ->addEnv_file("mysql." . $host_env_file)
-        ->addVolumes("./statsd/grafana/lib", "/var/lib/grafana");
-
-        $this->writeVariablesEnviroment($module . "." . $host_env_file, $module,
-        array(
-            "GF_SECURITY_ADMIN_PASSWORD", "queRini6",
-            "GF_INSTALL_PLUGINS", "grafana-simple-json-datasource",
-            "GF_DEFAULT_THEME", "light",
-            "GF_AUTH_ANONYMOUS_ORG_NAME", "Main Org.",
-            "GF_AUTH_ANONYMOUS_ORG_ROLE", "Viewer",
-            "GF_AUTH_ANONYMOUS_ENABLED", "true",
-            "GF_DATABASE_URL", "mysql://root:" . $this->_mysql_root_pass . "@mysql:3306/grafana",
-            "GF_SERVER_ROOT_URL", "http://" . $this->getDomain("grafana") . "/"
-        ));
+        ->addEnv_file("grafana.env")
+        ->addVolumes("./extra/statsd/grafana/lib", "/var/lib/grafana");
 
         $this->addJsonEndPoints($composer, $config);
     }