Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Creating a Bamboo Agent wit Ansible

William Flow September 25, 2022

Hi all

so I have an Ansible Playbook that:

1. Creates and Ubuntu EC2 on AWS

2. Then updates the EC2 and installs some packages and reboots

3. It then creates a Bamboo user and group and sets the password

4. It copies the Bamboo agent tar file sets its owner as Bamboo

5. I then run the installer and it approves the new agent via an API call

6. The script waits until the file bamboo-agent.cfg.xml is created

 

The problem is sometimes it happens meaning everything goes well and my new agent goes live on line or it just sits there then times out, I look at the logs and see that it is waiting to get approval 

INFO | jvm 2 | 2022/09/25 20:09:02 | * This agent requires manual approval.
INFO | jvm 2 | 2022/09/25 20:09:02 | * UUID: xxxxxxxxxxxxxxxxxxxxxxxxxx

 

then I look at the Bamboo agents

x.x.x.227xxxxxxxxxWaitingApprove access
x.x.x.227xxxxxxApprovedRevoke access | Edit IP address

 

so how can it be approved and still asking for approval? I need this to be able to setup and start the agent without errors, any help would be great

1 answer

1 accepted

0 votes
Answer accepted
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 25, 2022

Hello @William Flow,

The Bamboo Agent jar installer will keep trying to connect to the Bamboo Server every 60s in case it is not approved. Perhaps you need to wait longer and double-check the UUID inserted on bamboo.cfg.xml and use it on the REST API agent approval request.

Alternatively, you can install the Agent using the install suffix, this will only create the necessary content but will not run any services. You can then generate a bamboo.cfg.xml from a template and assign it with a random UUID then start the Agent. This way you have control of the UUID and will be 100% sure of which agent needs to be approved.

Cheers,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

William Flow September 27, 2022

Hi Eduardo so what I am thinking is  

1. install the jar file via command:

   

sudo runuser -l bamboo -c 'java -Dbamboo.home=/home/bamboo -jar /home/bamboo/atlassian-bamboo-agent-installer-8.0.9.jar https://cicd.system/agentServer/'
2. it waits for the
uuid-temp.properties file and garbs the UUID
3. They I approve the agent:
 
4. wait for the  bamboo-agent.cfg.xml file
How long should I wait for step 4 ?
or should i do a 
sudo runuser -l bamboo -c 'java -Dbamboo.home=/home/bamboo -jar /home/bamboo/atlassian-bamboo-agent-installer-8.0.9.jar https://cicd.system/agentServer/
install' then do the the approve then start the agent with a  sudo runuser -l bamboo -c '/home/bamboo/bin/bamboo-agent.sh start'  then wait for the bamboo-agent.cfg.xml file?
which do you think is better and how long to wait?
Thanks for your help
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 27, 2022

Hello @William Flow

The wait times will depend on external factors that are out of Bamboo's control as it relies on your automation.

I'd go with the second option where you have better control of the installation process.

  1. Use the install option
  2. Place a "skeleton" bamboo-agent.cfg.xml with the minimal configuration:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <configuration>
        <buildWorkingDirectory>/home/bamboo/bamboo-agent-home/xml-data/build-dir</buildWorkingDirectory>
        <agentUuid>YOU27c1a-NEED-4ebc-_TO_-af8bGENERATE</agentUuid>
        <agentDefinition>
            <name>agent_NAME</name>
            <description>Remote agent on host agent_NAME</description>
    </agentDefinition>
    </configuration>
  3. Start the Agent
  4. Approve it via the API
  5. The agent will restart every 60s and will connect to the Server once approved and add the remaining information to bamboo-agent.cfg.xml.

Regards,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

William Flow September 28, 2022

Ok will do one more question once I install it, then start it (via API), it will take time in communicating from my new agent to the bamboo server, example it will poll every minute until it sees that I approved it? So by setting my poll to check for the bamboo-

-agent.cfg.xml is there every 10 seconds for 10 minutes that in general should be enough time?
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 28, 2022

Hello @William Flow

The Bambo Agent will wait up to 60s and try again when in the Approval stage.

During the first start, the Agent will download extra files from the server, so you can add 2 or 3 minutes as a grace period (It may be more or less depending on your Network speed).

After that, capture the UUID from the bamboo-agent.cfg.xml (or use the one you have generated as per my previous suggestion) and approve it on the API.

Once the Agent is approved it will try again and succeed with the connection to the Server.

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

William Flow September 29, 2022

Hi @Eduardo Alvarenga I found my issue, what happens is 

1. i do the install with the install flag

2. I start the agent and do some more stuff

3. I restart the agent and sometimes it works fine other times I see the agent needs approval, i think the reason for this is I see the one that has already approved has and address of "the IP of the load balancer, the IP of the agent" like 10.xxx.xxx.61,10.xxx.xxx.221 and the one that is waiting is 10.xxx.xxx.91,10.xxx.xxx.221 which i think is causing the issue

Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 29, 2022

Hello @William Flow

Good to hear from you!

Try this KB article to mask your LB IP addresses from the connection and focus on the Agent's IPs:

Regards,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

William Flow September 29, 2022

Thanks for all your help @Eduardo Alvarenga  

Like Eduardo Alvarenga likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events