Browse Source

Agregado del usuario interno

Agregado del usuario interno a los workers

Agregado del usuario interno al archivo running.env
Your Name 7 years ago
parent
commit
2f3613760a
3 changed files with 52 additions and 25 deletions
  1. 1 6
      tools/mysql_scripts.sql
  2. 25 19
      tools/playbook.yml
  3. 26 0
      tools/src/Release.php

+ 1 - 6
tools/mysql_scripts.sql

@@ -6,9 +6,4 @@ CREATE TABLE IF NOT EXISTS `fd_session`.`sessions` (
   `sess_time` int(10) unsigned NOT NULL,
   `sess_lifetime` mediumint(9) NOT NULL,
   PRIMARY KEY (`sess_id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
-
-INSERT INTO `fd3_base`.`tenancy`
-(`id`, `name`, `enabled`) VALUES
-(1,    'Base', 1),
-(2,    'Inicial', 1);
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

+ 25 - 19
tools/playbook.yml

@@ -38,17 +38,6 @@
         login_password: "{{ lookup('env', 'MYSQL_PASSWORD') }}"
         state: present
 
-    - copy:
-        src: "{{ playbook_dir }}/mysql_scripts.sql"
-        dest: /tmp/mysql_scripts.sql
-
-    - name: Run SQL commands against DB to create table
-      mysql_db:
-        login_password: "{{ lookup('env', 'MYSQL_PASSWORD') }}"
-        state: import
-        name: fd_session
-        target: "/tmp/mysql_scripts.sql"
-
     - name: Create database base
       mysql_db:
         name: fd3_base
@@ -99,6 +88,18 @@
         priv: '*.*:ALL'
         state: present
 
+    - name: Copy file mysql_scripts.sql
+      copy:
+        src: "{{ playbook_dir }}/mysql_scripts.sql"
+        dest: /tmp/mysql_scripts.sql
+
+    - name: Run SQL commands against DB to create table
+      mysql_db:
+        login_password: "{{ lookup('env', 'MYSQL_PASSWORD') }}"
+        state: import
+        name: fd_session
+        target: "/tmp/mysql_scripts.sql"
+
 - name: Launch docker for module base. Tag=start_base
   hosts: 127.0.0.1
   connection: local
@@ -134,15 +135,20 @@
       args:
         executable: /bin/bash
 
-    - name: Create user iksop
-      shell: "bin/console user:create iksop soporte@interlink.com.ar gran5pe --super-admin 1"
-      args:
-        executable: /bin/bash
+    - name: Copy file user_system.json
+      copy:
+        src: "{{ playbook_dir }}/user_system.json"
+        dest: /tmp/user_system.json
 
-    - name: Create user admin
-      shell: "bin/console user:create admin admi@interlink.com.ar admin 2"
+    - name: Update variable usersetting
+      set_fact:
+        usersetting: "{{ lookup('file','/tmp/user_system.json')|from_json }}"
+
+    - name: Create user iksop
+      shell: "bin/console user:create {{ item.user }} {{ item.email }} {{ item.password }} {{ item.tenancy }} {{ item.extra }}"
       args:
         executable: /bin/bash
+      with_items: "{{ usersetting.users }}"
 
     - name: Promote users to ADMIN
       shell: " bin/console fos:user:promote admin ROLE_ADMIN"
@@ -151,8 +157,8 @@
 
     - name: Copy file oauth.data.log to host
       fetch:
-          src: /opt/base/oauth.data.log
-          dest: /tmp/
+        src: /opt/base/oauth.data.log
+        dest: /tmp/
 
 - name: Configure oauth data for other container. Tag=configure_oauth
   hosts: 127.0.0.1

+ 26 - 0
tools/src/Release.php

@@ -61,6 +61,10 @@ class Release extends Command
      * @var array Contiene la configuracion de los modulos.
      */
     private $_modules;
+    /**
+     * @var array Contiene los usuarios que van a poder acceder al sistema.
+     */
+    private $_user_system;
 
     /**
      * Constructor.
@@ -77,6 +81,12 @@ class Release extends Command
         $this->_mysql_pass = "235r2342gtfsw";
         $this->_mysql_root_pass = "235r2342gtfsw";
         $this->_docker_restart_default = "on-failure:10";
+        $this->_user_system = ['users' =>
+            [
+                ['user' => 'admin', 'password' => 'admin', 'tenancy' => 1, 'email' => 'soporte@interlink.com.ar', 'extra' => '--super-admin '],
+                ['user' => 'iksop', 'password' => 'gran5pe', 'tenancy' => 2, 'email' => 'admin@interlink.com.ar', 'extra' => ''],
+                ['user' => 'interno', 'password' => 'gran5pe1nterno', 'tenancy' => 2, 'email' => 'admin@interlink.com.ar', 'extra' => '']
+            ]];
         $this->_modules = array();
         $this->_ansible_vars = array();
         $this->_modules_all = array(
@@ -242,6 +252,8 @@ class Release extends Command
 
             $this->_ansible_vars["DOMAIN"] = $this->_domain;
             $this->_ansible_vars["CLIENT"] = $this->_client;
+            $this->_ansible_vars["CMD_USERNAME"] = $this->_user_system['users']['user'];
+            $this->_ansible_vars["CMD_PASSWORD"] = $this->_user_system['users']['password'];
 
             $dObj = new DevOps\FileSystem(realpath($dir));
             $dObj->dirExists()->realpath();
@@ -263,6 +275,8 @@ class Release extends Command
             $this->writeOAUTH();
             // escribo un archivo con variables para ansible
             $this->writeEnvVariables();
+            // escribo un archivo con los usuarios del sistema
+            $this->writeUserSystem();
 
             $dObj->file('install.yml')->content(
                 yaml::dump(array(
@@ -748,6 +762,7 @@ class Release extends Command
             ->addLinks("base")
             ->addLinks("amqp")
             ->addLinks("nginx", $this->getDomain("base"))
+            ->addEnv_file("running.env")
             ->addVolumes("./base/", "/opt/base");
 
         $composer
@@ -760,6 +775,7 @@ class Release extends Command
             ->addLinks("base")
             ->addLinks("amqp")
             ->addLinks("nginx", $this->getDomain("base"))
+            ->addEnv_file("running.env")
             ->addVolumes("./ftth/", "/opt/ftth");
 
         $composer
@@ -772,6 +788,7 @@ class Release extends Command
             ->addLinks("base")
             ->addLinks("amqp")
             ->addLinks("nginx", $this->getDomain("base"))
+            ->addEnv_file("running.env")
             ->addVolumes("./ftth/", "/opt/ftth");
 
         $composer
@@ -1048,6 +1065,15 @@ class Release extends Command
             ->content($tmp);
     }
 
+    /**
+     * Crea el archivo con los usuarios del sistema para que lea el ansible.
+     */
+    private function writeUserSystem()
+    {
+        $this->_dObj->file("user_system.json")
+            ->content(json_encode($this->_user_system));
+    }
+
     /**
      * Crea el archivo con las variables para ejecutar el ansible.
      */