Make the role assignment step optional in the deployment (#271)

This commit is contained in:
Cheick Keita
2020-11-10 06:11:34 -08:00
committed by GitHub
parent 4cafee9bbf
commit 81a04ed81d

View File

@ -116,6 +116,7 @@ class Client:
migrations, migrations,
export_appinsights: bool, export_appinsights: bool,
log_service_principal: bool, log_service_principal: bool,
upgrade: bool,
): ):
self.resource_group = resource_group self.resource_group = resource_group
self.arm_template = arm_template self.arm_template = arm_template
@ -127,6 +128,7 @@ class Client:
self.instance_specific = instance_specific self.instance_specific = instance_specific
self.third_party = third_party self.third_party = third_party
self.create_registration = create_registration self.create_registration = create_registration
self.upgrade = upgrade
self.results = { self.results = {
"client_id": client_id, "client_id": client_id,
"client_secret": client_secret, "client_secret": client_secret,
@ -400,9 +402,14 @@ class Client:
sys.exit(1) sys.exit(1)
self.results["deploy"] = result.properties.outputs self.results["deploy"] = result.properties.outputs
def assign_scaleset_identity_role(self):
if self.upgrade:
logger.info("Upgrading: skipping assignment of the managed identity role")
return
logger.info("assigning the user managed identity role") logger.info("assigning the user managed identity role")
assign_scaleset_role( assign_scaleset_role(
self.application_name, self.results["deploy"]["scaleset-identity"]["value"] self.application_name,
self.results["deploy"]["scaleset-identity"]["value"],
) )
def apply_migrations(self): def apply_migrations(self):
@ -703,6 +710,7 @@ def main():
("check_region", Client.check_region), ("check_region", Client.check_region),
("rbac", Client.setup_rbac), ("rbac", Client.setup_rbac),
("arm", Client.deploy_template), ("arm", Client.deploy_template),
("assign_scaleset_identity_role", Client.assign_scaleset_identity_role),
("apply_migrations", Client.apply_migrations), ("apply_migrations", Client.apply_migrations),
("queues", Client.create_queues), ("queues", Client.create_queues),
("eventgrid", Client.create_eventgrid), ("eventgrid", Client.create_eventgrid),
@ -772,6 +780,11 @@ def main():
help="Create an application registration and/or generate a " help="Create an application registration and/or generate a "
"password for the pool agent", "password for the pool agent",
) )
parser.add_argument(
"--upgrade",
action="store_true",
help="Indicates that the instance is being upgraded",
)
parser.add_argument( parser.add_argument(
"--apply_migrations", "--apply_migrations",
type=str, type=str,
@ -812,6 +825,7 @@ def main():
args.apply_migrations, args.apply_migrations,
args.export_appinsights, args.export_appinsights,
args.log_service_principal, args.log_service_principal,
args.upgrade,
) )
if args.verbose: if args.verbose:
level = logging.DEBUG level = logging.DEBUG