Skip to content

Instantly share code, notes, and snippets.

@richbruce
Last active May 26, 2020 13:19
Show Gist options
  • Save richbruce/722f52a052e403ba29baf1deb0e8f6c3 to your computer and use it in GitHub Desktop.
Save richbruce/722f52a052e403ba29baf1deb0e8f6c3 to your computer and use it in GitHub Desktop.
from pexpect import pxssh
import os
NODE_IPADDRESSES = os.getenv('NODE_IPADDRESSES')
NODE_IPADDRESSES = NODE_IPADDRESSES.split(",")
NODE_USERNAME = os.getenv('NODE_USERNAME')
NODE_USERNAME_PASSWORD = os.getenv('NODE_USERNAME_PASSWORD')
DOCKER_USERNAME = os.getenv('DOCKER_USERNAME')
DOCKER_IMAGE_NAME = os.getenv('DOCKER_IMAGE_NAME')
VERSION = os.getenv("VERSION")
for IPADDRESS in NODE_IPADDRESSES:
s = pxssh.pxssh()
s.login(IPADDRESS, NODE_USERNAME)
s.sendline(
f'echo {NODE_USERNAME_PASSWORD} | sudo -k -S sudo docker pull {DOCKER_USERNAME}/{DOCKER_IMAGE_NAME}:{VERSION}')
s.prompt()
print(s.before.decode('utf-8'))
s.logout()
print("done")
# # CLEANUP ########################################################################################################
# s.sendline('rm .bash_history')
# s.prompt()
# print(s.before.decode('utf-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment