Automated software deployment is the fundamental concept that Leroy was designed around achieving. In order to have a successful automated deployment, we must model the deployment into the following required steps: Deployment syntax and basic property checks in the deployment engine. Ensuring configurations are sane in that properties are defined in all environments that defined in any given one, or declared global and that all properties that are used are defined. Pre-deployment checks to check for common failures such as: Proper available disk space. Proper available memory Any paths defined, exist. Any URLS defined, respond. Any databases defined, can be authenticated against with configured credentials. Any integration points are properly responding. All required software or components that need to be pre-installed, are installed and at the right versions. Ensuring that the version of the deployment, artifacts and configurations have previously been deployed to a: Continuous deployment environment Development integration environment so developers can test integration points with their new code. QA environment so QA testing has occurred on a given build. Staging environment that matches the architecture of production to test that the build works in the same environment and can pass the same tests as QA Post deployment checks that test to ensure the application has been deployed. When building an automated software deployment workflow, we always must follow these rules: All steps must be repeatable and cause the same result. For example, if we need to remove a folder and all files in it, such a statement must be wrapped around a conditional so we can run it again and it has no effect since the work has been done. For example: The right way: if [ -d folder ]; then echo "[INFO] Found folder and deleting" rm -rf folder fi The wrong way: rm -rf folder All steps in a workflow must not have any environment specific logic that prevents it from working in all environments. A simple way to look at an automated software deployment is: (one)workflow + (one of many)environments = deployment Meaning, we should be able to run a deployment workflow on any environment. To enforce this idea, Leroy requires that all roles you define in an environment must be declared in all environments. Any service you start, must be tested to ensure it has started. Any service you stop must be tested to ensure it has stopped. If these tests fail, the deployment must fail. When possible, create a workflow that pre-stages the artifacts up to all hosts. This is just a speed optimization and an innate feature of Leroy that allows you to pre-stage artifacts to all desired hosts in the environment. It doesn't hurt to copy files and can continuously be done as builds are completed to any environment. Break your deployment into stacks of versioned components and deploy everything so you have control over your stack. For instance, if you have a JBoss application, do not manually setup jboss on your server then setup an automated deployment of your .war / .ear artifacts. Rather, deploy a version of jboss, your overlays, configurations and your .war in your workflow. This way controlling your version of jboss is much simpler. This stacking concept can be done for any combination of services, configurations and artifacts. With this, one can make a workflow that creates an entire environment of an application, or a workflow that simply updates an existing one, all using common workflows that call each other. Treat shell scripts or bat scripts like functions where the environment variables you set are inputs and the script operates on those inputs and always returns a 0 or non-zero value back to the shell. For example, when dealing with a windows service the following shell script does quite nicely. Inputs: SERVICE_NAME SERVICE_DIR SERVICE_FILE @echo on set INSTALLUTIL=%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil.exe SC QUERY "%SERVICE_NAME%" > NUL IF ERRORLEVEL 1060 ( "%INSTALLUTIL%" /i "%SERVICE_DIR%\%SERVICE_FILE%" ) ELSE ( sc delete "%SERVICE_NAME%" "%INSTALLUTIL%" /i "%SERVICE_DIR%\%SERVICE_FILE%" ) Combining this command with a Leroy post-process script of: The transacted install has completed This will require the installutil to produce the output of: The transacted install has completed In order to be success, otherwise, this is failure. Put it all together and you have a leroy workflow command with: Installing service: FUNSERVICE ${FUNSERVICE_NAME} ${FUNSERVICE_DIR} ${FUNSERVICE_FILE} For more info visit here: software deployment continuous integration Configuration Management
Related Articles -
software deployment, continuous integration,
|