"""A Linode Python Pulumi program""" import pulumi import pulumi_linode import pulumi_command as command import pulumi_cloudflare as cloudflare import additional_configs import ansible config = pulumi.Config() hostname = config.require("hostname") domainname = config.require("domainname") # Create a Linode resource (Linode Instance) instance = pulumi_linode.Instance(hostname, type=config.require("linodeType"), region=config.require("linodeRegion"), image=config.require("linodeImage"), label=hostname, root_pass=additional_configs.DEFAULT_ROOT_PASSWORD, authorized_keys=additional_configs.SSH_KEYS, opts=pulumi.ResourceOptions( custom_timeouts=pulumi.CustomTimeouts(create="2m") ) ) zone = cloudflare.get_zone(name=domainname) dnsrecord = cloudflare.Record(hostname, name=hostname, zone_id=zone.id, type="A", content=instance.ip_address, comment=f"Pulumi-generated linode" ) environment = { 'name': hostname, 'hostname': hostname + '.' + domainname, } adeploy = ansible.AnsibleDeployment(instance, environment, config.get('playbooks')) adeploy.create_inventory() adeploy.run_playbooks() # Export the Instance label of the instance pulumi.export('ip_address', instance.ip_address)