Skip to content

Commit

Permalink
Merge pull request #6 from nikosch86/develop
Browse files Browse the repository at this point in the history
digitalocean changed something in how the droplet comes online, we ha…
  • Loading branch information
nikosch86 authored Sep 17, 2022
2 parents 2edb778 + d233d30 commit affeb15
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions stand-up.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,26 @@ def validate_digitalocean():
for action in actions:
action.load()
action.wait()
if action.status == 'in-progress':
logger.debug("droplet not yet up, waiting some more")
actions = droplet.get_actions()
for action in actions:
action.load()
action.wait()
droplet.load()
if droplet.status != 'active' and droplet.status != 'new':
cleanup_and_die('something went wrong creating the instance, the status is "{}"'.format(droplet.status))
waitForNetworkingCount = 0
waitForNetworkingMax = 10
while droplet.ip_address is None and waitForNetworkingCount < waitForNetworkingMax:
waitForNetworkingCount += 1
logger.debug("the droplet does not report back an external IP, waiting {}/{}".format(waitForNetworkingCount, waitForNetworkingMax))
time.sleep(2)
droplet.load()
instance_ip = droplet.ip_address
if instance_ip is None:
print(vars(droplet))
cleanup_and_die('something went wrong, the droplet does not report back an external IP: {}'.format(vars(droplet)))
logger.info("instance with id {} has external IP {}".format(droplet.id, instance_ip))
printProgressBar(7)
try:
Expand Down Expand Up @@ -628,11 +644,16 @@ def validate_digitalocean():
printProgressBar(9)
logger.info("setting up system")
stdin, stdout, stderr = ssh.exec_command("echo LC_ALL=\"en_US.UTF-8\" >> /etc/default/locale; \
apt-get -q update && apt-get install -yq curl software-properties-common dirmngr && \
docker -v >/dev/null 2>&1 || curl https://get.docker.com | bash")
apt-get -q -o DPkg::Lock::Timeout=60 update && apt-get -o DPkg::Lock::Timeout=60 install -yq curl software-properties-common dirmngr")
logger.debug("".join(stdout.readlines()))
if stdout.channel.recv_exit_status() > 0: logger.critical("STDERR of setup command: {}".format(stderr.read()))

logger.info("setting up docker")
stdin, stdout, stderr = ssh.exec_command("docker -v >/dev/null 2>&1 || curl https://get.docker.com | bash")
logger.debug("".join(stdout.readlines()))
if stdout.channel.recv_exit_status() > 0: logger.critical("STDERR of setup command: {}".format(stderr.read()))


printProgressBar(10)

stdin, stdout, stderr = ssh.exec_command("docker-compose -v >/dev/null || curl -L \"https://github.com/docker/compose/releases/download/{}/docker-compose-Linux-x86_64\" -o /usr/local/bin/docker-compose && \
Expand Down

0 comments on commit affeb15

Please sign in to comment.