0

I have

jenkins ansible and remote host

jenkinsfile code

def CONSUL_HCL_FILE_CONTEXT(name,port,target_host){
def CONTEXT="""
service {
name = '${name}'
port = ${port}
enable_tag_override = false
tags = ['prometheus']
check {
name = '${name}'
tcp = '${target_host}:${port}'
interval = \"60s\"
}
}
"""
return CONTEXT;
}
deploy = sh(script: "ansible -m shell -a 'echo \"${CONSUL_HCL_FILE_CONTEXT("${project}","${port}","${target_host}")}\" | tee /etc/consul.d/${project}.hcl' ${target_host}", returnStdout: true).trim() as String

after check result on target_host

/etc/consul.d# cat /etc/consul.d/metrics_from_hive.hcl

service {
name = metrics_from_hive
port = 8006
enable_tag_override = false
tags = [prometheus]
check {
name = metrics_from_hive
tcp = remote-001:8006
interval = 60s
}
}

How tansfer double from jenkinsfile to remote target host via ansible ssh?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.