I have a pipeline that ask as a string parameter the IP of server where connect and make operations.
I added to jenkis side pipeline
extraVars: [serverPublicIP:"${serverPublicIP}"]
Now in the ansible side I have this before
name: connect and instal....
hosts: webservers
remote_user: ec2-user
become: true
tasks:
and in dev.inv
[webservers]
XX.YY.ZZ.KK ansible_user=ec2-user
so webservers is a static map of server to connect.
How i can pass the IP received from jenkis pipeline to ansible inv? or how change ansible script for use ip from jenkins and not use ip on map?
Related
I'm using Kubernetes Continuous Deploy Plugin to deploy and I'm using pipeline and this is stage to deploy into kubernetes in the Jenkinsfile:
stage('Deploy to k8s'){
steps{
kubernetesDeploy(
configs:'quarkusAgrata.yaml',
kubeconfigId:'KUBERNETES_CLUSTER_CONFIG',
enableConfigSubstitution:true
)
}
}
I am getting these errors even after correctly configuring
My KUBERNETES_CLUSTER_CONFIG image
Log on to the box/container/pod hosting Jenkins and try to ping the IP, if alls good, try to telnet to the IP AND port. Depending on the results you should know whether or not a connection is possible from your Jenkins host. Note: if you have Jenkins running in a Container On a pod, you may need to ssh into the container on the pod. Make sure you're in the correct environment when trying to debug. Otherwise you'll kid yourself into thinking you're forming a connection from the Jenkins host when you might not be at quite the right level.
ping 123.123.123.123 - show whether a connection to the host is possible on the ping port.
telnet 123.123.123.123 8080 - connecting to a specific port via telnet - if all is good the connection should be opened. If you don't have the telnet application on the pod you may need to install it.. or else you can spin up a busybox container which has various tools alongside telnet for debugging.
I am having Jenkins in my virtual machine Azure .i need to access it with URL remotely from outside.
No matter which the steps you have done, create the VM with a cloud-init file to install the Jenkins, or create the VM and then install the Jenkins. There is no difference.
You need to open port 8080 for Jenkins traffic and port 1337 for the Node.js app. If you finish all the settings of Jenkins, then you can browse the Jenkins with the VM public IP and the port 8080 outside the VM, the URL like this: http://vmPublicIps:8080. Get all the steps from Create a VM in Azure with Jenkins.
Or you can just create a Jenkins Server with the image that Azure provided, see Create a Jenkins server on an Azure Linux VM from the Azure portal.
I am not sure how to specify my host name in ansible host file. I am not able to ping my remote machine because of this.
jenkins slave node name: agent007
In /etc/ansible/hosts list the host machines:
[localhost]
IP address of local host
u should have passwordless connection using ssh-keygen -t rsa which will give u a rsa.pubkey which should be copied on authorization keys of host machine
then u can run the playbook
Please make sure you have mapped the local DNS if you are trying to ping using hostname.
Or else try Ip. Also you should make the password-less authentication for this.
Use ssh-keygen and copy the pub key to the remote server in authorized hosts file.
The remote host you are trying to reach needs to be defined in your ansible inventory file, usually named hosts:
agent007 ansible_ssh_host=<ip addr>
Then you can explicitly use this inventory file with the -i option
ansible-playbook -i hosts firstplaybook.yml
I am able to install kubernetes using kubeadm method successfully. My environment is behind a proxy. I applied proxy to system, docker and I am able to pull images from Docker Hub without any issues. But at the last step where we have to install the pod network (like weave or flannel), its not able to connect via proxy. It gives a time out error. I am just checking to know if there is any command like curl -x http:// command for kubectl apply -f? Until I perform this step it says the master is NotReady.
When you do work with a proxy for internet access, do not forget to configure the NO_PROXY environment variable, in addition of HTTP(S)_PROXY.
See this example:
NO_PROXY accepts a comma-separated list of hosts, IP addresses, or IP ranges in CIDR format:
For master hosts
Node host name
Master IP or host name
For node hosts
Master IP or host name
For the Docker service
Registry service IP and host name
See also for instance weaveworks/scope issue 2246.
When connecting Jenkins master and Jenkins agent by means of JNLP, and having a firewall in between, which port(s) do I have to declare in the firewall to be kept open?
For Jenkins master:
443 (the Jenkins master is available via https)
9999 (fixed configured in my Jenkins master in 'TCP port for JNLP agents')
For Jenkins agent:
Which port has to be open for Jenkins master to be able to access Jenkins agent?
When connecting Jenkins master and slave/agent via JNLP, the agent is the one who will establish communication with the master.
It's ideal if the agent(s) are behind a firewall or in a private network that doesn't allow incoming connections.
Which port has to be open for Jenkins master to be able to access Jenkins agent?
None, just be sure that the TCP port for JNLP is open on the master (port 9999 in your case)