8. Worker Steps¶
This section documents the Playbook syntax for all of the workers included with the Release Engine. What follows includes formal signatures of each step, as well as examples of each step in playbooks.
8.1. Juicer¶
8.1.1. juicer:Promote¶
Promote a release cart to a specified environment. It is recommended that this command is used in an execution sequence only a single dummy host listed in the hosts array. This will prevent the step from being ran multiple times.
Parameters
- dynamic (type: list)
- Required: True
- Items: The strings environment and cart
Example
1 2 3 4 5 6 | hosts: ['localhost']
steps:
- juicer:Promote:
dynamic:
- environment
- cart
|
Note
Recall that playbooks which have steps including dynamic parameters require the values for those parameters to be passed when starting the deployment.
8.2. BigIP¶
8.2.1. bigip:InRotation¶
Enable the current host in the BigIP.
Example
1 2 3 | hosts: ["example01.com", "example02.com"]
steps:
- bigip:InRotation
|
8.2.2. bigip:OutOfRotation¶
Disable the current host in the BigIP.
Example
1 2 3 | hosts: ["example01.com", "example02.com"]
steps:
- bigip:OutOfRotation
|
8.2.3. bigip:ConfigSync¶
Sync the BigIP configuration from a primary to a secondary.
Parameters
- envs (type: list)
- Required: True
- Items: Strings of environment names
Example
1 2 3 4 | hosts: ["example01.com", "example02.com"]
steps:
- bigip:ConfigSync:
envs: ["qa", "stage", "prod"]
|
8.3. Docker¶
8.3.1. docker:StopContainer¶
Stops a running container.
Parameters
- server_name (type str)
- Required: True
- Description: The name of the server to connect to.
- container_name (type str)
- Required: True
- Description: The container to stop.
Example
To stop the container mycontainer on 127.0.0.1:
1 2 3 4 5 | hosts: ['localhost']
steps:
- docker:StopContainer:
server_name: "127.0.0.1:2376"
container_name: "mycontainer"
|
8.3.2. docker:RemoveContainer¶
Removes a container.
Parameters
- server_name (type str)
- Required: True
- Description: The name of the server to connect to.
- container_name (type str)
- Required: True
- Description: The container to remove.
Example
To remove the container mycontainer on 127.0.0.1:
1 2 3 4 5 | hosts: ['localhost']
steps:
- docker:RemoveContainer:
server_name: "127.0.0.1:2376"
container_name: "mycontainer"
|
8.3.3. docker:PullImage¶
Note
Currently the docker worker only pulls images from a given insecure registry. In the future this will be changed to allow for secure or insecure.
Pulls an image down to a server.
Parameters
- server_name (type str)
- Required: True
- Description: The name of the server to connect to.
- image_name (type str)
- Required: True
- Description: The name of the image to pull.
- insecure_registry (type str)
- Required: True
- Description: The name the insecure registry to pull from.
Example
To pull the image myimage to 127.0.0.1 from http://registry.example.com:
1 2 3 4 5 6 | hosts: ['localhost']
steps:
- docker:RemoveContainer:
server_name: "127.0.0.1:2376"
image_name: "myimage"
insecure_registry: "http://registry.example.com"
|
8.3.4. docker:CreateContainer¶
Creates a container for use.
Parameters
- server_name (type str)
- Required: True
- Description: The name of the server to connect to.
- image_name (type str)
- Required: True
- Description: The name of the image to pull.
- container_name (type str)
- Required: True
- Description: The name to use for the new container.
- container_command (type str)
- Required: True
- Description: The command used when starting the new container.
- container_hostname (type str)
- Required: False
- Description: The hostname of the new container.
- container_ports (type list)
- Required: False
- Description: The port setup for the new container.
Example
To pull the image myimage to 127.0.0.1 from http://registry.example.org:
1 2 3 4 5 6 7 8 9 | hosts: ['localhost']
steps:
- docker:RemoveContainer:
server_name: "127.0.0.1:2376"
image_name: "myimage"
container_name: "mycontainer"
container_command: "/use/bin/supervisord"
container_hostname: "container.example.org"
container_ports: [1111, 2222]
|
8.3.5. docker:StartContainer¶
Starts a container.
Parameters
- server_name (type str)
- Required: True
- Description: The name of the server to connect to.
- container_name (type str)
- Required: True
- Description: The name to use for the new container.
- container_binds (type dict)
- Required: False
- Description: The file system binds.
- port_bindings (type dict)
- Required: False
- Description: The mapping of host and container ports.
Example
To start the container mycontainer on 127.0.0.1 binding 1111 to the hosts port of 8080 and binding the hosts /var/data/ to the image at /var/www/html/ as read-only:
1 2 3 4 5 6 7 8 9 10 | hosts: ['localhost']
steps:
- docker:RemoveContainer:
server_name: "127.0.0.1:2376"
container_name: "mycontainer"
container_binds:
"/var/data/":
"bind": "/var/www/html"
"ro": True
port_bindings: {1111: 8080}
|
8.4. FUNC¶
The FUNC worker has several commands (with their own subcommands) available. They are all documented on this page.
8.4.1. Command¶
The command module allows you to run arbitrary commands on a remote host. It has one sub-command available, Run.
8.4.1.1. command:Run¶
Parameters
- cmd (type: string)
- Required: True
- Description: The command to run, as it would be typed into a shell prompt
Example
1 2 3 4 | hosts: ['localhost']
steps:
- command:Run:
cmd: puppet agent --test --color=false
|
8.4.2. Fileops¶
The fileops module allows you to interact with the files on remote hosts. This is meant to be slightly more restricted than allowing puppet:Run.
8.4.2.1. fileops:ChangeOwnership¶
Parameters
- path (type: str or list)
- Required: True
- Default: None
- Description: Path(s) to target files and/or directories
- user (type: str)
- Required: True
- Default: None
- Description: The user who will own the file(s)/dir(s)
- group (type: str)
- Required: True
- Default: None
- Description: The group who will own the file(s)/dir(s)
- recursive (type: bool)
- Required: False
- Default: False
- Description: If the command should traverse through directories
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | hosts: ['localhost']
steps:
# Change ownership of one file
- fileops:ChangeOwnership:
path: /tmp/filename
user: root
group: root
# Change ownership of an entire directory
- fileops:ChangeOwnership:
path: /tmp/dir/
user: root
group: root
recursive: true
# Change ownership of an entire directory and a file
- fileops:ChangeOwnership:
path:
- /tmp/dir/
- /tmp/filename
user: root
group: root
recursive: true
|
8.4.2.2. fileops:ChangePermissions¶
Parameters
- path (type: str)
- Required: True
- Default: None
- Description: Path to a specific file or dir
- mode (type: str)
- Required: True
- Default: None
- Description: The new mode. Ex: “0644”. Note you must make it a string else it will modify it while parsing!
- recursive (type: bool)
- Required: False
- Default: False
- Description: If the command should traverse through directories
Example
1 2 3 4 5 6 7 8 9 10 11 12 | hosts: ['localhost']
steps:
# Change permissions on one file
- fileops:ChangePermissions:
path: /tmp/filename
mode: 0644
# Change permissions on an entire directory
- fileops:ChangePermissions:
path: /tmp/dir/
mode: 0644
recursive: true
|
8.4.2.3. fileops:FindInFiles¶
Parameters
- path (type: str or list)
- Required: True
- Default: None
- Description: Path(s) to target files and/or directories
- regexp (type: str)
- Required: True
- Default: None
- Description: Regular expression to search with
- case_insensitive (type: bool)
- Required: False
- Default: False
- Description: Makes the search case insensitive
- recursive (type: bool)
- Required: False
- Default: False
- Description: If the command should traverse through directories
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | hosts: ['localhost']
steps:
# Search a file for the string "test"
- fileops:FindInFiles:
path: /tmp/filename
regexp: test
# Search all files in a dir for the string "test"
- fileops:FindInFiles:
path: /tmp/dir/
regexp: test
recursive: true
# Search a file for the string "test" in any case
- fileops:FindInFiles:
path: /tmp/filename
regexp: test
case_insensitive: true
|
8.4.2.4. fileops:Move¶
Parameters
- path (type: str or list)
- Required: True
- Default: None
- Description: Path(s) to target files and/or directories
- to (type: str)
- Required: True
- Default: None
- Description: The location for the target path
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 | hosts: ['localhost']
steps:
# Rename a filename
- fileops:Move:
path: /tmp/filename
to: /tmp/newname
# Move files to a new directory
- fileops:Move:
path:
- /tmp/filename
- /tmp/newname
to: /tmp/dir/
|
8.4.2.5. fileops:Remove¶
Parameters
- path (type: str or list)
- Required: True
- Default: None
- Description: Path(s) to target files and/or directories
- recursive (type: bool)
- Required: False
- Default: False
- Description: If the command should traverse through directories
Example
1 2 3 4 5 6 7 8 9 10 | hosts: ['localhost']
steps:
# Remove a file
- fileops:Remove:
path: /tmp/filename
# Remove a directory
- fileops:Remove:
path: /tmp/dir/
recursive: true
|
8.4.2.6. fileops:Touch¶
Parameters
- path (type: str or list)
- Required: True
- Default: None
- Description: Path(s) to target files to create
Example
1 2 3 4 5 6 7 8 9 10 11 | hosts: ['localhost']
steps:
# Create a single, empty file
- fileops:Touch:
path: /tmp/filename
# Create multiple empty files
- fileops:Touch:
path:
- /tmp/filename
- /tmp/newname
|
8.4.2.7. fileops:Tar¶
Parameters
- path (type: str or list)
- Required: True
- Default: None
- Description: Path(s) to target files/dirs to include
- to (type: str)
- Required: True
- Default: None
- Description: The path of the new archive
- compression (type: str)
- Required: False
- Default: None
- Description: gzip or bzip
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | hosts: ['localhost']
steps:
# Create an archive of one file
- fileops:Tar:
path: /tmp/filename
to: /tmp/filename.tar
# Create a compressed tar of a directory
- fileops:Tar:
path: /tmp/dir/
to: /tmp/dir.tar.gz
compression: gzip
# Create a compressed tar of a directory and specific files
- fileops:Tar:
path:
- /tmp/dir/
- /tmp/filename
- /tmp/newfile
to: /tmp/dir.tar.gz
compression: bzip
|
8.4.3. Nagios¶
The nagios module allows you to perform common tasks in Nagios related to downtime and notifications.
8.4.3.1. nagios:ScheduleDowntime¶
Depending on the exact invocation, nagios:ScheduleDowntime will schedule downtime for:
- A host
- Services on a host
- A host and it’s services
Parameters
- nagios_url (type: string)
- Description: Hostname of the nagios server
- Required: True
- Default: None
- minutes (type: int)
- Description: Number of minutes to schedule downtime for
- Required: False
- Default: 30
- service (type: string or list)
- Description: Service, or services, to schedule downtime for
- Required: False
- Default: Set downtime for the host itself (services on the host will continue to alert like normal)
- Extras: Use the string ALL to schedule downtime for the host as well as all services on the host. Use the string HOST to explicitly set downtime for just a host. HOST and ALL are case-insensitive.
- service_host (type: string)
- Description: An alternative host to schedule downtime for
- Required: False
- Default: None
- Extras: See example below for service host
Example: Schedule Downtime for a host
In this example we set downtime for a host. Because minutes is not provided, the duration will be for the default of 30 minutes.
1 2 3 4 5 | hosts: ['localhost']
steps:
- nagios:ScheduleDowntime:
nagios_url: nagios.example.com
service: host
|
As stated in the parameter documentation above, we can give the string host in any mix of upper and lower case characters.
Example: Schedule Downtime for a service
In this example we set downtime for 15 minutes (line 5) for a specific service (megafrobber, line 6).
1 2 3 4 5 6 | hosts: ['localhost']
steps:
- nagios:ScheduleDowntime:
nagios_url: nagios.example.com
minutes: 15
service: megafrobber
|
Example: Schedule Downtime for several services
Similar to the previous example, here we are setting downtime for several services at once. Note the difference below in syntax on lines 6 → 8 compared to line 6 above. Here we provide the services as a list to the service parameter.
1 2 3 4 5 6 7 8 | hosts: ['localhost']
steps:
- nagios:ScheduleDowntime:
nagios_url: nagios.example.com
minutes: 15
service:
- megafrobber
- httpd
|
Example: Schedule Downtime for a host and all services on the host
In this example we will set an hour of downtime (60 minutes, line 5) for a host and all services running on that host (line 6).
1 2 3 4 5 6 | hosts: ['localhost']
steps:
- nagios:ScheduleDowntime:
nagios_url: nagios.example.com
minutes: 60
service: ALL
|
Example: Using service_host to set downtime for an alternative host
In some deployments, service hosts are created in nagios to monitor services not exactly tied to a specific host.
For example, you may be using a vendor load balancing solution, like F5 LTM BigIPs. In a situation like this you may monitor the status of all balancer pools so that you can send alerts if members of the pool drop out of rotation unexpectedly.
However, while performing routine maintenance, is it expected for hosts to be taken out of the rotation. That’s what service_host is for. Instead of setting downtime for a specific host, we might schedule downtime for a service representing a balancer pool on our service host.
1 2 3 4 5 6 7 | hosts: ['localhost']
steps:
- nagios:ScheduleDowntime:
nagios_url: nagios.example.com
minutes: 60
service_host: lb01.example.com
service: megafrobber_pool_prod
|
In the above example on line 6 we tell the nagios worker that instead of setting downtime for localhost, instead, set downtime for lb01.example.com. Then on the following line (7) we indicate we are setting downtime for the production megafrobber balancer pool.
8.4.4. Puppet¶
The puppet module allows you to interact with the puppet service on remote hosts.
8.4.4.1. puppet:Run¶
Parameters
The parameters to the Run subcommand can be mixed and matched together. That is to say, none of the parameters given below are mutually exclusive.
- noop (type: boolean)
- Required: False
- Default: False
- Description: Set to True to enable noop mode (show what would have happened)
- CLI Equivalent: puppet agent --test --noop
- server (type: string)
- Required: False
- Default: None
- Description: Specify which puppet master to compile the catalog against
- CLI Equivalent: puppet agent --test --server puppetmaster01.example.com
- tags (type: list of strings)
- Required: False
- Default: None
- Description: - Arguments to pass to the --tags option
- CLI Equivalent: puppet agent --test --tags sometag anothertag moretags
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | hosts: ['localhost']
steps:
# Basic subcommands
- puppet:Run
- puppet:Enable
- puppet:Disable
# Now with some extra options
# Run puppet in noop mode
- puppet:Run:
noop: True
# Run puppet in noop mode, and make sure the agent is enabled first
- puppet:Enable
- puppet:Run:
noop: True
# Equivalent to 'puppet agent --test --tags yum auth package'
- puppet:Run:
tags:
- yum
- auth
- package
|
8.4.4.2. puppet:Enable¶
Parameters
- The Enable subcommand does not accept any parameters
1 2 3 | hosts: ['localhost']
steps:
- puppet:Enable
|
8.4.4.3. puppet:Disable¶
Parameters
- motd (type: string or False)
- Required: False
- Default: puppet disabled by Release Engine at 2014-09-16 16:27:11.075617
- Description: The puppet:Disable sub-command will automatically append a message to /etc/motd indicating that the puppet agent has been stopped. This behavior can be disabled by setting motd to False, or customized by setting motd to a message of your choice. Use %s to substitute a datestring (per str(datetime.datetime.now())) into your message
1 2 3 4 5 6 7 8 9 10 11 12 | hosts: ['localhost']
steps:
# Just disable the puppet agent, motd is still updated
- puppet:Disable
# Disable the agent, but don't update the motd
- puppet:Disable
motd: False
# Disable the agent, and put a custom message in /etc/motd
- puppet:Disable
motd: "Puppet disabled for maintenance on %s"
|
8.4.5. Service¶
The service module allows you to interact with system services, as you would with the service or systemctl commands. Only one example is included in this section because the syntax for each of the service module steps are nearly identical.
8.4.5.1. Example¶
This example demonstrates how to restart the megafrobber service (see lines 3 and 4).
1 2 3 4 | hosts: ['localhost']
steps:
- service:Restart:
service: megafrobber
|
To use any of the other sub-commands, on line 3 in this example we would replace service:Restart with the desired subcommand. Such as service:Stop or service:Reload.
8.4.5.2. service:Stop¶
Stop a given service.
8.4.5.3. service:Start¶
Start a given service.
8.4.5.4. service:Restart¶
Restart a given service.
8.4.5.5. service:Status¶
Return the status (running, stopped, etc) of a given service.
8.4.5.6. service:Reload¶
Tell a service to reload it’s configuration files.
Note
Not all system services support all the given subcommands. This is especially true for reload.
8.4.6. Yum Cmd¶
8.4.6.1. yumcmd:Install¶
The yumcmd install command will allow you to install a package or packages to the systems defined in the playbook.
1 2 3 4 | hosts: ['localhost']
steps:
- yumcmd:Install:
package: emacs
|
8.4.6.2. yumcmd:Remove¶
The yumcmd remove command will remove a package installed on one system or many systems as defined by the playbook.
1 2 3 4 | hosts: ['localhost']
steps:
- yumcmd:Remove:
package: vim
|
8.4.6.3. yumcmd:Update¶
Yumcmd update will update the system completely. Of note this will not currently update an individual package.
1 2 3 | hosts: ['localhost']
steps:
- yumcmd:Update
|
8.5. Git¶
8.5.1. git:Merge¶
Merges one branch into another and then pushes it back to origin.
Parameters
- repo (type str)
- to_branch (type str)
- Required: True
- Description: The branch to merge in to
- from_branch (type str)
- Required: False
- Description: The branch to merge from
Example
To merge one commit into mybranch:
1 2 3 4 5 6 | hosts: ['localhost']
steps:
- git:Merge:
repo: ssh://git@example.com/someplace.git
to_branch: master
from_branch: feature
|
8.5.2. git:CherryPickMerge¶
Cherry pick’s commits from one branch and then squashs the results into another.
Parameters
- repo (type str)
- to_branch (type str)
- Required: True
- Description: The branch to squash merge in to
- temp_branch (type str)
- Required: False
- Description: The temporary branch to use while cherry picking (Default: mergebranch)
- commits (type list)
- Required: True
- Description: List of commits to cherry pick
- run_scripts (type list)
- Required: False
- Description: List of script names to execute before pushing results back to server
Example
To merge one commit into mybranch:
1 2 3 4 5 6 | hosts: ['localhost']
steps:
- git:CherryPickMerge:
repo: ssh://git@example.com/someplace.git
to_branch: mybranch
commits: ['77a085eb34597b544a233d8ce4c943dcac']
|
8.6. noop¶
8.6.1. noop:Fail¶
Force a deployment to fail.
8.6.2. noop:AnythingElse¶
Any other subcommand given to the noop worker will automatically succeed.
Example
The first step will pass, the second step will fail.
1 2 3 4 | hosts: ['localhost']
steps:
- noop:MegaFrobber
- noop:Fail
|
8.7. HTTPRequest¶
8.7.1. httprequest:Get¶
Executes an HTTP GET on a URL.
Parameters
- url (type str)
- Required: True
- Description: The URL to attempt to get.
- code (type int)
- Required: False
- Description: The expected status code. Default: 200
Example
To request http://example.com and expect a 200:
1 2 3 4 5 | hosts: ['localhost']
steps:
- httprequest:Get:
url: "http://example.com"
code: 200
|
8.7.2. httprequest:Put¶
Executes an HTTP PUT on a URL.
Parameters
- url (type str)
- Required: True
- Description: The URL to attempt to put.
- content (type str)
- Required: True
- Description: The content itself.
- contenttype (type str)
- Required: True
- Description: The content type of the content.
- b64encoded (type bool)
- Required: False
- Description: Set to true if the content is base64encoded. The worker will then decode before PUTting.
- code (type int)
- Required: False
- Description: The expected status code. Default: 200
Example
To PUT json to http://example.com and expect a 201:
1 2 3 4 5 6 7 | hosts: ['localhost']
steps:
- httprequest:Put:
url: "http://example.com"
code: 201
contenttype: "application/json"
content: "{}"
|
8.7.3. httprequest:Post¶
Executes an HTTP POST on a URL.
Parameters
- url (type str)
- Required: True
- Description: The URL to attempt to post.
- content (type str)
- Required: True
- Description: The content itself.
- contenttype (type str)
- Required: True
- Description: The content type of the content.
- b64encoded (type bool)
- Required: False
- Description: Set to true if the content is base64encoded. The worker will then decode before POSTing.
- code (type int)
- Required: False
- Description: The expected status code. Default: 200
Example
To POST json to http://example.com and expect a 200:
1 2 3 4 5 6 7 | hosts: ['localhost']
steps:
- httprequest:Post:
url: "http://example.com"
code: 200
contenttype: "application/json"
content: "{}"
|
8.7.4. httprequest:Delete¶
Executes an HTTP DELETE on a URL.
Parameters
- url (type str)
- Required: True
- Description: The URL to attempt to delete.
- code (type int)
- Required: False
- Description: The expected status code. Default: 200
Example
To request a DELETE on http://example.com and expect a 410:
1 2 3 4 5 | hosts: ['localhost']
steps:
- httprequest:Delete:
url: "http://example.com"
code: 410
|
8.8. Satellite5¶
8.8.1. satellite5:Promote¶
Promote all RPM’s from one channel into another channel. Under the covers this utilizes the channel.software.mergePackages API call.
Dynamic Parameters
- promote_from_label (type str)
- Required: True
- Description: Channel to promote packages from
- promote_to_label (type str)
- Required: True
- Description: Channel to promote packages to
Example
Promote packages from sourcechannel into destinationchannel
1 2 3 4 5 | hosts: ['localhost']
steps:
- satellite5:Promote:
promote_from_label: sourcechannel
promote_to_label: destinationchannel
|
8.9. Sleep¶
8.9.1. sleep:Seconds¶
Pause all further playbook step execution for the given number of seconds.
Parameters
- seconds (type int)
- Required: True
- Description: The number of seconds to pause for
Example
To pause a playbook for 1,337 seconds:
1 2 3 4 | hosts: ['localhost']
steps:
- sleep:seconds:
seconds: 1337
|
Note
If more than one host is given in hosts, the playbook will pause again for each host given.
8.10. ServiceNow¶
Note
All checks are ran for each host in hosts
Note
All ServiceNow steps are more useful as a Pre-Deployment Step
8.10.1. servicenow:DoesChangeRecordExist¶
Checks to see if a change record exists. Resulting data will have an exists key with a bool.
Dynamic Arguments
- change_record (type str)
- Required: True
- Description: The change record to look for.
Example
To check if a change record exists:
1 2 3 4 5 | hosts: ['localhost']
steps:
- servicenow:DoesChangeRecordExist:
dynamic:
- change_record
|
8.10.2. servicenow:DoesCTaskExist¶
Checks to see if a CTask exists. Resulting data will have an exists key with a bool.
Dynamic Arguments
- change_record (type str)
- Required: True
- Description: The associated CHG in case of auto creation.
- ctask (type str)
- Required: True
- Description: The CTask to look for.
Example
To check if a CTask exists:
1 2 3 4 5 6 | hosts: ['localhost']
steps:
- servicenow:DoesCTaskExist:
dynamic:
- change_record
- ctask
|
8.10.3. servicenow:UpdateStartTime¶
Updates the custom start time field for an environment.
Dynamic Arguments
- change_record (type str)
- Required: True
- Description: The change record to look for.
- environment (type str)
- Required: True
- Description: The target environment.
Example
To update the start time:
1 2 3 4 5 6 | hosts: ['localhost']
steps:
- servicenow:UpdateStartTime:
dynamic:
- environment
- change_record
|
8.10.4. servicenow:UpdateEndTime¶
Updates the custom end time field for an environment.
Dynamic Arguments
- change_record (type str)
- Required: True
- Description: The change record to look for.
- environment (type str)
- Required: True
- Description: The target environment.
Example
To update the start time:
1 2 3 4 5 6 | hosts: ['localhost']
steps:
- servicenow:UpdateEndTime:
dynamic:
- environment
- change_record
|
8.10.5. servicenow:CreateChangeRecord¶
Create a change record automatically.
Note
Creating change records requires a non-trivial amount of integration work. This subcommand will not work out-of-the-box.
See the main re-worker-servicenow documentation for additional information.
Arguments
- This subcommand accepts no arguments
Example
To create a change record
1 2 3 | hosts: ['localhost']
steps:
- servicenow:CreateChangeRecord
|
8.10.6. servicenow:CreateCTask¶
Creates a new CTask.
Dynamic Arguments
- change_record (type str)
- Required: True
- Description: The change record to associate the new CTask with.
- ctask_description (type str)
- Required: False
- Description: Description of the task.
Example
To create a new CTask:
1 2 3 4 5 6 | hosts: ['localhost']
steps:
- servicenow:CreateCTask:
dynamic:
- change_record
- ctask_description
|
8.11. SQL¶
8.11.1. sql:CreateTable¶
Creates a NEW database table.
Parameters
- database (type str)
- Required: True
- Description: The name of the database to operate on
- name (type str)
- Required: True
- Description: The new tables name.
- columns (type dict)
- Required: True
- Description: Explination of how the table should look like. For more information on types see SQL Alchemy - Generic Types documentation.
Example
To create a table named MyTable with a two varchar columns:
1 2 3 4 5 6 7 8 9 10 11 12 13 | hosts: ['localhost']
steps:
- sql:CreateTable:
database: a_configured_database
name: MyTable
columns:
col1:
type: String
length: 255
primary_key: true
col2:
type: String
length: 255
|
8.11.2. sql:DropTable¶
Drops a table from a database.
Parameters
- database (type str)
- Required: True
- Description: The name of the database to operate on
- name (type str)
- Required: True
- Description: The table to drop.
Example
To drop MyTable:
1 2 3 4 5 | hosts: ['localhost']
steps:
- sql:DropTable:
database: a_configured_database
name: MyTable
|
8.11.3. sql:AlterTableColumns¶
Alters one or more columns in a table.
Parameters
- database (type str)
- Required: True
- Description: The name of the database to operate on
- name (type str)
- Required: True
- Description: The table name.
- columns (type dict)
- Required: True
- Description: Explination of how the columns should look like. For more information on types see SQL Alchemy - Generic Types documentation.
Example
To alter MyTable modifying a column:
1 2 3 4 5 6 7 8 9 | hosts: ['localhost']
steps:
- sql:AlterTableColumns:
database: a_configured_database
name: MyTable
columns:
col_to_modify:
type: String
length: 255
|
8.11.4. sql:AddTableColumns¶
Adds one or more columns in a table.
Parameters
- database (type str)
- Required: True
- Description: The name of the database to operate on
- name (type str)
- Required: True
- Description: The table name.
- columns (type dict)
- Required: True
- Description: Explination of how the columns should look like. For more information on types see SQL Alchemy - Generic Types documentation.
Example
To add two new columns to MyTable:
1 2 3 4 5 6 7 8 9 10 11 | hosts: ['localhost']
steps:
- sql:AddTableColumns:
database: a_configured_database
name: MyTable
columns:
new_col:
type: String
length: 255
another_new_col:
type: Integer
|
8.11.5. sql:DropTableColumns¶
Drops one or more columns from a table.
Parameters
- database (type str)
- Required: True
- Description: The name of the database to operate on
- name (type str)
- Required: True
- Description: The table name.
- columns (type list)
- Required: True
- Description: The names of the columns to drop
Example
Drop col2 from MyTable:
1 2 3 4 5 6 7 8 | hosts: ['localhost']
steps:
- sql:DropTableColumns:
database: a_configured_database
name: MyTable
columns: [
col2
]
|
8.11.6. sql:Insert¶
Inserts one or more rows into a table.
Parameters
- database (type str)
- Required: True
- Description: The name of the database to operate on
- name (type str)
- Required: True
- Description: The table name.
- rows (type list io dict)
- Required: True
- Description: Explination of the data to insert
Example
To insert two rows into MyTable:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | hosts: ['localhost']
steps:
- sql:Insert:
database: a_configured_database
name: MyTable
rows: [
{
col1: "hi",
col2: "hello"
},
{
col1: "sup",
col2: "aloha"
}
]
|
8.11.7. sql:Delete¶
Deletes one or more rows from a table.
Note
Currently Delete only supports equals in where.
Parameters
- database (type str)
- Required: True
- Description: The name of the database to operate on
- name (type str)
- Required: True
- Description: The table name.
- where (type dict)
- Required: True
- Description: Explination of when to delete.
Example
Delete everything from MyTable where col1 is hi:
1 2 3 4 5 6 7 8 | hosts: ['localhost']
steps:
- sql:Delete:
database: a_configured_database
name: MyTable
where: {
col1: "hi"
}
|
8.11.8. sql:ExecuteSQL¶
Execute raw (and database specific) SQL.
Parameters
- database (type str)
- Required: True
- Description: The name of the database to operate on
- sql (type str)
- Required: True
- Description: The SQL to execute.
Example
To insert a row in to MyTable:
1 2 3 4 5 | hosts: ['localhost']
steps:
- sql:ExecuteSQL:
database: a_configured_database
sql: 'INSERT INTO myTable (col1, col2) VALUES ("hello", "there")'
|