Rundeck Integration: An Example of CLI Approach Integration


This article describes how to use Rundeck Cli in Rundeck and how to operate Rundeck Cli with specific examples.

Summary Info

Rundeck's Cli profile information is shown in the following table:

project Explain
Official website http://rundeck.org
Open/Closed Source Open Source
Source code management address https://github.com/rundeck/rundeck-cli
License Category Apache 2.0 License
development language Java,Groovy
Current stable version v1.1.1 (2018/12/21)
Operating System Support Cross-platform support for Linux/Windows/Mac
Download address: github release https://github.com/rundeck/rundeck-cli/releases

Installation mode

Rundeck cli provides yum source and apt-get source, which can be installed directly using yum install or apt-get install on relevant Linux distributions. A simpler and more flexible way is to download the required version of binary jar files directly from github release, which can be used directly in JRE or JDK environments. The following is a brief description of the installation with v1.1.1 as an example.

Step 1: Download the jar file

[root@host132 ~]# wget https://github.com/rundeck/rundeck-cli/releases/download/v1.1.1/rundeck-cli-1.1.1-all.jar
...ellipsis
Saving to: 'rundeck-cli-1.1.1-all.jar'

100%[==============================================================================================>] 4,028,801    513KB/s   in 7.8s   
...ellipsis
[root@host132 ~]# 
[root@host132 ~]# ls rundeck-cli-1.1.1-all.jar 
rundeck-cli-1.1.1-all.jar
[root@host132 ~]# du -k rundeck-cli-1.1.1-all.jar 
3936	rundeck-cli-1.1.1-all.jar
[root@host132 ~]# 

jar files using cli

rundeck can be manipulated by cli using the following format

Command format: java-jar rundeck-cli-1.1.1-all.jar cli command

When no parameters are entered, available cli commands are output

liumiaocn:~ liumiao$ java -jar rundeck-cli-1.1.1-all.jar 
No command was specified.

- RD - Rundeck API Client Tool (v1.1.1) - https://rundeck.github.io/rundeck-cli/


    .:'/*/'`:,·:~·–:.,              ,._., ._
   /::/:/:::/:::;::::::/`':.,'       /::::::::::'/:/:~-.,
 /·*'`·´¯'`^·-~·:–-'::;:::'`;     /:-·:;:-·~·';/:::::::::`·-.
 '\                       '`;::'i'   ';           '`~-:;:::::::::'`,
   '`;        ,– .,        'i:'/     ',.                 '`·-:;:::::'i''
     i       i':/:::';       ;/'        `'i      ,_            '`;:::'¦'
     i       i/:·'´       ,:''           'i      ;::/`:,          i'::/
     '; '    ,:,     ~;'´:::'`:,       _;     ;:/;;;;:';        ¦'/
     'i      i:/\       `;::::/:'`;'   /::';   ,':/::::::;';     ;/   \       '`:/::::/',/-:;_i  ,'/::::;·´        ,'´
      ';   ,'       \         '`;/' '`·.     `'¯¯     '   , ·'´
       `'*´          '`~·-·^'´        `' ~·- .,. -·~ ´
                                           '

Available commands:

   adhoc      - Run adhoc command or script on matching nodes
   executions - List running executions, attach and follow their output, or kill them
   jobs       - List and manage Jobs
   keys       - Manage Keys via the Key Storage Facility.
   metrics    - View metrics endpoints information
   nodes      - List node resources
   projects   - List and manage projects
   retry      - Run a Job based on a specific execution
   run        - Run a Job
   scheduler  - View scheduler information
   system     - View system information
   tokens     - Create, and manage tokens
   users      - Manage user information

Use "rd [command] help" to get help on any command.
liumiaocn:~ liumiao$ 

Usage settings

Default settings file

Under Unix, you can use the following files to save the relevant settings

Setup file: ~/.rd/rd.conf

Setting of Environmental Variables

Common environmental variables are as follows:

  • RD_URL: Rundeck connection URL
  • RD_TOKEN: Connect to TOKEN
  • RD_USER: Connect username (used in conjunction with RD_PASSWORD)
  • RD_PASSWORD: Connection Password

Use example

Take the Project related operation as an example to illustrate the following.

Query Project

  • List all project information
    You can see that there is currently a project called rundeck-test-project.
liumiaocn:~ liumiao$ RD_URL=http://localhost:32044  RD_USER=admin RD_PASSWORD=admin java -jar rundeck-cli-1.1.1-all.jar projects list
# 1 Projects:
rundeck-test-project

liumiaocn:~ liumiao$ 

Create Project

Projects can be created in a variety of ways, where relevant parameters can be created by passing them directly into the command line.

liumiaocn:~ liumiao$ RD_URL=http://localhost:32044  RD_USER=admin RD_PASSWORD=admin java -jar rundeck-cli-1.1.1-all.jar projects create -p rundeck-test-cli-project -- --project.lable="Rundeck Test Cli Project"
# Created project: 
# 	rundeck-test-cli-project
liumiaocn:~ liumiao$ 

Validation of results after creation

liumiaocn:~ liumiao$ RD_URL=http://localhost:32044  RD_USER=admin RD_PASSWORD=admin java -jar rundeck-cli-1.1.1-all.jar projects list
# 2 Projects:
rundeck-test-cli-project
rundeck-test-project

liumiaocn:~ liumiao$

Confirmation of Web Page Results

In addition to creating queries for all items, the operations that pages can do are basically cli-able, and there are no more examples.

liumiaocn:~ liumiao$ RD_URL=http://localhost:32044  RD_USER=admin RD_PASSWORD=admin java -jar rundeck-cli-1.1.1-all.jar projects 
No command was specified.
List and manage projects.


Available commands:

   acls      - Manage Project ACLs
   archives  - Project Archives import and export
   configure - Manage Project configuration
   create    - Create a project
   delete    - Delete a project
   info      - Get info about a project
   list      - List all projects
   readme    - Manage Project readme
   scm       - Manage Project SCM

Use "projects [command] help" to get help on any command.
liumiaocn:~ liumiao$ 

Other contents

Reference content

https://www.rundeck.com/open-source
https://rundeck.github.io/rundeck-cli/commands/
https://rundeck.github.io/rundeck-cli/install/
https://rundeck.github.io/rundeck-cli/configuration/

Keywords: github Java Linux yum

Added by sun14php on Sun, 19 May 2019 17:14:11 +0300