from ipgetter2 import IPGetter
from troposphere import (
    Base64,
    ec2,
    GetAtt,
    Join,
    Output,
    Parameter,
    Ref,
    Template,
)
from troposphere.iam import (InstanceProfile, PolicyType as IAMPolicy, Role)
from awacs.aws import (Action, Allow, Policy, Principal, Statement)
from awacs.sts import AssumeRole

getter = IPGetter()

ApplicationName = "nodeserver"
ApplicationPort = "3000"
GithubAccount = "garbhsoft"
GithubAnsibleUrl = "https://github.com/{}/ansible".format(GithubAccount)
AnsiblePullCmd = "/usr/bin/ansible-pull -U {} {}.yml -i localhost".format(
    GithubAnsibleUrl, ApplicationName)
PublicCidrIp = str(ip_network(getter.get().v4))

t = Template()

t.set_description("Effective DevOps in AWS: HelloWorld web application")

t.add_parameter(
    Parameter(
def getter():
    return IPGetter()
示例#3
0
from ipgetter2 import IPGetter  # import ipgetter module

getter = IPGetter()


# myip function.
def myip():
    return str(getter.get().v4)  # return ip.
if CloudflareDnsRecordId is None:
    logger.critical('Could not resolve ' + config['General']['dynamic_cname'] +
                    ' to a Cloudflare dns id!')
    exit(1)
CloudflareDynDnsRecordId = None
if config['DynDns']['dyndns_target'] != 'no':
    CloudflareDynDnsRecordId = resolveNameToRecordId(
        config, config['DynDns']['dyndns_target'])
    if CloudflareDnsRecordId is None:
        logger.critical('Could not resolve ' +
                        config['DynDns']['dyndns_target'] +
                        ' to a Cloudflare dns id!')
        exit(2)

logger.info('Startup complete.')
getter = IPGetter()
getter.timeout = int(config['General']['external_timeout'])
primaryConfidence = int(int(config['Primary']['confidence']) / 2)
primaryActive = False
primarySubnetSet = config['Primary']['subnet'] != 'no'
secondarySubnetSet = config['Secondary']['subnet'] != 'no'
if primarySubnetSet:
    primarySubnet = ipaddress.ip_network(config['Primary']['subnet'])
if secondarySubnetSet:
    secondarySubnet = ipaddress.ip_network(config['Secondary']['subnet'])
bothSubnetSet = not (primarySubnetSet ^ secondarySubnetSet)
oldExternalIPv4 = None
try:
    while True:
        # Get the external ip and validate primary cname allowance
        try:
示例#5
0
def ip(update, context):
    getter = IPGetter()
    ips=getter.get()
    update.message.reply_text('Your ips:\n v4:{0}\n v6:{1}'.format(ips.v4,ips.v6))