Differences
This shows you the differences between two versions of the page.
infra [2014/12/09 10:08] rogerio |
infra [2017/07/21 03:08] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{template>: | ||
- | | name = INFRA-Provision | ||
- | | version = 0.1.0 | ||
- | | accountable = Rogério Schneider | ||
- | | depdency = ContextNet, OpenSplice, RTI, Linux | ||
- | }} | ||
- | |||
- | ===== Automated Infrastructure ===== | ||
- | |||
- | ==== INFRA-Provision ==== | ||
- | |||
- | * Installs and validate basic infrastructure configuration for LAC servers | ||
- | |||
- | * Automates build process for LAC software | ||
- | |||
- | Works great with Vagrant/ | ||
- | |||
- | ==== Fundamentals ==== | ||
- | |||
- | We are using a set of tools to setup, build and deploy ContextNet services to | ||
- | newly installed machines, with what we call " | ||
- | configuration, | ||
- | |||
- | To accomplish this automated deploy process, we define some premises, as | ||
- | follows: | ||
- | |||
- | 1. User must setup his own machine with some basic toolset. This process is also automated and should be done using RVM (The Ruby Version Manager) and it's Gemfiles, used to define the versions of helper tools. | ||
- | |||
- | 2. Capistrano is the main helper tool, used as a control center to run local and remote commands, such as setup, build and deploy. | ||
- | 3. You must have Java, Ant and Maven installed, and your JAVA_HOME variable should be correctly set. | ||
- | |||
- | 3.1. Java is used to compile the source code for ContextNet. | ||
- | 3.2. Ant is used to build the jars (build.xml is it's recipe file). | ||
- | 3.3. Maven is used to locally install the generated jars (not mandatory). | ||
- | 3.4. If you use Maven in other projects, you can refer to the built ContextNet jars in your pom.xml and your local Maven repository (~/ | ||
- | |||
- | 4. Vagrant is another helper tool and is used to provision local VMs within VirtualBox, automatically configuring the network and shared folders to conventioned, | ||
- | |||
- | ==== Main steps ==== | ||
- | |||
- | These are the main steps we take to deploy a new server. | ||
- | |||
- | 1. Install vanilla OS, Debian based. Tested with Ubuntu: | ||
- | 1.1. 14.04 64 bits | ||
- | 1.2. 12.04 32 bits | ||
- | |||
- | 2. Bootstrap the server with correct SSHd configuration and your SSH public key | ||
- | 3. Build needed ContextNet software | ||
- | 4. Setup/ | ||
- | 5. Deploy the built software to server | ||
- | 6. Restart services | ||
- | 6. Test deployed infrastructure | ||
- | |||
- | All steps are done using just a few commands: | ||
- | |||
- | cap < | ||
- | cap < | ||
- | |||
- | ==== How-to start ==== | ||
- | |||
- | * Use Ubuntu | ||
- | * If just running the build, you may use MacOS X (or even Cygwin for Windows - untested). | ||
- | * Prefer using Bash as you shell (should work on ZSH too but we had some trouble in an initial attempt). | ||
- | |||
- | * Install RVM (Ruby Version Manager) | ||
- | * http:// | ||
- | |||
- | * After RVM is installed, we need to load it and install the Ruby interpreter | ||
- | |||
- | rvm reload | ||
- | rvm install $(cat .ruby-version) | ||
- | cd .. # go to another dir | ||
- | cd - # when you come back (or every time you enter this project' | ||
- | rvm current | ||
- | gem list # you should see the default set of dependencies | ||
- | bundle | ||
- | gem list # now you should see all Ruby dependencies installed (defined in Gemfile and Gemfile.lock) | ||
- | |||
- | * SSH Keys | ||
- | |||
- | To facilitate the remote commands execution, you should insert your SSH public | ||
- | key in the file: `provision/ | ||
- | option as in `cap < | ||
- | password for every remote interaction. | ||
- | |||
- | * Now that we are set, just run some commands and get comfortable | ||
- | |||
- | cap help # this is the Capistrano help | ||
- | cap build # build the ContextNet jars | ||
- | cap < | ||
- | cap < | ||
- | cap < | ||
- | cap < | ||
- | |||
- | You should now have a control center for your servers, running directly from | ||
- | your local terminal. | ||
- | |||
- | ==== A word about SSH keys ==== | ||
- | |||
- | Please identify your key with your e-mail at the end. Follow the example of | ||
- | other keys already set in the project. | ||
- | |||
- | Mind that your key may be the same used to push to Git remotes, as the SSH | ||
- | keypair is personal (hence, should be reused in many machines as you feel like) | ||
- | and is not server bonded (thus, you should not generate new keypairs for each | ||
- | new machine you use or visit). As a general rule, you must only be careful with | ||
- | your private key, the public key may be distributed with no concerns. | ||
- | |||
- | ==== A word about Capistrano stages ==== | ||
- | |||
- | A stage is the definition of an environment, | ||
- | File `config/ | ||
- | |||
- | An example of stage is `lacobd`, defined in `config/ | ||
- | by two servers (lacobd.cloudapp.net and lacobd2.cloudapp.net) running most of | ||
- | the available roles (:base, :ospl, :rti, :sddl). | ||
- | |||
- | Generic stages are `localhost` and `vagrant`, pointing to local installations in | ||
- | such a way that can be reused locally by any user. If needed, you can create | ||
- | your own stages by adding a new file to the project. | ||
- | |||
- | ==== Using command line utility ==== | ||
- | |||
- | # Basic layout for Capistrano commands | ||
- | cap < | ||
- | |||
- | # Custom actions - cap -T | ||
- | cap bootstrap | ||
- | cap build # => Build all jars. | ||
- | cap build: | ||
- | cap build: | ||
- | cap build: | ||
- | cap build: | ||
- | cap clean # => Remove temporary local files. | ||
- | cap help # => Help. | ||
- | cap integration | ||
- | cap restart | ||
- | cap serverspec | ||
- | cap teardown | ||
- | |||
- | # Provision / Deploy - action deploy is the main task in Capistrano | ||
- | cap < | ||
- | cap < | ||
- | |||
- | # Restart | ||
- | cap < | ||
- | |||
- | # Tips | ||
- | - Use option "-s keys" to avoid password prompt and authenticate using SSH keys | ||
- | - Or export " | ||
- | |||
- | # Valid stages - located at config/ | ||
- | # The stage defines custom servers and configurations to be deployed | ||
- | - lacinfra | ||
- | - lacinfratest | ||
- | - lacobd | ||
- | - localhost | ||
- | - vagrant | ||
- | |||
- | # Examples | ||
- | cap build | ||
- | cap build force_ref=master | ||
- | cap lacinfratest bootstrap | ||
- | cap lacinfratest deploy | ||
- | cap lacinfratest deploy -s keys | ||
- | cap lacinfratest deploy -s keys force_ref=master | ||
- | cap lacinfratest restart | ||
- | cap lacinfratest restart -s keys | ||
- | cap lacinfratest serverspec | ||
- | cap lacinfratest serverspec -s keys | ||
- | cap lacinfratest integration | ||
- | cap lacinfratest integration -s keys | ||
- | cap lacinfratest integration -s keys integration_local_to_remote=true | ||
- | cap lacinfratest integration -s keys integration_local_to_remote=true force_ref=master | ||
- | cap lacinfratest teardown | ||
- | |||
- | ==== Adding a new repository to monitor, build and deploy ==== | ||
- | |||
- | When you need to add a new component to the build process, you need to modify as follows: | ||
- | |||
- | * Add the new repository to some of the existing jars (contextnet-clientlib, | ||
- | * File config/ | ||
- | |||
- | # all | ||
- | desc '=> Build contextnet-all-VERSION.jar.' | ||
- | task :all, :roles => nil, : | ||
- | |||
- | # Packages for this build. | ||
- | # ... | ||
- | repo current_mod, | ||
- | :git => ' | ||
- | repo current_mod, | ||
- | :git => ' | ||
- | repo current_mod, | ||
- | :git => ' | ||
- | repo current_mod, | ||
- | :git => ' | ||
- | |||
- | # Dependency packages for every build. | ||
- | # All jars must include this package list. | ||
- | repo current_mod, | ||
- | :git => ' | ||
- | repo current_mod, | ||
- | :git => ' | ||
- | repo current_mod, | ||
- | :git => ' | ||
- | repo current_mod, | ||
- | :git => ' | ||
- | repo current_mod, | ||
- | :git => ' | ||
- | |||
- | * Insert the new component into the build recipe. Depending on what you are adding, you may skip this step. | ||
- | * File build.xml | ||
- | |||
- | * Add the new repository to the contextnet-master-trigger job in Jenkins. | ||
- | |||
- | 1. First open the configuration of the main job trigger. | ||
- | |||
- | {{: | ||
- | |||
- | 2. Then go to the last repository in the list. | ||
- | |||
- | {{: | ||
- | |||
- | 3. And click "add repository" | ||
- | |||
- | {{: | ||
- | |||
- | 4. After you insert your new Git repository to be monitored, just save the configuration. | ||
- | |||
- | {{: | ||
- | |||
- | You may also want to sync the new configuration to the INFRA-Provision repository: | ||
- | |||
- | ci/ | ||
- | git add provision/ | ||
- | git commit -am ' | ||
- | git push | ||
- | |||
- | ===== Important links ===== | ||
- | |||
- | * [[https:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | * [[http:// | ||
- | |||
- | ===== Contact ===== | ||
- | |||
- | * [[user: | ||