Skip to content

JSONish Configuration

aminjam edited this page Nov 15, 2014 · 6 revisions

#JSONish Configuration

The following code block will list all of the possible options in the hipops configuration. Required properties will have REQ prefix in the value.

{
  //REQ unique identifier of stack
  "id": "blogs",

  //OPTIONAL
  "description": "",

  //REQ unique environment e.g. prod,dev,stage
  "env": "stage",

  //REQ base path for data persistency
  "dest": " /data",

  "oses": [{
    //REQ SSH user e.g. ubuntu,core
    "user": "ubuntu"

    //OPTIONAL
    "pythonInterpreter": "PATH=/home/core/bin:$PATH python"
  },

  "apps": [{
    //REQ unique name for app
    "name": "backend-api",

    //OPTIONAL type of app, used for scoping. If set to "generic" it will a host-level app without the naming convention DEFAULTS_TO=generic
    "type": "nodejs",

    //OPTIONAL
    "repository":{
      //OPTIONAL e.g. development, master DEFAULTS_TO=master
      "branch": "development",

      //REQ repository SSH url
      "sshUrl": "github.com/aminjam/hipops-SAMOMY-mysql.git",

      //OPTIONAL path to git SSH key
      "sshKey": "/Users/myUser/.ssh/id_rsa",

      //OPTIONAL only selected folder from the repo to be sent to container
      "folder": "dist/"
    },

    //OPTIONAL metadata used when using containers
    "cred": {
      "dbName": "sailsjs_demo_app",
      "username": "admin",
      "password": "P@ssw0rd"
    },

    //OPTIONAL files to copy to container
    "customizations": [{
      //REQ source 1.Relative Path 2.Absolute Path 3.http:// endpoint
      "src": "../../app-run.sh",

      //REQ destination 1.Absolute Path 2.If Only the filename, the default convention is used, and accessible by {{.App.Dest}} in playbook section
      "dest": "run.sh",

      //OPTIONAL default linux file mode DEFAULTS_TO:400
      "mode": 744
    }],

    //REQ docker image for app
    "image": "aminjam/nodejs",

    //OPTIONAL array of port numbers that will be exposed and used
    "ports": [3001]
  }],

  "playbooks": [{
    //REQ inventory of target machines
    "inventory": "tag_NAME_BLOGS-EC2",

    //OPTIONAL name of the playbook to run DEFUALTS_TO:hipops.yml
    "play":"myplay.yml"

    //REQ docker containers to take
    "containers": [{
      //REQ docker run <params>
      "params": "--name backends -d progrium/ambassadord "
    }, {
      "params": "--name setup_ip --rm --privileged --net container:backends progrium/ambassadord --setup-iptables"
    }]
  }, {
    "inventory": "tag_NAME_BLOGS-EC2",
    //OPTIONAL should be either `running` or `deploying`. DEFAULTS_TO=running.
    "state": "OPTIONAL (DEFAULTS_TO=running) if set to `deploying` the container is redeployed every time the hipops is executed",

    //OPTIONAL array of apps to run e.g. [{{index .Apps 0}}]
    "apps": [{{index .Apps 0}},{{index .Apps 1}}"],

    "containers": [{
      //REQ you can map all of `App` properties here
      "params": "-v {{.App.Dest}}:/home/app -p 3008:{{index .App.Ports 0}} -e SERVICE_NAME={{.App.Name}} -e BACKEND_{{index .App.Ports 0}}={{.App.Name}}.service.consul --link backends:backends -d {{.App.Image}} /run.sh"
    }]
  }]
}

###Notes

  • containers.params: You can chain a series of docker containers for groups of apps here. Let's say there were 2 apps in the array and 3 containers. hipops will run 3 containers for each of those apps in the array, for a total of 6 containers. Note that {{ box_* }} is reserved for all host configurations, like {{ box_hostname }} or {{ box_eth1.ipv4.address }}, so for a full list of possible values checkout ansible docs. Any other {{.App.*}} will get evaluated like a golang template for the app in scope, so for example {{.App.Name}} will refer to the name of the App from above in the format of ID-ENV-NAME. {{.App.Dest}} is a unique property that is available to you for data persistency of the containers.

You can find more examples here.

Clone this wiki locally