Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-50248

Ansible play unable to connect remote host

    Details

    • Type: Task
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: ansible-plugin
    • Labels:
      None
    • Environment:
    • Similar Issues:

      Description

      My playbook unable to connect remote host with private key for cloud user.

       

      Getting following error.

      suse12sp1 #48 Console [Jenkins]
      Started by user Abhay Srivastava
      Building in workspace /var/lib/jenkins/workspace/suse12sp1
      Installer "Run Shell Command" cannot be used to install "ansible-2.4.2.0" on the node "Jenkins"
      [suse12sp1] $ /bin/ansible-playbook /tmp/test.sh -i /tmp/hosts -f 5 --private-key /tmp/ssh1894583294890662940.key -u cloud
      ERROR! playbooks must be a list of plays

      The error appears to have been in '/tmp/test.sh': line 2, column 1, but may
      be elsewhere in the file depending on the exact syntax problem.

      The offending line appears to be:

      #!/bin/bash
      /bin/ansible-playbook /tmp/test.yml -i /tmp/hosts -f 5 --private-key /tmp/KeyPair-1c48_abhay_prod.pem -u cloud
      ^ here
      FATAL: command execution failed
      hudson.AbortException: Ansible playbook execution failed
      at org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder.perform(AnsiblePlaybookBuilder.java:236)
      at org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder.perform(AnsiblePlaybookBuilder.java:207)
      at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
      at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
      at hudson.model.Build$BuildExecution.build(Build.java:206)
      at hudson.model.Build$BuildExecution.doRun(Build.java:163)
      at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
      at hudson.model.Run.execute(Run.java:1727)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:97)
      at hudson.model.Executor.run(Executor.java:429)
      ERROR: Ansible playbook execution failed
      Finished: FAILURE
       

        Attachments

          Activity

          abhaysrivastava Abhay Srivastava created issue -
          Hide
          abhaysrivastava Abhay Srivastava added a comment -

          my key permission was wrong as it was read only for owner, and Jenkins user trying to access it but due to read 400 permission it was unable to read key file so I changed the permission of key file to 444. Now its working fine.

          Show
          abhaysrivastava Abhay Srivastava added a comment - my key permission was wrong as it was read only for owner, and Jenkins user trying to access it but due to read 400 permission it was unable to read key file so I changed the permission of key file to 444. Now its working fine.
          abhaysrivastava Abhay Srivastava made changes -
          Field Original Value New Value
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          abhaysrivastava Abhay Srivastava made changes -
          Assignee Jean-Christophe Sirot [ sirot ] Abhay Srivastava [ abhaysrivastava ]

            People

            • Assignee:
              abhaysrivastava Abhay Srivastava
              Reporter:
              abhaysrivastava Abhay Srivastava
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: