BMC Discovery Patterns invoking Docker and OpenShift commands on Linux Hosts are not successfully executing

Version 2
    Share This:

    This document contains official content from the BMC Software Knowledge Base. It is automatically updated when the knowledge article is modified.


    PRODUCT:

    BMC Discovery


    COMPONENT:

    BMC Discovery 11.3



    QUESTION:

    BMC Discovery Patterns invoking Docker and OpenShift commands on Linux Hosts are not successfully executing.

    Specifically the following commands are not successfully invoked:   
        
    • oc version
    •   
    • oc config view -o=json 
    •   
    • oc get nodes -o=json 
    •   
    • oc get all --all-namespaces -o=json 
    •   
    • oc get pods --all-namespaces 
    •   
    • docker ps*
    •   
    • docker version
    •  


    ANSWER:

     

    A.) The OpenShift Documentation presented on the BMC Discovery Configipedia pages states that in order for the above commands to run successfully the conditions below must be adhered to: 

      
       
    • .kube directory should be copied to the discovery user HOME directory or
    •  
    • $KUBECONFIG system variable should point to the actual .kube directory
      

    B.) Given the above, some of the listed commands need to be run as SUDO, and attempting to do so (via pattern invocation) still results in the command failing. This occurs due to one of the following reasons: 

      

     

      

    1. The path of sudo is not specified within your BMC Discovery Linux Initialise Script

      
       
    • Run the following command on your Discovery Target Host to determine the path location of Sudo: 

      

    Command: which sudo
    Example output: /usr/bin/sudo 

      
       
    • Now edit the Linux Initialise script to specify the location of sudo as follows: 

      

     

      

    # This function supports running privileged commands from patterns
    PRIV_RUNCMD() {
      COM="$@"
      SUDO="/usr/bin/sudo"

      


    2. The Initialise script utilises case $COM meaning that a complete command is required, if any of the listed commands above contain arguments, they will then result in failure. To remediate this the Initialise script will need to be altered to utilise case $1 to allow execution of commands containing arguments, as follows:
     

      

    Change FROM: 
    # This function supports running privileged commands from patterns
    PRIV_RUNCMD() {
      COM="$@"
      SUDO="/usr/bin/sudo"
      case
    $COM in
           grep)..........


    Change TO: 
    # This function supports running privileged commands from patterns
    PRIV_RUNCMD() {
      COM="$@"
      SUDO="/usr/bin/sudo"
      case
    $1 in
           grep)..........

     

      

    3. This point is specifically pertinent to the docker commands. The PRIV_RUNCMD attempts to run the docker command with the path /usr/bin/docker, however the TKU Pattern runs the command without the path specified, hence you'll need to amend the Initialise script to run the docker command without the path specified: 
     

      

    Change FROM: 
    # This function supports running privileged commands from patterns
    PRIV_RUNCMD() {
      COM="$@"
      SUDO="/usr/bin/sudo"
      case
    $COM in
           grep)..........

      

      ....

      
      /usr/bin/docker*)
                                  $SUDO $COM
       

    Change TO: 
    # This function supports running privileged commands from patterns
    PRIV_RUNCMD() {
      COM="$@"
      SUDO="/usr/bin/sudo"
      case
    $COM in
           grep)..........

       

      ....

       
       docker*)
                                  $SUDO $COM
     
      
      
       

     

      

     


    Article Number:

    000154891


    Article Type:

    FAQ/Procedural



      Looking for additional information?    Search BMC Support  or  Browse Knowledge Articles