コード例 #1
0
ファイル: wrapper.py プロジェクト: matthewa24/ansible-apache
def setup_instance():
    reservation = conn.run_instances(
        options.get_ami_id(),
        instance_type=options.get_instance_type(),
        key_name=options.get_ssh_key(),
        security_groups=[options.get_security_group()])
    reservation.instances[0].add_tag('Name', value=options.get_instance_name())
    return wait_for_ip(reservation.id)
コード例 #2
0
ファイル: wrapper.py プロジェクト: matthewa24/ansible-apache
def wait_for_ssh(ip_address):
  print options.YELLOW, "waiting for SSH access", options.WHITE
  e_code = 1
  while e_code != 0:
    p = subprocess.Popen(["ssh", "-i", options.get_ssh_key() + ".pem", options.get_ssh_user() + "@" + ip_address, "hostname"])
    e_code = p.wait()
    time.sleep(1)
  print options.GREEN, "SSH access obtained", options.GREEN
コード例 #3
0
ファイル: wrapper.py プロジェクト: matthewa24/ansible-apache
def configure_instance(ip_address):
  setup_ansible_hosts(ip_address)
  print options.YELLOW, "configuring instance:", ip_address, options.WHITE
  proc = subprocess.Popen(['ansible-playbook', '--private-key', options.get_ssh_key() + ".pem", '-u', options.get_ssh_user(), '-i', 'sample.hosts', 'apache2.yml'], stdout=subprocess.PIPE)
  exit_code = proc.wait()
  if exit_code == 0:
    print options.GREEN, "successfully configured the instance at:", options.WHITE, ip_address
  else:
    print options.RED, "failed to configure the instance at:", options.WHITE, ip_address
コード例 #4
0
ファイル: wrapper.py プロジェクト: matthewa24/ansible-apache
def wait_for_ssh(ip_address):
    print options.YELLOW, "waiting for SSH access", options.WHITE
    e_code = 1
    while e_code != 0:
        p = subprocess.Popen([
            "ssh", "-i",
            options.get_ssh_key() + ".pem",
            options.get_ssh_user() + "@" + ip_address, "hostname"
        ])
        e_code = p.wait()
        time.sleep(1)
    print options.GREEN, "SSH access obtained", options.GREEN
コード例 #5
0
ファイル: wrapper.py プロジェクト: matthewa24/ansible-apache
def configure_instance(ip_address):
    setup_ansible_hosts(ip_address)
    print options.YELLOW, "configuring instance:", ip_address, options.WHITE
    proc = subprocess.Popen([
        'ansible-playbook', '--private-key',
        options.get_ssh_key() + ".pem", '-u',
        options.get_ssh_user(), '-i', 'sample.hosts', 'apache2.yml'
    ],
                            stdout=subprocess.PIPE)
    exit_code = proc.wait()
    if exit_code == 0:
        print options.GREEN, "successfully configured the instance at:", options.WHITE, ip_address
    else:
        print options.RED, "failed to configure the instance at:", options.WHITE, ip_address
コード例 #6
0
ファイル: wrapper.py プロジェクト: matthewa24/ansible-apache
def setup_instance():
  reservation = conn.run_instances(options.get_ami_id(), instance_type=options.get_instance_type(), key_name=options.get_ssh_key(), security_groups=[options.get_security_group()])
  reservation.instances[0].add_tag('Name', value=options.get_instance_name())
  return wait_for_ip(reservation.id)