ashiqursuperfly / Jenkins-Controller-Agent-Setup

A controller-agent (aka master-slave) setup using official Jenkins Docker containers
https://dev.to/ashiqursuperfly/jenkins-controller-agent-master-slave-setup-in-10-minutes-using-docker-2a78
4 stars 4 forks source link

Brilliant Guide! Last step failing #1

Open GranTurismoDevops opened 1 year ago

GranTurismoDevops commented 1 year ago

Dear sir or madam,

Brilliant to follow until the very last step with SSH verification fails.

I think there's a typo regarding entering the private key into Jenkins master interface...You then use the example of the public key file.

Also is the argument for JENKINS_AGENT_SSH_PUBKEY mean to be the filename or the key itself in quotes?

It would help a lot if you posted your script run command with your arguments?

ashiqursuperfly commented 1 year ago

Hello,

  1. Can you point me to the line where you think there's a typo?
  2. The argument JENKINS_AGENT_SSH_PUBKEYis meant to be the key itself in quotes. But, you can cat the contents of your public key file inline and pass it if that's more convenient for you.
  3. I used exactly these two scripts. One to start the controller and one to start the agent(s). Please note that the scripts make use of bash command line arguments. So, you need to pass them as usual when running these scripts. For example,
    bash start-jenkins-agent.sh linux_agent1 "`cat ~/.ssh/id_rsa.pub`"
  4. I also have a blog post here explaining the steps in a little more detail. Let me know if going through this helps clear up some confusion. Blog Post
GranTurismoDevops commented 1 year ago

Hi Ashiqur and thanks for the reply! Indeed thanks as well for the guide...it was very helpful and I've done some really cool things with it...

The line where I think is a typo reads as follows (From https://dev.to/ashiqursuperfly/jenkins-controller-agent-master-slave-setup-in-10-minutes-using-docker-2a78 ):

Private Key: SSH Private Key file contents (e.g: jenkins_agent_1.pub)

This is misleading because "e.g: jenkins_agent_1.pub" is a public key (Because of *.pub)

More importantly, I've been running my jenkins agents in docker containers. This has been handy for aarch64/armhf builds as we use a server in AWS to accomplish the build, and as we are building a new jenkins environment it it beneficial to simply point old_jenkins_controller and new_jenkins_controller to different armhf build containers (allowing us to not disrupt our current pipeline). So, to accomplish this I tried to hardcode the public key files in one docker-compose file...something like this...

version: '3.7'

services: jenkins_agent_1: image: jca_jenkins_agent privileged: true user: root container_name: $CONTAINER_NAME expose:

#######

Network definition

########

networks:

regnet:

networks: jenkinsagentnet: name: jenkinsagentnet driver: bridge ipam: driver: default config:

However no matter how I quote those keys, I can't seem to pass them properly into the containers they create. What are your thoughts on this please? GT

On Sat, Dec 17, 2022 at 3:10 AM Ashiqur Rahman @.***> wrote:

Hello,

  1. Can you point me to the line where you think there's a typo?
  2. The argument JENKINS_AGENT_SSH_PUBKEYis meant to be the key itself in quotes. But, you can cat the contents of your public key file inline and pass it if that's more convenient for you.
  3. I used exactly these two scripts https://github.com/ashiqursuperfly/Jenkins-Controller-Agent-Setup/tree/master/scripts. One to start the controller and one to start the agent(s). Please note that the scripts make use of bash command line arguments. So, you need to pass them as usual when running these scripts. For example,

bash start-jenkins-agent.sh linux_agent1 "cat ~/.ssh/id_rsa.pub"

  1. I also have a blog post here explaining the steps in a little more detail. Let me know if going through this helps clear up some confusion. Blog Post https://dev.to/ashiqursuperfly/jenkins-controller-agent-master-slave-setup-in-10-minutes-using-docker-2a78

— Reply to this email directly, view it on GitHub https://github.com/ashiqursuperfly/Jenkins-Controller-Agent-Setup/issues/1#issuecomment-1356133911, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2FL7F6OAVTMPJF7MKD3HQTWNV7OPANCNFSM6AAAAAATBMZW5Q . You are receiving this because you authored the thread.Message ID: @.*** .com>

ashiqursuperfly commented 1 year ago

Hey GT, The Typo: Yeah it was a mistake. Thank you soo much for pointing that out.

I just went through the entire process again and everything worked just fine. Wonder what the actual issue is in your case. Would you share any error logs that you think might be of help? Do you wanna meet over Google Meet or sth and maybe share your screen? Might be able to help. GoodLuck!