jLinux

Untitled

Dec 25th, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2.  
  3. const Crypto = require( 'crypto' );
  4. const _      = require( 'lodash' );
  5.  
  6. exports.seed = function( knex, Promise ) {
  7.     return Promise.join(
  8.         knex( 'operating_systems' ).del(),
  9.         knex.insert([
  10.             { created_at: knex.fn.now(), type: 'linux',     flavor: 'Ubuntu', release: '7.10', code_name: 'gutsy', description: 'Ubuntu 7.10'                },
  11.             { created_at: knex.fn.now(), type: 'linux',     flavor: 'CentOS', release: '6.7',  code_name: null,    description: 'CentOS release 6.7 (Final)' },
  12.             { created_at: knex.fn.now(), type: 'linux',     flavor: 'RedHat', release: '6',    code_name: null,    description: 'RedHat Enterprise Linux 6'  },
  13.             { created_at: knex.fn.now(), type: 'microsoft', flavor: '2008',   release: 'r2',   code_name: null,    description: 'Windows Server 2008 r2'     }
  14.         ]).into( 'operating_systems' ),
  15.  
  16.         knex( 'servers' ).del(),
  17.         knex.insert([
  18.             {    // 1
  19.                 created_at: knex.fn.now(),
  20.                 server_hostname: 'lpweb01.server.ad',
  21.                 monitoring: 1,
  22.                 operating_system_id: 1,
  23.                 root_password: Crypto.createHash('md5').update( 'str - ' + _.random(0, 20) ).digest('hex')
  24.             }, { // 2
  25.                 created_at: knex.fn.now(),
  26.                 server_hostname: 'ldjen02.server.ad',
  27.                 monitoring: 1,
  28.                 operating_system_id: 2,
  29.                 root_password: Crypto.createHash('md5').update( 'str - ' + _.random(0, 20) ).digest('hex')
  30.             }, { // 3
  31.                 created_at: knex.fn.now(),
  32.                 server_hostname: 'lpnag01.server.ad',
  33.                 monitoring: 1,
  34.                 operating_system_id: 3,
  35.                 root_password: Crypto.createHash('md5').update( 'str - ' + _.random(0, 20) ).digest('hex')
  36.             }, { // 4
  37.                 created_at: knex.fn.now(),
  38.                 server_hostname: 'lpnag02.server.ad',
  39.                 monitoring: 1,
  40.                 operating_system_id: 3,
  41.                 root_password: Crypto.createHash('md5').update( 'str - ' + _.random(0, 20) ).digest('hex')
  42.             }, { // 5
  43.                 created_at: knex.fn.now(),
  44.                 server_hostname: 'lqchef01.server.ad',
  45.                 monitoring: 1,
  46.                 operating_system_id: 2,
  47.                 root_password: Crypto.createHash('md5').update( 'str - ' + _.random(0, 20) ).digest('hex')
  48.             }, { // 6
  49.                 created_at: knex.fn.now(),
  50.                 server_hostname: 'wpdir01.server.ad',
  51.                 monitoring: 1,
  52.                 operating_system_id: 4,
  53.                 root_password: Crypto.createHash('md5').update( 'str - ' + _.random(0, 20) ).digest('hex')
  54.             }, { // 7
  55.                 created_at: knex.fn.now(),
  56.                 server_hostname: 'wpdir02.server.ad',
  57.                 monitoring: 1,
  58.                 operating_system_id: 4,
  59.                 root_password: Crypto.createHash('md5').update( 'str - ' + _.random(0, 20) ).digest('hex')
  60.             }, { // 8
  61.                 created_at: knex.fn.now(),
  62.                 server_hostname: 'lptwst01.server.ad',
  63.                 monitoring: 1,
  64.                 operating_system_id: 1,
  65.                 root_password: Crypto.createHash('md5').update( 'str - ' + _.random(0, 20) ).digest('hex')
  66.             }, { // 9
  67.                 created_at: knex.fn.now(),
  68.                 server_hostname: 'lpngnx01.server.ad',
  69.                 monitoring: 1,
  70.                 operating_system_id: 1,
  71.                 root_password: Crypto.createHash('md5').update( 'str - ' + _.random(0, 20) ).digest('hex')
  72.             }, { // 10
  73.                 created_at: knex.fn.now(),
  74.                 server_hostname: 'wqbatch01.server.ad',
  75.                 monitoring: 0,
  76.                 operating_system_id: 1,
  77.                 root_password: Crypto.createHash('md5').update( 'str - ' + _.random(0, 20) ).digest('hex')
  78.             }, { // 11
  79.                 created_at: knex.fn.now(),
  80.                 server_hostname: 'lscacti01.server.ad',
  81.                 monitoring: 0,
  82.                 operating_system_id: 1,
  83.                 root_password: Crypto.createHash('md5').update( 'str - ' + _.random(0, 20) ).digest('hex')
  84.             }, { // 12
  85.                 created_at: knex.fn.now(),
  86.                 server_hostname: 'lqrhds01.server.ad',
  87.                 monitoring: 1,
  88.                 operating_system_id: 1,
  89.                 root_password: Crypto.createHash('md5').update( 'str - ' + _.random(0, 20) ).digest('hex')
  90.             }, { // 13
  91.                 created_at: knex.fn.now(),
  92.                 server_hostname: 'lqrhds02.server.ad',
  93.                 monitoring: 1,
  94.                 operating_system_id: 1,
  95.                 root_password: Crypto.createHash('md5').update( 'str - ' + _.random(0, 20) ).digest('hex')
  96.             }, { // 14
  97.                 created_at: knex.fn.now(),
  98.                 server_hostname: 'wsbamboo01.server.ad',
  99.                 monitoring: 1,
  100.                 operating_system_id: 1,
  101.                 root_password: Crypto.createHash('md5').update( 'str - ' + _.random(0, 20) ).digest('hex')
  102.             }
  103.         ]).into( 'servers' ),
  104.  
  105.         knex( 'applications' ).del(),
  106.         knex.insert( [
  107.             { created_at: knex.fn.now(), name: 'Apache',        version: '2'     }, // 1
  108.             { created_at: knex.fn.now(), name: 'Nagios',        version: '4'     }, // 2
  109.             { created_at: knex.fn.now(), name: 'Nginx',         version: null    }, // 3
  110.             { created_at: knex.fn.now(), name: 'PHP',           version: '5'     }, // 4
  111.             { created_at: knex.fn.now(), name: 'Jenkins',       version: '1.642' }, // 5
  112.             { created_at: knex.fn.now(), name: 'Chef Server',   version: null    }, // 6
  113.             { created_at: knex.fn.now(), name: 'Tumbleweed',    version: 1       }, // 7
  114.             { created_at: knex.fn.now(), name: 'AD',            version: null    }, // 8
  115.             { created_at: knex.fn.now(), name: 'Chef Client',   version: null    }, // 9
  116.             { created_at: knex.fn.now(), name: 'Batch Server',  version: null    }, // 10
  117.             { created_at: knex.fn.now(), name: 'LDAP',          version: null    }, // 11
  118.             { created_at: knex.fn.now(), name: 'Cacti',         version: null    }, // 12
  119.             { created_at: knex.fn.now(), name: 'Bamboo',        version: null    }  // 13
  120.         ]).into( 'applications' ),
  121.  
  122.         knex( 'applications_servers' ).del(),
  123.         knex.insert( [
  124.             // lpweb01: Apache, PHP, Chef Client
  125.             { created_at: knex.fn.now(), server_id: 1, application_id: 1   },
  126.             { created_at: knex.fn.now(), server_id: 1, application_id: 4   },
  127.             { created_at: knex.fn.now(), server_id: 1, application_id: 9   },
  128.             // lpngnx01: Nginx, PHP, Chef Client
  129.             { created_at: knex.fn.now(), server_id: 9, application_id: 3   },
  130.             { created_at: knex.fn.now(), server_id: 9, application_id: 4   },
  131.             { created_at: knex.fn.now(), server_id: 9, application_id: 9   },
  132.             // ldjen02: Jenkins, Chef Client
  133.             { created_at: knex.fn.now(), server_id: 2, application_id: 5   },
  134.             { created_at: knex.fn.now(), server_id: 2, application_id: 9   },
  135.             // lpnag01 & lpnag02: Nagios, Chef Client
  136.             { created_at: knex.fn.now(), server_id: 3, application_id: 2   },
  137.             { created_at: knex.fn.now(), server_id: 3, application_id: 9   },
  138.             { created_at: knex.fn.now(), server_id: 4, application_id: 2   },
  139.             { created_at: knex.fn.now(), server_id: 4, application_id: 9   },
  140.             // lqchef01: Chef Server
  141.             { created_at: knex.fn.now(), server_id: 5, application_id: 6   },
  142.             // wpdir01 & wpdir02: Active Directory
  143.             { created_at: knex.fn.now(), server_id: 6, application_id: 8   },
  144.             { created_at: knex.fn.now(), server_id: 7, application_id: 8   },
  145.             // lptwst01: Tumbleweed, Chef Client
  146.             { created_at: knex.fn.now(), server_id: 8, application_id: 7   },
  147.             { created_at: knex.fn.now(), server_id: 8, application_id: 9   },
  148.             // lscacti01: Cacti, Chef Client,
  149.             { created_at: knex.fn.now(), server_id: 11, application_id: 9  },
  150.             { created_at: knex.fn.now(), server_id: 11, application_id: 12 },
  151.             // wqbatch01: Batch Server
  152.             { created_at: knex.fn.now(), server_id: 10, application_id: 10 },
  153.             // lqrhds01 & lqrhds02: LDAP, Chef Client
  154.             { created_at: knex.fn.now(), server_id: 12, application_id: 11 },
  155.             { created_at: knex.fn.now(), server_id: 13, application_id: 8  },
  156.             { created_at: knex.fn.now(), server_id: 12, application_id: 11 },
  157.             { created_at: knex.fn.now(), server_id: 13, application_id: 8  },
  158.             // wsbamboo01: Bamboo
  159.             { created_at: knex.fn.now(), server_id: 14, application_id: 13 }
  160.         ]).into( 'applications_servers' )
  161.     );
  162. };
Advertisement
Add Comment
Please, Sign In to add comment