I'm trying to deploy a build via Jenkins pipeline using agent
docker
and Ansible playbook but it fails on Gathering Facts
stage as shown below:
TASK [Gathering Facts] *********************************************************
fatal: [destination.box.local]: UNREACHABLE! => {"changed": false, "msg": "argument must be an int, or have a fileno() method.", "unreachable": true}
Similar Jenkins pipeline using agent
any
and Ansible not from docker (local installation) will do the job w/o any hiccups.
Agent section from Jenkins pipeline looks like:
pipeline {
agent {
docker {
image 'artifactory.devbox.local/docker-local/myrepo/jdk8:latest'
args '-v $HOME/.m2:/root/.m2 -v /etc/ansible:/etc/ansible -v $HOME/.ansible/tmp:/.ansible/tmp -v $HOME/.ssh:/root/.ssh'
}
}
parameters {
string(
name: 'PROFILE',
defaultValue: 'dev',
description: 'Select profile to build?'
)
string(
name: 'HOST',
defaultValue: 'dev',
description: 'Which Outbound Host(s) group to deploy to?'
)
}
stages {
stage('Artifactory configuration') {
steps {
rtMavenDeployer(
id: "MAVEN_DEPLOYER",
serverId: 'Artifactory',
releaseRepo: "libs-release-local",
snapshotRepo: "libs-snapshot-local"
)
rtMavenResolver(
id: "MAVEN_RESOLVER",
serverId: 'Artifactory',
releaseRepo: "libs-release",
snapshotRepo: "libs-snapshot"
)
}
}
stage('Maven build') {
steps {
withEnv(['JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk', 'MAVEN_HOME=/usr/share/maven']) {
rtMavenRun(
pom: 'pom.xml',
goals: 'clean',
deployerId: "MAVEN_DEPLOYER",
resolverId: "MAVEN_RESOLVER"
)
}
}
}
stage ('Publish build') {
steps {
rtPublishBuildInfo (
serverId: 'Artifactory',
)
}
}
stage('deploy') {
when{
anyOf {
branch 'master'
branch 'develop'
}
}
steps {
ansiblePlaybook(
playbook: 'playbook.yml',
extraVars: [
profile: "${params.PROFILE}",
host: "${params.HOST}"
]
)
}
}
}
}
After adding ansible_ssh_common_args='-o StrictHostKeyChecking=no'
to the Ansible inventory (or setting host_key_checking = False
in the config) I have got that error:
TASK [Gathering Facts] *********************************************************
fatal: [destination.box.local]: UNREACHABLE! => {"changed": false, "msg": "'getpwuid(): uid not found: 700'", "unreachable": true}
fatal: [ansible_ssh_common_args=-o StrictHostKeyChecking=no]: UNREACHABLE! => {"changed": false, "msg": "[Errno -3] Try again", "unreachable": true}
Any thought what I need to add to it to let Ansible run a playbook?
steps
in your pipeline that runs Ansible. Can you five us the full Jenkinsfile please ?