Create an action using GitHub
13 min
for actions to be correctly received and imported in common actions, the user needs to follow the following structure the folder structure must contain the path where actions are stored each action must include three json files action configuration json, action definition jsonand action template json prerequisites the following prerequisites must be met before creating actions using github use only ansible playbook or ansible tower (at) to support actions host the playbook in a single github repository configure github provider access with a token set up access and job templates for at creating a custom action actions are divided into four component files action definition docid\ wvc8jzngudficxxshjpdm action configuration docid\ wvc8jzngudficxxshjpdm action template docid\ wvc8jzngudficxxshjpdm action catalog metadata docid\ wvc8jzngudficxxshjpdm creating an ansible playbook docid\ wvc8jzngudficxxshjpdm action definition, action template and action configuration files must have the same version make sure the version is updated in all three files only one version can be published however, multiple versions can be stored in draft state to publish with a different version, retire and delete the old version first action definition this file allows you to define the important properties for a custom action \<font color="#f3f4f6">property\</font> \<font color="#f3f4f6">type\</font> \<font color="#f3f4f6">description\</font> actionconfigparams boolean action configurations are needed or not for the particular action actiondefinitionid string action is identified using actiondefinitionid used for mapping between action definition and action template actiondefinitionversion object describes version of action using id and label as key properties actiondefinitiondisplaylabel string action label to be displayed on ui used as a mapping between action definition and action configuration actiontype string supported action types are provisionnew, viewonly, basic, configchange, global, statechange, deprovision, servicerequest, incident approvalsteprequired boolean is approval required or not associatedto object used to create association between action and particular resource type resourcefamilies property is used to specify resourcefamily (resource type) of resource to which action needs to be attached context object specifies context of the action costimpact boolean cost impact of the action description string action description mcmpapplication list list of applications in which action needs to be present eg \[ "mcmp\ common\ service", "mcmp\ aiops\ service" ] provider object content and target provider details using contentprovider and targetprovider as key properties fulfillmentroutingkey string fulfillment routing key status string status of the action systemconfigs string any system configurations required servicetype string service type of the action actiondefinitionretriablettl string time to live in minutes for action definition retry isretriable string is action retriable? possible values are "true" or "false" action configuration this file allows you to enable user pass inputs while performing any action \<font color="#f3f4f6">property\</font> \<font color="#f3f4f6">type\</font> \<font color="#f3f4f6">description\</font> configgroup list list of configuration groups currently only one configuration group is supported configgroupname string name to be displayed for configuration group on ui configgroupcode string unique identification code for configuration group used as a mapping between action configuration and action definition configgroupsequence number sequence of configuration group starts with 0 visibilityrules list visibility rules if any configs list list of the configurations under a particular configuration group configid string unique identifier for the configuration should match with binding hidden boolean the configuration can be hidden or not isrequired boolean the configuration can require input or not editable boolean this input can be editable or not configname string config/input name to be displayed on ui binding string unique identifier for binding the input used to get value of input in action template should match with configid description string description of input field shown in ⓘ icon inputtype string type of the input field eg freetext, selectone sequence number sequence of config/input starts with 0 values list the values/options to select in the dropdown should be used only in case of inputtype selectone key properties are valueid, value, label default object default value for the input key properties are valueid, value, label validation string regex based validation for input fields errormessage string error message to be displayed if validation fails derives list configurations which can be derived from current configuration/input action template this file allows you to specify the playbook and playbook inputs \<font color="#f3f4f6">property\</font> \<font color="#f3f4f6">type\</font> \<font color="#f3f4f6">description\</font> actiondefinitionid string action is identified using actiondefinitionid used for mapping between action definition and action template refid string reference id of action template provider object content and target provider details using contentprovider and targetprovider as key properties description string base64 encoded template is stored in description the base64 encoded template has following properties \<font color="#f3f4f6">property\</font> \<font color="#f3f4f6">type\</font> \<font color="#f3f4f6">description\</font> actiontemplate object type of template the fix value is actiontemplate ansiblerunner object template is run using ansible runner this is a fixed value playbookname string relative path to the playbook file playbookpath string url to the repository foldername string relative path to the playbook folder branchname string optional parameter github branch from which playbook is to be fetched default branch is master variables list list of input parameters to the playbook in form of object with key, value pair eg \[{ "name" "req action", "value" "update" },{ "vnet name" "req action", "value" "$ resourcename" }] action catalog metadata the metadata of action definition, action configuration and action template are stored in the action catalog metadata file \<font color="#f3f4f6">property\</font> \<font color="#f3f4f6">type\</font> \<font color="#f3f4f6">description\</font> provider object content and target provider details using contentprovider and targetprovider as key properties sourcepath string path of source actions folder providerofferingtypes list list of provider offering types serviceofferings list list of catalogs if any operations list list of operations if any actions list list of actions in form of object containing action definition, action configuration and action template with jet properties as definition, configurationfile and templatefile respectively creating an ansible playbook this playbook is run based on the req action the required ansible module, along with its input properties, is used inside a block inputs to the ansible playbook are passed from the action template \<font color="#f3f4f6">name\</font> \<font color="#f3f4f6">type\</font> \<font color="#f3f4f6">description\</font> name string name of the playbook hosts string type of device where you are working on connection string type of host connection proxy env string production environment for http or https protocol set fact string actual action that will be included in the playbook subscription id string unique id for the azure subscription tenant string instance secret string combination of up 40 characters client id string application id resource group string the group where the resource belongs to virtual network name string name of the virtual network service endpoints string entity that can be referenced environment string environment in provider ignore errors string request to ignore errors if any changes are done in playbook, make sure to manage the version the version should be increased on the metadata file and the integration template afterwards finally, make sure to update the actions definitions and actions configurations file \[ { "id" "pb aws state operations on off restart", < unique id can be "pb \<provider> \<folder name> \<file name>" used inside integration template "version" "1 0 0", < version should be used inside integration template "name" "on off restart yml", < playbook file name "type" "playbook", "start" true, < true for main playbook "requires" \[] < define other dependent playbook for them start can be false } ] after the playbook is created and successfully tested, you need to create the action definition for custom action after the action files are properly updated, store them in a zip file format and follow the steps described in onboarding by discovery docid\ bq6zawfin7nfsu 1mbzue