def make_template(num_masters, gen_arguments, varietal, bootstrap_variant_prefix): ''' Return a tuple: the generated template for num_masters and the artifact dict. @param num_masters: int, number of master nodes to embed in the generated template @param gen_arguments: dict, args to pass to the gen library. These are user input arguments which get filled in/prompted for. @param varietal: string, indicate template varietal to build for either 'acs' or 'dcos' ''' master_list_source = Source() master_list_source.add_must('master_list', Late(master_list_arm_json(num_masters, varietal))) master_list_source.add_must('num_masters', str(num_masters)) if varietal == 'dcos': arm, results = gen_templates( gen_arguments, 'azuredeploy', extra_sources=[master_list_source, azure_dcos_source]) elif varietal == 'acs': arm, results = gen_templates( gen_arguments, 'acs', extra_sources=[master_list_source, azure_acs_source]) else: raise ValueError("Unknown Azure varietal specified") yield {'packages': util.cluster_to_extra_packages(results.cluster_packages)} yield { 'channel_path': 'azure/{}{}-{}master.azuredeploy.json'.format(bootstrap_variant_prefix, varietal, num_masters), 'local_content': arm, 'content_type': 'application/json; charset=utf-8' }
aws_base_source = Source( entry={ 'validate': [validate_provider], 'default': { 'platform': 'aws', 'resolvers': '["169.254.169.253"]', 'num_private_slaves': '5', 'num_public_slaves': '1', 'os_type': '', 'aws_masters_have_public_ip': 'true', 'enable_docker_gc': 'true' }, 'must': { 'aws_region': Late('{ "Ref" : "AWS::Region" }'), 'aws_stack_id': Late('{ "Ref" : "AWS::StackId" }'), 'aws_stack_name': Late('{ "Ref" : "AWS::StackName" }'), 'ip_detect_contents': get_ip_detect('aws'), 'ip_detect_public_contents': calculate_ip_detect_public_contents, 'ip6_detect_contents': get_ip_detect('aws6'), 'exhibitor_explicit_keys': 'false', 'cluster_name': Late('{ "Ref" : "AWS::StackName" }'), 'master_discovery':
'{{ master_cloud_config }}', 'slave_cloud_config': '{{ slave_cloud_config }}', 'slave_public_cloud_config': '{{ slave_public_cloud_config }}', 'fault_domain_detect_contents': yaml.dump( pkg_resources.resource_string( 'gen', 'fault-domain-detect/cloud.sh').decode()) }, 'conditional': { 'oauth_available': { 'true': { 'must': { 'oauth_enabled': Late("[[[variables('oauthEnabled')]]]"), 'adminrouter_auth_enabled': Late("[[[variables('oauthEnabled')]]]"), } }, 'false': {}, }, 'licensing_enabled': { 'true': { 'must': { 'license_key_contents': Late("[[[variables('licenseKey')]]]"), }, 'secret': [ 'license_key_contents', ],
aws_base_source = Source( entry={ 'validate': [validate_provider], 'default': { 'platform': 'aws', 'resolvers': '["169.254.169.253"]', 'num_private_slaves': '5', 'num_public_slaves': '1', 'os_type': '', 'aws_masters_have_public_ip': 'true', 'enable_docker_gc': 'true' }, 'must': { 'aws_region': Late('{ "Ref" : "AWS::Region" }'), 'aws_stack_id': Late('{ "Ref" : "AWS::StackId" }'), 'aws_stack_name': Late('{ "Ref" : "AWS::StackName" }'), 'ip_detect_contents': get_ip_detect('aws'), 'ip_detect_public_contents': calculate_ip_detect_public_contents, 'exhibitor_explicit_keys': 'false', 'cluster_name': Late('{ "Ref" : "AWS::StackName" }'), 'master_discovery': 'master_http_loadbalancer', # The cloud_config template variables pertaining to "cloudformation.json" 'master_cloud_config': '{{ master_cloud_config }}', 'agent_private_cloud_config': '{{ slave_cloud_config }}', 'agent_public_cloud_config': '{{ slave_public_cloud_config }}', # template variable for the generating advanced template cloud configs 'cloud_config': '{{ cloud_config }}', 'rexray_config_preset': 'aws' },
aws_base_source = Source(entry={ 'validate': [ validate_provider ], 'default': { 'platform': 'aws', 'resolvers': '["169.254.169.253"]', 'num_private_slaves': '5', 'num_public_slaves': '1', 'os_type': '', 'aws_masters_have_public_ip': 'true', 'enable_docker_gc': 'true' }, 'must': { 'aws_region': Late('{ "Ref" : "AWS::Region" }'), 'aws_stack_id': Late('{ "Ref" : "AWS::StackId" }'), 'aws_stack_name': Late('{ "Ref" : "AWS::StackName" }'), 'ip_detect_contents': get_ip_detect('aws'), 'ip_detect_public_contents': calculate_ip_detect_public_contents, 'exhibitor_explicit_keys': 'false', 'cluster_name': Late('{ "Ref" : "AWS::StackName" }'), 'master_discovery': 'master_http_loadbalancer', # The cloud_config template variables pertaining to "cloudformation.json" 'master_cloud_config': '{{ master_cloud_config }}', 'agent_private_cloud_config': '{{ slave_cloud_config }}', 'agent_public_cloud_config': '{{ slave_public_cloud_config }}', # template variable for the generating advanced template cloud configs 'cloud_config': '{{ cloud_config }}', 'rexray_config_preset': 'aws', 'fault_domain_detect_contents': yaml.dump(
'enable_docker_gc': 'true' }, 'must': { 'resolvers': '["168.63.129.16"]', 'ip_detect_contents': yaml.dump(pkg_resources.resource_string('gen', 'ip-detect/azure.sh').decode()), 'master_discovery': 'static', 'exhibitor_storage_backend': 'azure', 'master_cloud_config': '{{ master_cloud_config }}', 'slave_cloud_config': '{{ slave_cloud_config }}', 'slave_public_cloud_config': '{{ slave_public_cloud_config }}', }, 'conditional': { 'oauth_available': { 'true': { 'must': { 'oauth_enabled': Late("[[[variables('oauthEnabled')]]]"), 'adminrouter_auth_enabled': Late("[[[variables('oauthEnabled')]]]"), } }, 'false': {}, } } }) def validate_cloud_config(cc_string): ''' Validate that there aren't any single quotes present since they break the ARM template system. Exit with an error message if any invalid characters are detected.