Merge branch 'master' of /git/ansible

This commit is contained in:
Peter Robinson 2015-03-25 16:56:02 +00:00
commit 4dd3d9b3b0
6 changed files with 56 additions and 23 deletions

View file

@ -49,30 +49,52 @@ def image_name_to_id(host_vars, user, password, tenant, auth_url):
raise errors.AnsibleFilterError('There is no image of name {0} accessible for tenant {1}'.format(host_vars, tenant))
def network_name_to_id(host_vars, user, password, tenant, auth_url):
""" Accept one name of network or list of names of networks and return the same
structure, but names replaced by ids of the network(s). """
auth = identity.Password(auth_url=auth_url, username=user,
password=password, tenant_name=tenant)
sess = session.Session(auth=auth)
token = auth.get_token(sess)
endpoint = auth.get_endpoint(sess, service_name='neutron', service_type='network')
neutron = NeutronClient('2.0', endpoint_url=endpoint, token=token)
networks = neutron.list_networks(name=host_vars, fields='id')["networks"]
if networks:
return networks[0]['id']
result_as_list = isinstance(host_vars, list)
if not result_as_list:
host_vars = [host_vars]
result = []
for net in host_vars:
networks = neutron.list_networks(name=net, fields='name')["networks"]
if networks:
result += [networks[0]['id']]
else:
raise errors.AnsibleFilterError('There is no network of name {0} accessible for tenant {1}'.format(host_vars, tenant))
if result_as_list:
return result
else:
raise errors.AnsibleFilterError('There is no network of name {0} accessible for tenant {1}'.format(host_vars, tenant))
return result[0]
def network_id_to_name(host_vars, user, password, tenant, auth_url):
""" Accept one id of network or list of ids of networks and return the same
structure, but ids replaced by name of the network(s). """
auth = identity.Password(auth_url=auth_url, username=user,
password=password, tenant_name=tenant)
sess = session.Session(auth=auth)
token = auth.get_token(sess)
endpoint = auth.get_endpoint(sess, service_name='neutron', service_type='network')
neutron = NeutronClient('2.0', endpoint_url=endpoint, token=token)
networks = neutron.list_networks(id=host_vars, fields='name')["networks"]
if networks:
return networks[0]['name']
result_as_list = isinstance(host_vars, list)
if not result_as_list:
host_vars = [host_vars]
result = []
for net in host_vars:
networks = neutron.list_networks(id=net, fields='name')["networks"]
if networks:
result += [networks[0]['name']]
else:
raise errors.AnsibleFilterError('There is no network of id {0} accessible for tenant {1}'.format(host_vars, tenant))
if result_as_list:
return result
else:
raise errors.AnsibleFilterError('There is no network of id {0} accessible for tenant {1}'.format(host_vars, tenant))
return result[0]
class FilterModule (object):
def filters(self):

View file

@ -1,11 +1,12 @@
---
instance_type: m1.xlarge
image: "{{ f20_qcow_id }}"
keypair: fedora-admin-20130801
#image: "{{ f20_qcow_id }}"
image: "Fedora-Cloud-Base-20141203-21"
keypair: msuchy
security_group: web-80-anywhere-persistent,web-443-anywhere-persistent,ssh-anywhere-persistent,default
zone: nova
hostbase: copr-be-dev-
public_ip: 209.132.184.179
public_ip: 209.132.184.53
root_auth_users: bkabrda msuchy tradej pingou vgologuz
description: copr dispatcher and repo server - dev instance
tcp_ports: ['22', '80', '443']
@ -14,6 +15,9 @@ volumes: [ {volume_id: 'b41e4d70-8f76-44b5-ab24-d91f02ae0afa', device: '/dev/vdc
inventory_tenant: persistent
# name of machine in OpenStack
inventory_instance_name: copr-be-dev
cloud_networks:
- net-id: persistent-net
- net-id: copr-net
# Copr vars
copr_hostbase: copr-be-dev

View file

@ -190,13 +190,14 @@ rawhide-composer.phx2.fedoraproject.org
[composers-stg]
composer.stg.phx2.fedoraproject.org
# sign servers don't listen to ssh by default.
[sign-bridge]
sign-bridge01.phx2.fedoraproject.org
#
# sign vault servers don't listen to ssh by default.
#
[sign-vault]
#sign-vault03.phx2.fedoraproject.org
sign-vault04.phx2.fedoraproject.org
sign-vault03.phx2.fedoraproject.org
#sign-vault04.phx2.fedoraproject.org
[autosign]
autosign01.phx2.fedoraproject.org
@ -750,6 +751,10 @@ koschei.cloud.fedoraproject.org
# copr keygen instance
copr-keygen.cloud.fedoraproject.org
[new-cloud-experiments]
209.132.184.53
copr-be-dev.cloud.fedoraproject.org
[jenkins-slaves]
# EL-6 builder
209.132.184.165

View file

@ -1,12 +1,12 @@
- name: check/create instance
hosts: 209.132.184.49
hosts: copr-be-dev.cloud.fedoraproject.org
#hosts: copr-be-dev2.cloud.fedoraproject.org
#hosts: copr-back:copr-back-stg
#hosts: copr-back-stg
user: fedora
sudo: True
#user: root
gather_facts: True
gather_facts: False
# gather_facts: False
vars_files:
@ -32,12 +32,12 @@
# - include: "{{ tasks }}/persistent_cloud.yml"
# DEBUG OTHER
#- include: "{{ tasks }}/persistent_cloud_new.yml"
- include: "{{ tasks }}/persistent_cloud_new.yml"
- include: "{{ tasks }}/growroot_cloud.yml"
- debug: msg="root auth users {{root_auth_users}}"
- name: cloud basic setup
hosts: 209.132.184.49
hosts: 209.132.184.53
#hosts: copr-be-dev2.cloud.fedoraproject.org
#hosts: copr-back:copr-back-stg
#hosts: copr-back-stg
@ -56,7 +56,7 @@
shell: "hostname {{copr_hostbase}}.cloud.fedoraproject.org"
- name: provision instance
hosts: 209.132.184.49
hosts: 209.132.184.53
#hosts: copr-be-dev2.cloud.fedoraproject.org
#hosts: copr-back:copr-back-stg
#hosts: copr-back-stg

View file

@ -55,8 +55,10 @@ bodhi_server: {{ bodhi_server }}
## URL of ResultsDB server API interface, which can store all test results
resultsdb_server: {{ resultsdb_server }}
{% if deployment_type == 'dev' %}
## URL of ExecDB server API interface, which tracks task execution status
execdb_server: {{ execdb_server }}
{% endif %}
## URL of taskotron buildmaster
taskotron_master: {{ taskotron_master }}

View file

@ -8,7 +8,7 @@
# OS_TENANT_ID
# OS_TENANT_NAME
- debug: msg="Auth {{OS_AUTH_URL}} {{OS_TENANT_NAME}} {{OS_USERNAME}}"
#- debug: msg="Auth {{OS_AUTH_URL}} {{OS_TENANT_NAME}} {{OS_USERNAME}}"
# To use direct `nova` commands construct _OS_AUTH_OPTS as:
# --os-auth-url {{OS_AUTH_URL}} --os-username {{OS_USERNAME}} --os-password {{OS_PASSWORD}} --os-tenant-name {{OS_TENANT_NAME}} --os-tenant-id {{OS_TENANT_ID}}
@ -40,12 +40,12 @@
login_password: "{{ADMIN_PASS}}"
login_tenant_name: "{{inventory_tenant}}"
name: "{{inventory_instance_name}}"
image_id: "{{ image }}"
image_id: "{{ image|image_name_to_id('admin', ADMIN_PASS, inventory_tenant, os_auth_url) }}"
wait_for: 300
flavor_id: "{{ instance_type|flavor_name_to_id('admin', ADMIN_PASS, inventory_tenant, os_auth_url) }}
flavor_id: "{{ instance_type|flavor_name_to_id('admin', ADMIN_PASS, inventory_tenant, os_auth_url) }}"
security_groups: "{{security_group}}"
key_name: "{{ keypair }}"
nics: "{{ cloud_networks }}"
nics: "{{ cloud_networks|network_name_to_id('admin', ADMIN_PASS, inventory_tenant, os_auth_url) }}"
# floating_ip_pools: "{{ floating_ip_pools }}"
floating_ips:
- "{{public_ip}}"