{"componentChunkName":"component---src-templates-default-template-tsx","path":"/documentation/integration/Standard_ActionHandlers/AHconfig/","result":{"data":{"asciidoc":{"id":"610b442c-3856-5636-aa3a-e12847e3b024","html":"<div id=\"toc\" class=\"toc\">\n<div id=\"toctitle\">Table of Contents</div>\n<ul class=\"sectlevel1\">\n<li><a href=\"#_introduction\">Introduction</a></li>\n<li><a href=\"#_setting_up_docker\">Setting up docker</a>\n<ul class=\"sectlevel2\">\n<li><a href=\"#_linux_based_container_images\">Linux based container images</a></li>\n</ul>\n</li>\n<li><a href=\"#_defining_docker_composition_docker_compose_yml\">Defining docker composition (docker-compose.yml)</a>\n<ul class=\"sectlevel2\">\n<li><a href=\"#_creating_environment_variable_file_config_env\">Creating environment variable file (config.env)</a></li>\n<li><a href=\"#_mounting_rsa_private_key_for_ssh_only\">Mounting RSA private key (for SSH only)</a></li>\n<li><a href=\"#_action_handler_configuration_map_ah_config\">Action Handler configuration map (AH_CONFIG)</a></li>\n</ul>\n</li>\n<li><a href=\"#_starting_the_actionhandler_container\">Starting the ActionHandler container</a>\n<ul class=\"sectlevel2\">\n<li><a href=\"#_sample_kis_for_testing\">Sample KIs for testing</a></li>\n</ul>\n</li>\n</ul>\n</div>\n<div class=\"sect1\">\n<h2 id=\"_introduction\">Introduction</h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>ActionHandlers are integration components of the HIRO system. They are used to\ninvoke actions on target systems. The ActionHandler establishes a websocket\nconnection with the HIRO Action-API.\nAn ActionHandler can be deployed either on our SaaS platform or can be hosted on\na machine in your network. The latter has the advantage of not needing to open\ninbound ports on firewall. This document is for our customers who choose the latter.</p>\n</div>\n<div class=\"paragraph\">\n<p>The installation requires three steps:</p>\n</div>\n<div class=\"ulist\">\n<ul>\n<li>\n<p>Setting up docker</p>\n</li>\n<li>\n<p>Defining docker composition (docker-compose.yml)</p>\n</li>\n<li>\n<p>Starting the ActionHandler container</p>\n</li>\n</ul>\n</div>\n</div>\n</div>\n<div class=\"sect1\">\n<h2 id=\"_setting_up_docker\">Setting up docker</h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>The HIRO standard Action Handlers (SSH and HTTP) are provided using a docker image.\nThis image must be mounted in a maschine in your network running docker.\nFor general information on docker, please refer to the help pages on\n<a href=\"https://hub.docker.com/\">DockerHub</a>. We assume you&#8217;ve installed docker and docker-compose.\nYou can verify by checking the versions:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-bash\" data-lang=\"bash\">$ docker -v\nDocker version xx.xx.xx, build xxxxxxxxxx\n$ docker-compose -v\ndocker-compose version x.xx.x, build xxxxxxxx</code></pre>\n</div>\n</div>\n<div class=\"sect2\">\n<h3 id=\"_linux_based_container_images\">Linux based container images</h3>\n<div class=\"paragraph\">\n<p>All arago docker images are Linux based. The Docker image is published on our <a href=\"https://hub.docker.com/repository/docker/almatoai/hiro-actionhandler\">DockerHub repository</a>. Please ensure that your docker installation can run linux based images.\nYou can confirm by pulling the latest image and check for error messages.</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-bash\" data-lang=\"bash\">docker pull almatoai/hiro-actionhandler:latest</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>In case you are presented with an error message about Linux images not usable on your platform, please refer to the <a href=\"https://docs.docker.com/\">DockerHub help pages</a> and adjust your installation.</p>\n</div>\n</div>\n</div>\n</div>\n<div class=\"sect1\">\n<h2 id=\"_defining_docker_composition_docker_compose_yml\">Defining docker composition (docker-compose.yml)</h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>The docker composition defines which image and how the container is started. It is defined in a configuration file in YAML format and holds the information about for your docker image, the HIRO instance and the type of actions you seek to execute.</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Sample docker-compose.yml</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-yml\" data-lang=\"yml\">version: \"3.7\"\nservices:\n  actionhandler:\n    image: almatoai/hiro-actionhandler:latest # Please update version number to the most recent tagged version\n    container_name: actionhandler\n    env_file: ~/[path to your environment file]/config.env\n    restart: always\n    volumes: #required for SSH only\n      - type: bind\n        source: [absolute path]/[private key file]\n        target: /home/hiro/.ssh/id_rsa\n    environment:\n      USE_DEFAULT_AH_CONFIGS: ExecuteCommand,HTTPRequest\n      AH_CONFIG: &gt;\n        {}</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>The next sections walk you through the required adjustments: We will pass an environment variable file with HIRO credentials, mount the SSH private key and pass environment (when required) and define the Action Handler configuration map.</p>\n</div>\n<div class=\"sect2\">\n<h3 id=\"_creating_environment_variable_file_config_env\">Creating environment variable file (config.env)</h3>\n<div class=\"paragraph\">\n<p>You need to create an ActionHandler environment variable file for the docker image, typically named <code>config.env</code>. This file holds the credentials for your HIRO instance.</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Sample config.env</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-bash\" data-lang=\"bash\">HIRO_USER=XXXXXXX\nHIRO_PASS=XXXXXXX\nHIRO_EXTERNAL_USER=XXXXXXX\nHIRO_EXTERNAL_PASS=XXXXXXX</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>Each ActionHandler should have a dedicated service user account for the respective HaaS instance.\nIn case you do not have the credentials ready, please login to the arago account management application <a href=\"http://id.almato.ai/\">Almato ID</a>,\nnavigate to Member tab and search for users named 'actionhandler'.</p>\n</div>\n<div class=\"imageblock\">\n<div class=\"content\">\n<img src=\"/7.0/images/actionhandler/search_user.png\" alt=\"Search User\">\n</div>\n</div>\n<div class=\"paragraph\">\n<p>If a dedicated ActionHandler user does not exist for your haas-instance yet, please contact\nyour organization admin. Make a note of the username and password and enter them in the environment variable file for <code>HIRO_USER</code> and <code>HIRO_PASS</code>. You can change the password by clicking the\noptions icon and select <code>Edit Profile</code>. In case of questions, you can also contact the <a href=\"https://support.hiro.almato.ai/\">HIRO Support</a>.</p>\n</div>\n<div class=\"paragraph\">\n<p>The <code>HIRO_EXTERNAL_USER</code> and <code>HIRO_EXTERNAL_PASS</code> environment variables are optional if the \"supply_token\" functionality is required and the token passed to the actual handler should use a different user account than the ActionHandler itself.</p>\n</div>\n</div>\n<div class=\"sect2\">\n<h3 id=\"_mounting_rsa_private_key_for_ssh_only\">Mounting RSA private key (for SSH only)</h3>\n<div class=\"paragraph\">\n<p>If you want to invoke SSH commands using the ActionHandler, you need to mount an RSA private key into the container and exchange the public key with the target system.\nThe key needs to be in pkcs8 format and should not have a passphrase. You can generate a new key pair with the following command:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-bash\" data-lang=\"bash\">ssh-keygen -m pkcs8</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>Save the key pair to the server running docker and set the <code>source</code> attributes in the docker composition to the location of the private key- and cert-file. Make sure the files are readable for the ActionHandler (by default, the ActionHandler is run as user <code>hiro</code> with id <code>1000</code>).\nDo not forget to add the content of the generated public key into <code>~/.ssh/authorized_keys</code> on your the target system.</p>\n</div>\n<div class=\"paragraph\">\n<p>Please note: From a container perspective, even the local host is a remote target system, so you should be following the same steps. However, you might find some shortcuts in the <a href=\"https://docs.docker.com/engine/reference/run/#network-settings\">DockerHub help pages for network configuration</a>.</p>\n</div>\n</div>\n<div class=\"sect2\">\n<h3 id=\"_action_handler_configuration_map_ah_config\">Action Handler configuration map (AH_CONFIG)</h3>\n<div class=\"paragraph\">\n<p>Your connector needs a configuration of which actions or capabilities to\nprocess and how to execute them. This is configured in a configuration variable\ncalled <code>AH_CONFIG</code>.</p>\n</div>\n<div class=\"paragraph\">\n<p>Please refer to <a href=\"/7.0/documentation/integration/Standard_ActionHandlers/ah_capability_config/\">How to configure capabilities in the standard Action Handler (Docker image)</a>\nfor details on the configuration map.</p>\n</div>\n</div>\n</div>\n</div>\n<div class=\"sect1\">\n<h2 id=\"_starting_the_actionhandler_container\">Starting the ActionHandler container</h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>Once the composition is defined, you can start the ActionHandler docker container by issuing the following command:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-bash\" data-lang=\"bash\">docker-compose up</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>Please make sure you are issuing this command from the same directory your <code>docker-compose.yml</code> file is located in. Upon sucess, you should see the following log entries:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Sample log entris after successfull composition</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-bash\" data-lang=\"bash\">[...]\nCreating network \"docker_default\" with the default driver\nCreating actionhandler ... done\nAttaching to actionhandler\nactionhandler_1  | {\"time\":\"...\",\"severity\":\"info\",\"message\":\"Loaded configuration for capabilities: [\\\"HTTPRequest\\\"]\",\"metadata\":{}}\n[...]\nactionhandler    | {\"time\":\"...\",\"severity\":\"info\",\"message\":\"Authenticating...\",\"metadata\":{}}\nactionhandler    | {\"time\":\"...\",\"severity\":\"info\",\"message\":\"Successfully authenticated.\",\"metadata\":{}}\n[...]\nactionhandler    | {\"time\":\"...\",\"severity\":\"info\",\"message\":\"Connected to core.almato.ai using http\",\"metadata\":{}}\nactionhandler    | {\"time\":\"...\",\"severity\":\"info\",\"message\":\"Upgrading connection...\",\"metadata\":{}}\nactionhandler    | {\"time\":\"...\",\"severity\":\"info\",\"message\":\"WebSocket upgrade succeeded.\",\"metadata\":{}}\nactionhandler    | {\"time\":\"...\",\"severity\":\"info\",\"message\":\"[ActionHandler] New ActionWS status: :ready\",\"metadata\":{}}\n[...]</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>In case of generic docker problems, please refer to the <a href=\"https://docs.docker.com/\">DockerHub help pages</a>. On problems related to the ActionHandler docker image, please contact <a href=\"https://support.hiro.almato.ai/\">HIRO Support</a>.</p>\n</div>\n<div class=\"paragraph\">\n<p>The command above composes a docker container attached to your current console. In other words: If you close the console, the container will be terminated. To compose a detached container, please issue the following command:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-bash\" data-lang=\"bash\">docker-compose up --detach</code></pre>\n</div>\n</div>\n<div class=\"paragraph\">\n<p>More information on attached and detached containers and their lifespan can be found on the <a href=\"https://docs.docker.com/\">DockerHub help pages</a>.</p>\n</div>\n<div class=\"sect2\">\n<h3 id=\"_sample_kis_for_testing\">Sample KIs for testing</h3>\n<div class=\"paragraph\">\n<p>You can test your ActionHandler by executing the follow KIs from HIRO&#8482;:</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Sample KI for a HTTP request</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-bash\" data-lang=\"bash\">on\n  ogit/_id\nwhen\n  ProcessIssue == \"TestHTTPRequest\"\ndo\n  code: LOCAL::STATUS,\n  body: LOCAL::RESULT = action(\n\tcapability: \"HTTPRequest\",\n\tparams: \"format=json\",\n\turl: \"https://api64.ipify.org/\",\n\ttimeout: \"10\"\n  )\n  if LOCAL::STATUS == \"200\" then\n    log(\"SUCCESS: Your IP adress is ${LOCAL::RESULT}\")\n  else\n    log(\"ERROR ${LOCAL::STATUS}: ${LOCAL::RESULT}\")\n  end\n  delete(ProcessIssue)</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Expected HIRO Engine log</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-bash\" data-lang=\"bash\">action action executed: GET https://api64.ipify.org/?format=json\ninfo\naction arguments: {\"Arguments\":{\"params\":\"format=json\",\"timeout\":\"10\",\"url\":\"https://api64.ipify.org/\"},\"Capability\":\"HTTPRequest\"}, results: {\"body\":\"{\\\"ip\\\":\\\"52.30.30.78\\\"}\",\"code\":200,\"exec\":\"GET https://api64.ipify.org/?format=json \",\"headers\":\"{\\\"Connection\\\":\\\"keep-alive\\\",\\\"Content-Length\\\":\\\"20\\\",\\\"Content-Type\\\":\\\"application/json\\\",\\\"Date\\\":\\\"Mon, 04 Oct 2021 12:41:42 GMT\\\",\\\"Server\\\":\\\"nginx/1.19.7\\\",\\\"Vary\\\":\\\"Origin\\\"}\"}\ndebug\nlog SUCCESS: Your IP adress is xxx.xxx.xxx.xxx\ninfo</code></pre>\n</div>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">Sample KI for a SSH command</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-bash\" data-lang=\"bash\">on\n  ogit/_id\nwhen\n  ProcessIssue == \"TestSSH\"\ndo\n  stdout: LOCAL::OUTPUT,\n  stderr: LOCAL::ERROR,\n  exit: LOCAL::SYSTEMRC = action(\"ExecuteCommand\", command: \"echo Hello World\", host: \"{ip of your target system}\", user: \"{user for your target system}\", timeout: \"20\")\n  if LOCAL::SYSTEMRC == \"0\" then\n    log(\"SUCCESS: ${LOCAL::OUTPUT}\")\n  else\n    log(\"ERROR ${LOCAL::SYSTEMRC}: ${LOCAL::ERROR}\")\n  end\n  delete(ProcessIssue)</code></pre>\n</div>\n</div>\n</div>\n</div>\n</div>","document":{"main":"On-premise Action Handler Installation Guide","title":"On-premise Action Handler Installation Guide","subtitle":""},"fields":{"toc":true,"location":["documentation","integration","Standard_ActionHandlers","AHconfig"]}},"sidebarYaml":{"id":"6d066bdd-c982-5a69-b909-a31e6fc044e0","showIndex":null}},"pageContext":{"id":"610b442c-3856-5636-aa3a-e12847e3b024","parent":"documentation"}},"staticQueryHashes":["1010459453","1010459453","2356112386","2356112386","2603905930","2603905930","3026652197","3026652197","3167850324","3167850324","63159454","63159454"]}