gabriel %!s(int64=7) %!d(string=hai) anos
pai
achega
8be71d2a84
Modificáronse 6 ficheiros con 29 adicións e 12 borrados
  1. 18 6
      tools/Dockerfile
  2. 0 0
      tools/cmd.php
  3. 0 0
      tools/composer.json
  4. 0 0
      tools/composer.lock
  5. 1 1
      tools/src/GetSource.php
  6. 10 5
      tools/src/Release.php

+ 18 - 6
tools/Dockerfile

@@ -5,7 +5,7 @@ EXPOSE 8000
 RUN apt-get update && apt-get install -yq wget apt-transport-https lsb-release ca-certificates software-properties-common gnupg2 curl iputils-ping
 RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
 RUN sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
-RUN apt-get update && apt-get install -yq python git vim tmux zip build-essential php7.1 iptables xz-utils
+RUN apt-get update && apt-get install -yq python python-pip git vim tmux zip build-essential php7.1 iptables xz-utils
 # mysql-client php7.1 php7.1-mysql php7.1-curl php7.1-xml php7.1-zip php7.1-bcmath php7.1-mbstring php7.1-dom php7.1-amqp php7.1-soap php7.1-snmp
 ## install composer
 RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
@@ -13,6 +13,12 @@ RUN php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60e
 RUN php composer-setup.php --install-dir=/usr/local/bin --filename=composer
 RUN php -r "unlink('composer-setup.php');"
 
+## install docker-composer
+#RUN curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
+#RUN chmod +x /usr/local/bin/docker-compose
+RUN pip install --upgrade pip
+RUN pip install docker-compose
+
 ## install ansible
 RUN echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" | tee /etc/apt/sources.list.d/ansible.list
 RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
@@ -30,11 +36,17 @@ COPY keys /opt/keys
 RUN chmod 0600 /opt/keys/*
 
 ## contains file to execute
-RUN mkdir /opt/installation
-RUN chmod -R 777 /opt/installation
-ADD . /opt/installation
-WORKDIR /opt/installation
+#RUN mkdir /opt/installation
+#RUN chmod -R 777 /opt/installation
+#ADD . /opt/installation
+#WORKDIR /opt/installation
+
+ARG DIR_INSTALL
+RUN mkdir -p $DIR_INSTALL
+RUN chmod -R 777 $DIR_INSTALL
+ADD . $DIR_INSTALL
+WORKDIR $DIR_INSTALL
 
 ENV DOCKER_HOST unix:///tmp/docker.sock
 
-ENTRYPOINT ["/opt/installation/execute.sh"]
+ENTRYPOINT ["./execute.sh"]

+ 0 - 0
tools/cmd.php


+ 0 - 0
tools/composer.json


+ 0 - 0
tools/composer.lock


+ 1 - 1
tools/src/GetSource.php

@@ -19,7 +19,7 @@ class GetSource extends Command
             ->setName('get:source')
             ->setDescription('Get the source using a ini file.')
             ->setHelp('This command allows you to fetch code based on the git.ini file configuration...')
-            ->addArgument('ini_file', InputArgument::REQUIRED, 'The ini file from where to get the source code config.')
+            ->addArgument('ini_file', InputArgument::REQUIRED, 'The ini file from where to get the source code config   .')
             ->addOption('source-name', null, InputOption::VALUE_REQUIRED, 'Rename the source to this name.', "upstream");
     }
 

+ 10 - 5
tools/src/Release.php

@@ -2,6 +2,7 @@
 
 namespace FD3;
 
+use function GuzzleHttp\default_user_agent;
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputArgument;
@@ -198,7 +199,7 @@ class Release extends Command
             }
             if (file_exists($dir . "/" . $this->_running_log)) {
                 $helper = $this->getHelper('question');
-                $question = new ConfirmationQuestion('The ' . $this->_running_log . ' file exist. Read file or take parameters? (Y/n)', true);
+                $question = new ConfirmationQuestion('The ' . realpath($dir) . "/" . $this->_running_log . ' file exist. Read file or take parameters? (Y/n)', true);
                 if ($helper->ask($input, $output, $question)) {
                     $this->setParametersFormFile($input);
                 }
@@ -208,14 +209,14 @@ class Release extends Command
 
             $this->_ansible_vars["DOMAIN"] = $this->_domain;
 
-            $dObj = new DevOps\FileSystem($dir);
+            $dObj = new DevOps\FileSystem(realpath($dir));
             $dObj->dirExists()->realpath();
             $this->_dObj = $dObj;
 
             // agrego las opciones del input a la configuracion _modues
             $this->addConfigOptions($input);
             // creo el archivo de log de como se ejecuto
-            $this->createFileRunning($input);
+            $this->createFileRunning($input, $output);
             // cargo las fuentes a clonar
             $this->createGitClone();
             // creo el archivo docker-compose.yml
@@ -243,6 +244,8 @@ class Release extends Command
                 "[defaults]\n" .
                 "inventory=inventory.ini\n"
             );
+            // copio el playbook
+            copy(getcwd() . "/playbook.yml", $dObj->dirExists()->realpath()->getPath() . "/playbook.yml");
         } catch (\Throwable $error) {
             var_dump($error->getTraceAsString(), $error->getCode(), $error->getMessage());
         } finally {
@@ -690,13 +693,15 @@ class Release extends Command
     /**
      * Crea un archivo conlos parametros con los que se corrio el script.
      * @param InputInterface $input Contiene el input
+     * @param OutputInterface $output Contiene el output
      */
-    private function createFileRunning(InputInterface $input)
+    private function createFileRunning(InputInterface $input, OutputInterface $output)
     {
         $file = array();
         $file ["Running"] = array("date" => gmdate('Y-m-d h:i:s'));
         $file ["Arguments"] = $input->getArguments();
         $file ["Options"] = $input->getOptions();
+        $output->writeln("Writing " . $this->_dObj->getPath() . "/" . $this->_running_log);
         $this->_dObj->file($this->_running_log)->writeIniConfig($file);
     }
 
@@ -857,6 +862,6 @@ class Release extends Command
             $all .= $this->_domain . "_" . $key . "_1\n";
         }
 
-        $this->_dObj->file("inventory111.ini")->content($tmp . $all);
+        $this->_dObj->file("inventory.ini")->content($tmp . $all);
     }
 }