How to update host IP address after AWS node reboot

One of my AWS hosts was rebooted and a different public IP address was allocated and the node is now stuck in “RECONNECTING” mode. I’m trying to run the command below on the affected host with CATTLE_AGENT_IP=NEW host PUBLIC IP address and MANAGEMENT_IP = rancher server IP address. I’m not sure what the SECURITY_TOKEN is and where I can locate it in the config. Any assistance is much appreciated. Thanks.

sudo docker run -d –e CATTLE_AGENT_IP=x.x.x.x --privileged
-v /var/run/docker.sock:/var/run/docker.sock
rancher/agent:v0.9.2 http://MANAGEMENT_IP:8080/v1/scripts/SECURITY_TOKEN

On the Add Host page, click the “custom” icon and then copy the docker run command from there. Add -e CATTLE_AGENT_IP=<your new public ip> to it.

I copied and pasted the command from the custom page, it appears that the run command still contains the old rancher server ip address. Anyway, I updated the relevant IP addresses but the host is still in RECONNECTING mode, not sure if there’s anything else I need to do. Not sure if the security token is IP dependent, if yes, perhaps the new Token is not reflected on the docker run command. Thanks for looking into it.

I have just checked the output of docker inspect and the IP addresses were not updated successfully even though docker run command was executed without error.

If your Rancher/server IP also changed, you would need to update the host registration to the new IP, which would update the custom command.

http://docs.rancher.com/rancher/configuration/settings/#host-registration

And then re-run the rancher/agent registration for all agents.