Created
April 12, 2020 07:23
-
-
Save nohtyp/99dfa2771945a1a24deb2501ba03e4f4 to your computer and use it in GitHub Desktop.
To update launch configurations using a script, this is a prototype of the script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import re | |
import os | |
import boto3 | |
ssm_client = boto3.client('ssm') | |
zones = { 'us-east-1a': {'pbs-master-node-1a':'pbs-master-node-1a-lc', 'pbs-worker-node-1a':'pbs-worker-node-1a-lc'}, | |
'us-east-1b': {'pbs-master-node-1b':'pbs-master-node-1b-lc','pbs-worker-node-1b':'pbs-worker-node-1b-lc'} | |
} | |
worker=ssm_client.get_parameter(Name='latest_pbspro_node_ami_id').get('Parameter').get('Value') | |
master=ssm_client.get_parameter(Name='latest_pbspro_master_ami_id').get('Parameter').get('Value') | |
az = sys.argv[1] | |
name = sys.argv[2] | |
for i in zones.get(az): | |
#print(i, availability_zone.get(az).get(i)) | |
#print(availability_zone.get(az).get(i)) | |
#print(i + '-ag') | |
if i == 'pbs-master-node-1a': | |
os.system("python3 copy_launch_configurations.py create --name " + name + " --copy-from " + zones.get(az).get(i) + " --ami-id " + master + " --update-ag " + i + '-ag ' + '--azs ' + az) | |
elif i == 'pbs-master-node-1b': | |
os.system("python3 copy_launch_configurations.py create --name " + name + " --copy-from " + zones.get(az).get(i) + " --ami-id " + master + " --update-ag " + i + '-ag ' + '--azs ' + az) | |
elif i == 'pbs-worker-node-1a': | |
os.system("python3 copy_launch_configurations.py create --name " + name + " --copy-from " + zones.get(az).get(i) + " --ami-id " + worker + " --update-ag " + i + '-ag ' + '--azs ' + az) | |
elif i == 'pbs-worker-node-1b': | |
os.system("python3 copy_launch_configurations.py create --name " + name + " --copy-from " + zones.get(az).get(i) + " --ami-id " + worker + " --update-ag " + i + '-ag ' + '--azs ' + az) | |
else: | |
print("The server is not one of the systems managed") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment