ImpulseSync™ User Manual
HomePricingContact Us
  • Introduction
    • What is Impulse?
  • Crash Course of ImpulseSync
    • Overview Of ImpulseSync
    • Step 1: Endpoints
      • Endpoint Configuration
    • Step 2: Jobs
      • Job Configuration
      • Step 2a: Content manipulators
      • Step 2b: Content mapper
    • Step 3: Syncing
  • Getting Started
    • Core Concepts
    • Creating Endpoints
    • Creating Jobs
    • Starting a Transaction
    • Transaction Reports
    • Automating Jobs with Pipelines
    • Scripting Post Sync
    • Scheduling Jobs and Pipelines
    • Dashboard
    • Managing Jobs/Pipelines
    • Content Mapper
      • Aligning Mismatched Content
      • Connector Matrix
      • Locked Fields
      • Content Aligner
      • Aligning Content Challenges
  • Reports
    • Reports Screen
    • Debug Report
    • Messages
  • Connectors
    • Common Job Options
    • All Connectors List
    • Source Connectors
      • Contentful
      • Contentstack
      • dotCMS
      • Drupal v7
      • Drupal v9
      • GitHub
      • GraphQL
      • MS Teams
      • SCP
      • Snapshot
      • Strapi v3
      • Strapi v4
    • Destination Connectors
      • Contentful
      • Contentstack
      • dotCMS
      • SCP
      • Strapi v3
      • Strapi v4
  • Content Manipulators
    • Common Manipulator Options
    • Add Replace Field
    • AI(Artificial intelligence)
    • Change ID Manipulator
    • CSV Store Manipulator
    • Dynamic Job Store Manipulator
    • File to Text
    • Folder Manipulator
    • Get and Set Field
    • Language
    • Liquid Field
      • Liquid On the Quick
      • Basics
        • Impulse Values
        • Impulse Variables
        • Operators
        • Truthy and falsy
        • Types
        • Whitespace control
      • Tags
        • Control flow
        • Impulse Content Objects
        • Iteration
        • Utility
        • Variable
      • Filters
        • abs
        • append
        • capitalize
        • ceil
        • compact
        • concat
        • date
        • date_str
        • default
        • divided_by
        • downcase
        • escape
        • escape_once
        • first
        • floor
        • getStoredValue
        • htmlQuery
        • htmlReplace
        • idMap
        • join
        • jq
        • json
        • last
        • lstrip
        • map
        • minus
        • modulo
        • newline_to_br
        • plus
        • prepend
        • remove
        • remove_first
        • replace
        • replace_first
        • reverse
        • round
        • rstrip
        • section
        • sections
        • size
        • slice
        • sort
        • sort_natural
        • split
        • str_to_date
        • strip
        • strip_html
        • strip_newlines
        • times
        • truncate
        • truncatewords
        • type
        • uniq
        • upcase
        • utl_decode
        • url_encode
      • Liquid Playground
    • Markdown
    • Regex
    • Relationship
    • Store Field
    • Tidy
  • Time Machine
    • Snapshot
    • Viewing Snapshots
    • Delivery from Snapshots
  • Cookbook Recipes
    • Adding Fields
    • Aligning Content between Endpoints
    • Avoid overriding Fields
    • Avoid syncing Content Types
    • Combing Fields
    • Default Field Value
    • File (.doc) to Structured Content
    • File (.docx) to Structured Content - Expanded
    • HTML to Structured Content
    • Language (Locale) mismatch between endpoints
    • Paths/IDs Changed
    • Reference to Value
    • Single Content Type to Multiple
    • Splitting Content with Reference
    • Syncing Content with Languages
    • Text Select to Boolean
    • Text to Reference
    • Text to Reference - liquid
    • Two Sources to One Destination
    • Changing a folder path
    • Combining data between content types
    • Converting HTML Sections
    • JSON object to reference
    • Use CSV to convert values
    • Storing fields with Store field motator
  • Troubleshooting
    • What to do if I run into a Job Problem
    • Troubleshooting via UI
    • Submitting a ticket
  • Using Impulse Headlessly
    • Getting Started with cURL
      • Creating Endpoints
      • Creating Jobs
      • Starting a Transaction
      • Transaction Reports
      • Automating Jobs with Pipelines
      • Scheduling Jobs and Pipelines
      • Aligning Mismatched Content
      • Scripting Post Sync
  • Organization Tier Restrictions
  • Content Storage Options
Powered by GitBook
On this page
  • Impulse API Authentication
  • What if I want to perform scripted actions after content syncs?
  • How to perform SSH commands at the end of a sync
  • Create/Update Config API
  • SSH Command
  • Add SSH Command
  • Run a Sync
  1. Getting Started

Scripting Post Sync

Impulse API Authentication

Before you can call many of the Impulse API endpoints, you will need to have a user. Once you have a user you can use basic auth to access the endpoints.

What if I want to perform scripted actions after content syncs?

Some repositories require an additional command from a CLI to update the system with the new content or content type. You can add these commands to run at the end of a sync, before the transaction is finished but after the content has been synced.

How to perform SSH commands at the end of a sync

At this time, we do not have this functionality available in our UI. Instead you will need to use the REST endpoints to perform ssh commands. However, we do plan on add this functionality to the UI. Stay tuned.

Create/Update Config API

To create the configuration, you will need to use the "Hooks-ssh" API. Using cURL, you can make a request like the following:

curl --location -g --request PUT '{{impulse-protocol}}://{{impulse-domain}}:{{impulse-port}}/private/hooks-ssh/config/{{endpointId}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "url" : "192.168.68.120:22",
    "username" : "root",
    "privateKey" : "b3BlbnNzaC1rZXktdjEAAAAABG5vbm"
}'

Request Body

The request body with variables to send is as follows:

{
    "url" : "{{remote-url}",
    "username" : "{{ssh-user}}",
    "privateKey" : "{{private-key}}"
}

A quick description of each attribute follows:

  • url: remote host ip, it has to include the port, for example: 192.168.68.120:22

  • username: is the user that has privileges in the remote host.

  • privateKey: has to be encoded base64, and can't contain new lines. One way to generate it is like this: base64 -w 0 private-key-motiv.pem > encoded-private-key-motiv.pem (pass the content of encoded-private-key-motiv.pem make sure you are not copying any end of lines)

SSH Command

The sshPostHook flag is a global flag that can be set on all endpoints.

If used, it will send a request to the Hooks SSH service after the sync-manager receives the topic for all content has been synced.

This flag takes a single command to be run on the remote server. These commands will be run at the home (~) of the user set in the hooks-ssh config. i.e. If you use the user "ubuntu", then all command will be run from /home/ubunutu

It is set as follows: "sshPostHook:<command>"

Examples: "sshPostHook:touch posthook.file" or "sshPostHook:echo \"post hook text\" >> posthook.file && cat posthook.file"

Add SSH Command

Now that the config is created, you will need to define the command as part of the job.

To do this, get the job object via API.

{{impulse-protocol}}://{{impulse-domain}}:{{impulse-port}}/private/job-depot/jobs/{{job-id}}

The job object will look something like this:

{
  "id": "dd7f9cb7-52d3-434c-934e-64537ba0e2d2",
  "name": "my-job",
  "type": "manual",
  "description": "A job for end transaction ssh commands.",
  "active": true,
  "endpoints": [
    {
      "endpoint": {
        "id": "2e458822-9ba0-11ea-bb37-0242ac130002"
      },
      "type": "source",
      "detail": "contenttype:demo"
    },
    {
      "endpoint": {
        "id": "9538b3c8-d7c8-4602-80a7-20bb00599508"
      },
      "type": "destination",
      "detail": "contenttype:demo"
    }
  ]
}

You will need to add a new job.endpoints.detail for the endpoint you created the config for.

The detail key to add is sshPostHook followed by the ssh commands you want to run. For example, to create a file and view it's contents you can add the following detail separated by a comma. Only a single sshPostHook flag should be used on each endpoint.

sshPostHook:echo \"post hook text\" >> posthook.file && cat posthook.file

Updating the job we send this request:

curl --location -g --request PUT '{{impulse-protocol}}://{{impulse-domain}}:{{impulse-port}}/private/job-depot/jobs/{{job-id}}' \
--header 'Content-Type: application/json' \
--data-raw '{
  "name": "my-job",
  "type": "manual",
  "description": "A job for end transaction ssh commands.",
  "active": true,
  "endpoints": [
    {
      "endpoint": {
        "id": "2e458822-9ba0-11ea-bb37-0242ac130002"
      },
      "type": "source",
      "detail": "contenttype:demo"
    },
    {
      "endpoint": {
        "id": "9538b3c8-d7c8-4602-80a7-20bb00599508"
      },
      "type": "destination",
      "detail": "contenttype:demo,sshPostHook:echo \"post hook text\" >> posthook.file && cat posthook.file"
    }
  ]
}'

Run a Sync

After the config exists for the endpoint and the job has been updated with the new details, you can run a sync. After the job has moved the content to the destination, the script you set in the job details will then run. After the script is finished, the transaction will be complete.

PreviousAutomating Jobs with PipelinesNextScheduling Jobs and Pipelines

Last updated 2 years ago