Ansible Module substitute for Shell Commands 63/27163/9
authorliyuenan <liyuenan@huawei.com>
Wed, 18 Jan 2017 10:05:27 +0000 (18:05 +0800)
committerliyuenan <liyuenan@huawei.com>
Wed, 25 Jan 2017 04:37:20 +0000 (12:37 +0800)
JIRA: COMPASS-520

After update ansible version to v3, keystone_user module only support v2 API.
So we use Shell Commands now, but it will failed with high probability.
Those Shell Commands should be instead by ansible modules to manage Identity users,
projects or some other work like crate networks.

Change-Id: I63d38b4a811a9c063ac4404da72787f594411b53
Signed-off-by: liyuenan <liyuenan@huawei.com>
17 files changed:
build.sh
build/build.conf
deploy/adapters/ansible/ansible_modules/keystone_endpoint.py [new file with mode: 0755]
deploy/adapters/ansible/roles/ext-network/tasks/main.yml
deploy/adapters/ansible/roles/heat/tasks/heat_install.yml
deploy/adapters/ansible/roles/keystone/tasks/keystone_create.yml
deploy/adapters/ansible/roles/keystone/tasks/keystone_install.yml
deploy/adapters/ansible/roles/keystone/tasks/main.yml
deploy/adapters/ansible/roles/keystone/templates/clouds.yml.j2 [new file with mode: 0644]
deploy/adapters/ansible/roles/keystone/vars/main.yml
deploy/adapters/ansible/roles/nova-controller/tasks/nova_config.yml
deploy/adapters/ansible/roles/openstack-post/tasks/main.yml
deploy/adapters/ansible/roles/openstack-post/vars/main.yml [new file with mode: 0644]
deploy/compass_conf/templates/ansible_installer/openstack_newton/ansible_cfg/HA-ansible-multinodes.tmpl
deploy/deploy_host.sh
repo/pip/extra-requirement-tar.txt
repo/pip/extra-requirement-wheel.txt

index 249e6e5..3dfd54f 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -87,7 +87,7 @@ function download_packages()
 {
      for i in $CENTOS_BASE $LOADERS $CIRROS $APP_PACKAGE \
               $COMPASS_CORE $COMPASS_WEB $COMPASS_INSTALL $COMPASS_PKG \
-              $PIP_REPO $PIP_OPENSTACK_REPO $ANSIBLE_MODULE \
+              $PIP_REPO $PIP_OPENSTACK_REPO \
               $UBUNTU_ISO $CENTOS_ISO $XENIAL_NEWTON_PPA $CENTOS7_NEWTON_PPA; do
 
          if [[ ! $i ]]; then
@@ -134,7 +134,6 @@ function copy_file()
 
     cp $CACHE_DIR/`basename $LOADERS` $new/ -rf || exit 1
     cp $CACHE_DIR/`basename $APP_PACKAGE` $new/app_packages/ -rf || exit 1
-    cp $CACHE_DIR/`basename $ANSIBLE_MODULE | sed 's/.git//g'`  $new/ansible/ -rf || exit 1
 
     if [[ $CIRROS ]]; then
         cp $CACHE_DIR/`basename $CIRROS` $new/guestimg/ -rf || exit 1
index 2699eb7..68fc1cf 100644 (file)
@@ -15,7 +15,6 @@ export COMPASS_INSTALL=${COMPASS_INSTALL:-http://github.com/baigk/compass-instal
 export COMPASS_PKG=${COMPASS_PKG:-$PACKAGE_URL/centos7-compass-core.tar.gz}
 export PIP_REPO=${PIP_REPO:-$PACKAGE_URL/pip.tar.gz}
 export PIP_OPENSTACK_REPO=${PIP_OPENSTACK_REPO:-$PACKAGE_URL/pip-openstack.tar.gz}
-export ANSIBLE_MODULE=${ANSIBLE_MODULE:-https://github.com/openstack-ansible/openstack-ansible-modules.git}
 
 # OS ISO for provisioning
 export CENTOS_ISO=${CENTOS_ISO:-$PACKAGE_URL/CentOS-7-x86_64-Minimal-1611.iso} # centos 7.3
diff --git a/deploy/adapters/ansible/ansible_modules/keystone_endpoint.py b/deploy/adapters/ansible/ansible_modules/keystone_endpoint.py
new file mode 100755 (executable)
index 0000000..0201dd2
--- /dev/null
@@ -0,0 +1,227 @@
+#!/usr/bin/python
+#
+# Copyright 2017 Huawei Technologies Co. Ltd
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+try:
+    import shade
+    HAS_SHADE = True
+except ImportError:
+    HAS_SHADE = False
+
+from distutils.version import StrictVersion
+from ansible.module_utils.basic import *  # noqa: F403
+from ansible.module_utils.openstack import *  # noqa: F403
+
+ANSIBLE_METADATA = {'status': ['preview'],
+                    'supported_by': 'community',
+                    'version': '1.0'}
+
+DOCUMENTATION = '''
+---
+module: keystone_endpoint
+short_description: Manage OpenStack endpoint
+extends_documentation_fragment: openstack
+author: "Yuenan Li"
+version_added: "2.2"
+description:
+    - Create, update, or delete OpenStack endpoint.
+options:
+   name:
+     description:
+        - Name of the endpoint
+     required: true
+   service_type:
+     description:
+        - The type of service
+     required: true
+   enabled:
+     description:
+        - Is the endpoint enabled
+     required: false
+     default: True
+   interface:
+     description:
+        - Interface type of the endpoint
+     required: false
+   url:
+     description:
+        - URL of the endpoint
+     required: true
+   region:
+     description:
+       - Endpoint region
+   state:
+     description:
+       - Should the resource be present or absent
+     choices: [present, absent]
+     default: present
+requirements:
+    - "python >= 2.6"
+    - "shade"
+'''
+
+EXAMPLES = '''
+# Create a endpoint for glance
+- keystone_endpoint:
+     cloud: mycloud
+     state: present
+     name: glance
+     admin_url: http://172.16.1.222:9292
+     internal_url: http://172.16.1.222:9292
+     public_url: http://172.16.1.222:9292
+'''
+
+RETURN = '''
+endpoint:
+    description: Dictionary describing the endpoint.
+    returned: On success when state is 'present'
+    type: dictionary
+    contains:
+        id:
+            description: endpoint ID.
+            type: string
+            sample: "3292f020780b4d5baf27ff7e1d224c44"
+        name:
+            description: endpoint name.
+            type: string
+            sample: "glance"
+        interface:
+            description: Interface type.
+            type: string
+            sample: "admin"
+        url:
+            description: URL.
+            type: string
+            sample: "http://172.16.1.222:9292"
+id:
+    description: The endpoint ID.
+    returned: On success when state is 'present'
+    type: string
+    sample: "3292f020780b4d5baf27ff7e1d224c44"
+'''
+
+
+def _needs_update(module, endpoint):
+    if endpoint.url != module.params['url'] and \
+       endpoint.interface == module.params['interface']:
+        return True
+    return False
+
+
+def _system_state_change(module, endpoint):
+    state = module.params['state']
+    if state == 'absent' and endpoint:
+        return True
+
+    if state == 'present':
+        if endpoint is None:
+            return True
+        return _needs_update(module, endpoint)
+
+    return False
+
+
+def main():
+    argument_spec = openstack_full_argument_spec(  # noqa: F405
+        enabled=dict(default=True, type='bool'),
+        name=dict(required=True),
+        service_type=dict(required=True),
+        state=dict(default='present', choices=['absent', 'present']),
+        region=dict(default=None, required=False),
+        interface=dict(default=None,
+                       choices=['admin', 'internal', 'public']),
+        url=dict(default=None, required=False),
+    )
+
+    module_kwargs = openstack_module_kwargs()  # noqa: F405
+    module = AnsibleModule(argument_spec,  # noqa: F405
+                           supports_check_mode=True,
+                           **module_kwargs)
+
+    if not HAS_SHADE:
+        module.fail_json(msg='shade is required for this module')
+    if StrictVersion(shade.__version__) < StrictVersion('1.6.0'):
+        module.fail_json(msg="To utilize this module, the installed version of"
+                             "the shade library MUST be >=1.6.0")
+
+    enabled = module.params['enabled']  # noqa: F841
+    name = module.params['name']
+    service_type = module.params['service_type']
+    state = module.params['state']
+    region = module.params['region']
+    interface = module.params['interface']
+    url = module.params['url']
+
+    try:
+        cloud = shade.operator_cloud(**module.params)
+
+        services = cloud.search_services(name_or_id=name,
+                                         filters=dict(type=service_type))
+
+        if len(services) > 1:
+            module.fail_json(msg='Service name %s and type %s are not unique' %
+                             (name, service_type))
+        elif len(services) == 0:
+            module.fail_json(msg="No services with name %s" % name)
+        else:
+            service = services[0]
+
+        endpoints = [x for x in cloud.list_endpoints()
+                     if (x.service_id == service.id and
+                         x.interface == interface)]
+
+        count = len(endpoints)
+        if count > 1:
+            module.fail_json(msg='%d endpoints with service name %s' %
+                             (count, name))
+        elif count == 0:
+            endpoint = None
+        else:
+            endpoint = endpoints[0]
+
+        if module.check_mode:
+            module.exit_json(changed=_system_state_change(module, endpoint))
+
+        if state == 'present':
+            if endpoint is None:
+                endpoint = cloud.create_endpoint(
+                    service_name_or_id=service.id, enabled=enabled,
+                    region=region, interface=interface, url=url)
+                changed = True
+            else:
+                if _needs_update(module, endpoint):
+                    endpoint = cloud.update_endpoint(
+                        endpoint_id=endpoint.id, enabled=enabled,
+                        service_name_or_id=service.id, region=region,
+                        interface=interface, url=url)
+                    changed = True
+                else:
+                    changed = False
+            module.exit_json(changed=changed, endpoint=endpoint)
+
+        elif state == 'absent':
+            if endpoint is None:
+                changed = False
+            else:
+                cloud.delete_endpoint(endpoint.id)
+                changed = True
+            module.exit_json(changed=changed)
+
+    except shade.OpenStackCloudException as e:
+        module.fail_json(msg=str(e))
+
+
+if __name__ == '__main__':
+    main()
index d212dd9..b73bb0a 100644 (file)
   wait_for: port=9696 delay=10 timeout=60 host={{ internal_ip }}
 
 - name: create external net
-  shell:
-    . /opt/admin-openrc.sh;
-    neutron net-create \
-        {{ public_net_info.network }} \
-        --provider:network_type {{ public_net_info.type }} \
-        --provider:physical_network {{ public_net_info.provider_network }} \
-        --router:external "True"
+  os_network:
+    cloud: opnfv
+    name: "{{ public_net_info.network }}"
+    provider_network_type: "{{ public_net_info.type }}"
+    provider_physical_network: "{{ public_net_info.provider_network }}"
+    shared: false
+    external: "yes"
+    state: present
+  run_once: true
   when: public_net_info.enable == "True"
-        and inventory_hostname == groups['controller'][0]
+        and public_net_info.type == "flat"
+
+- name: create external net
+  os_network:
+    cloud: opnfv
+    name: "{{ public_net_info.network }}"
+    provider_network_type: "{{ public_net_info.type }}"
+    provider_physical_network: "{{ public_net_info.provider_network }}"
+    provider_segmentation_id: "{{ public_net_info.segment_id }}"
+    shared: false
+    external: "yes"
+    state: present
+  run_once: true
+  when: public_net_info.enable == "True"
+        and public_net_info.type != "flat"
 
 - name: create external subnet
-  shell:
-    . /opt/admin-openrc.sh;
-    neutron subnet-create \
-        --name {{ public_net_info.subnet }} \
-        --gateway {{ public_net_info.external_gw }} \
-        --disable-dhcp \
-        --allocation-pool \
-        start={{ public_net_info.floating_ip_start }},end={{ public_net_info.floating_ip_end }} \
-        {{ public_net_info.network }} {{ public_net_info.floating_ip_cidr }}
+  os_subnet:
+    cloud: opnfv
+    name: "{{ public_net_info.subnet }}"
+    network_name: "{{ public_net_info.network }}"
+    cidr: "{{ public_net_info.floating_ip_cidr }}"
+    enable_dhcp: "{{ public_net_info.enable_dhcp }}"
+    no_gateway_ip: "{{ public_net_info.no_gateway }}"
+    gateway_ip: "{{ public_net_info.external_gw }}"
+    allocation_pool_start: "{{ public_net_info.floating_ip_start }}"
+    allocation_pool_end: "{{ public_net_info.floating_ip_end }}"
+    state: present
+  run_once: true
   when: public_net_info.enable == "True"
-        and inventory_hostname == groups['controller'][0]
index fd0f6ea..2803a3e 100644 (file)
   lineinfile: dest=/opt/service create=yes line='{{ item }}'
   with_items: "{{ services | union(services_noarch) }}"
 
-- name: create heat user domain
-  shell: |
-    . /opt/admin-openrc.sh;
-    openstack domain create --description "Stack projects and users" heat;
-    openstack user create --domain heat --password {{ HEAT_PASS }} \
-        heat_domain_admin;
-    openstack role add --domain heat --user-domain heat \
-        --user heat_domain_admin admin;
-    openstack role create heat_stack_owner;
-    openstack role add --project demo --user demo heat_stack_owner;
+- name: create heat domain
+  os_keystone_domain:
+    cloud: opnfv
+    name: heat
+    state: present
+    description: "Stack projects and users"
+  when: inventory_hostname == groups['controller'][0]
+
+- name: create heat user
+  os_user:
+    cloud: opnfv
+    domain: heat
+    name: heat_domain_user
+    password: "{{ HEAT_PASS }}"
+  when: inventory_hostname == groups['controller'][0]
+
+- name: create heat role
+  os_keystone_role:
+    cloud: opnfv
+    name: heat_stack_owner
+  when: inventory_hostname == groups['controller'][0]
+
+- name: grant heat role
+  os_user_role:
+    cloud: opnfv
+    user: demo
+    project: demo
+    role: heat_stack_owner
   when: inventory_hostname == groups['controller'][0]
 
 - name: update heat conf
index 2f5aefe..1022895 100644 (file)
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 ---
-- name: set keystone endpoint
-  shell:
-    . /opt/admin-openrc.sh;
-    openstack endpoint set \
-        --interface public \
-        --url {{ item.publicurl }} \
-        $(openstack endpoint list | grep keystone | grep public \
-        | awk '{print $2}');
-    openstack endpoint set \
-        --interface internal \
-        --url {{ item.internalurl }} \
-        $(openstack endpoint list | grep keystone | grep internal \
-        | awk '{print $2}');
-    openstack endpoint set \
-        --interface admin \
-        --url {{ item.adminurl }} \
-        $(openstack endpoint list | grep keystone | grep admin \
-        | awk '{print $2}');
+- name: set admin url for keystone endpoint
+  keystone_endpoint:
+    cloud: opnfv
+    endpoint_type: admin
+    name: "{{ item.name }}"
+    service_type: "{{ item.type }}"
+    state: present
+    interface: admin
+    region: "{{ item.region}}"
+    url: "{{ item.adminurl }}"
+  with_items: "{{ os_services[0:1] }}"
+
+- name: set internal url for keystone endpointl
+  keystone_endpoint:
+    cloud: opnfv
+    endpoint_type: admin
+    name: "{{ item.name }}"
+    service_type: "{{ item.type }}"
+    state: present
+    interface: internal
+    region: "{{ item.region}}"
+    url: "{{ item.internalurl }}"
+  with_items: "{{ os_services[0:1] }}"
+
+- name: set public url for keystone endpoint
+  keystone_endpoint:
+    cloud: opnfv
+    endpoint_type: admin
+    name: "{{ item.name }}"
+    service_type: "{{ item.type }}"
+    state: present
+    interface: public
+    region: "{{ item.region}}"
+    url: "{{ item.publicurl }}"
   with_items: "{{ os_services[0:1] }}"
-  register: result
-  until: result.rc == 0
-  retries: 10
-  delay: 5
 
 - name: add service
-  shell:
-    . /opt/admin-openrc.sh;
-    openstack service create \
-        --name "{{ item.name }}"
-        --description "{{ item.description }}" \
-        {{ item.type }}
-  with_items: "{{ os_services[1:] }}"
-  register: result
-  until: result.rc == 0
-  retries: 10
-  delay: 5
+  os_keystone_service:
+    cloud: opnfv
+    name: "{{ item.name }}"
+    description: "{{ item.description }}"
+    service_type: "{{ item.type }}"
+  with_items: "{{ os_services }}"
 
 - name: add project
-  shell:
-    . /opt/admin-openrc.sh;
-    openstack project create --description "Service Project" service;
-    openstack project create --domain default --description "Demo Project" demo;
-  register: result
-  until: result.rc == 0
-  retries: 10
-  delay: 5
-
-- name: set admin user
-  shell:
-    . /opt/admin-openrc.sh;
-    openstack user set \
-        --email "{{ item.email }}" \
-        --project "{{ item.tenant }}" \
-        --description "{{ item.tenant_description }}" \
-        --password "{{ item.password }}" \
-        {{ item.user }}
+  os_project:
+    cloud: opnfv
+    domain_id: default
+    name: "{{ item.tenant }}"
+    description: "{{ item.tenant_description }}"
   with_items: "{{ os_users }}"
-  when: item["user"] == "admin"
-  register: result
-  until: result.rc == 0
-  retries: 10
-  delay: 5
 
 - name: add user
-  shell:
-    . /opt/admin-openrc.sh;
-    openstack user create \
-        --email "{{ item.email }}" \
-        --project "{{ item.tenant }}" \
-        --description "{{ item.tenant_description }}" \
-        --password "{{ item.password }}" \
-        {{ item.user }}
-  with_items: "{{ os_users[1:] }}"
-  register: result
-  until: result.rc == 0
-  retries: 10
-  delay: 5
+  os_user:
+    cloud: opnfv
+    domain: default
+    name: "{{ item.user }}"
+    password: "{{ item.password }}"
+    default_project: "{{ item.tenant }}"
+    email: "{{ item.email }}"
+  with_items: "{{ os_users }}"
 
 - name: add roles
-  shell:
-    . /opt/admin-openrc.sh;
-    openstack role create {{ item.role }}
+  os_keystone_role:
+    cloud: opnfv
+    name: "{{ item.role }}"
   with_items: "{{ os_users }}"
-  when: item["user"] == "demo"
-  register: result
-  until: result.rc == 0
-  retries: 10
-  delay: 5
 
 - name: grant roles
-  shell:
-    . /opt/admin-openrc.sh;
-    openstack role add \
-        --project "{{ item.tenant }}" \
-        --user "{{ item.user }}" \
-        {{ item.role }}
+  os_user_role:
+    cloud: opnfv
+    user: "{{ item.user }}"
+    role: "{{ item.role }}"
+    project: "{{ item.tenant }}"
   with_items: "{{ os_users }}"
-  register: result
-  until: result.rc == 0
-  retries: 10
-  delay: 5
 
-- name: add endpoints
-  shell:
-    . /opt/admin-openrc.sh;
-    openstack endpoint create \
-        --region {{ item.region }} \
-        {{ item.name }} public {{ item.publicurl }};
-    openstack endpoint create \
-        --region {{ item.region }} \
-        {{ item.name }} internal {{ item.internalurl }};
-    openstack endpoint create \
-        --region {{ item.region }} \
-        {{ item.name }} admin {{ item.adminurl }};
+- name: create admin url for service's endpoint
+  keystone_endpoint:
+    cloud: opnfv
+    endpoint_type: admin
+    name: "{{ item.name }}"
+    service_type: "{{ item.type }}"
+    state: present
+    interface: admin
+    region: "{{ item.region}}"
+    url: "{{ item.adminurl }}"
+  with_items: "{{ os_services[1:] }}"
+
+- name: create internal url for service's endpoint
+  keystone_endpoint:
+    cloud: opnfv
+    endpoint_type: admin
+    name: "{{ item.name }}"
+    service_type: "{{ item.type }}"
+    state: present
+    interface: internal
+    region: "{{ item.region}}"
+    url: "{{ item.internalurl }}"
+  with_items: "{{ os_services[1:] }}"
+
+- name: create public url for service'e endpoint
+  keystone_endpoint:
+    cloud: opnfv
+    endpoint_type: admin
+    name: "{{ item.name }}"
+    service_type: "{{ item.type }}"
+    state: present
+    interface: public
+    region: "{{ item.region}}"
+    url: "{{ item.publicurl }}"
   with_items: "{{ os_services[1:] }}"
-  register: result
-  until: result.rc == 0
-  retries: 10
-  delay: 5
index 0d3161e..a390ffc 100644 (file)
   notify:
     - restart keystone services
 
+- name: install shade
+  pip: name=shade state=present
+
+- name: create path for os-client-config
+  file:
+    path: /etc/openstack
+    state: directory
+    mode: 0755
+
+- name: copy os-client-config
+  template:
+    src: clouds.yml.j2
+    dest: /etc/openstack/clouds.yml
+
 - name: keystone source files
   template: src={{ item }} dest=/opt/{{ item }}
   with_items:
     - admin-openrc.sh
     - admin-openrc-v2.sh
     - demo-openrc.sh
-
-- meta: flush_handlers
index ad619d4..29b6cd6 100644 (file)
     - keystone_config
     - keystone
 
+- meta: flush_handlers
+
 - include: keystone_create.yml
   when: inventory_hostname == groups['controller'][0]
   tags:
     - config
     - keystone_create
     - keystone
-
-- meta: flush_handlers
diff --git a/deploy/adapters/ansible/roles/keystone/templates/clouds.yml.j2 b/deploy/adapters/ansible/roles/keystone/templates/clouds.yml.j2
new file mode 100644 (file)
index 0000000..b387f7b
--- /dev/null
@@ -0,0 +1,12 @@
+---
+clouds:
+  opnfv:
+    auth:
+      username: 'admin'
+      password: {{ ADMIN_PASS }}
+      project_name: 'admin'
+      auth_url: 'http://{{ internal_vip.ip }}:35357/v3'
+      project_domain_name: default
+      user_domain_name: default
+    identity_api_version: 3
+    region_name: RegionOne
index 65ae409..2e5f57c 100644 (file)
@@ -32,9 +32,9 @@ os_services:
     type: compute
     region: RegionOne
     description: "OpenStack Compute"
-    publicurl: "http://{{ public_vip.ip }}:8774/v2.1/%\\(tenant_id\\)s"
-    internalurl: "http://{{ internal_vip.ip }}:8774/v2.1/%\\(tenant_id\\)s"
-    adminurl: "http://{{ internal_vip.ip }}:8774/v2.1/%\\(tenant_id\\)s"
+    publicurl: "http://{{ public_vip.ip }}:8774/v2.1/%(tenant_id)s"
+    internalurl: "http://{{ internal_vip.ip }}:8774/v2.1/%(tenant_id)s"
+    adminurl: "http://{{ internal_vip.ip }}:8774/v2.1/%(tenant_id)s"
 
   - name: neutron
     type: network
@@ -64,25 +64,25 @@ os_services:
     type: volume
     region: RegionOne
     description: "OpenStack Block Storage"
-    publicurl: "http://{{ public_vip.ip }}:8776/v1/%\\(tenant_id\\)s"
-    internalurl: "http://{{ internal_vip.ip }}:8776/v1/%\\(tenant_id\\)s"
-    adminurl: "http://{{ internal_vip.ip }}:8776/v1/%\\(tenant_id\\)s"
+    publicurl: "http://{{ public_vip.ip }}:8776/v1/%(tenant_id)s"
+    internalurl: "http://{{ internal_vip.ip }}:8776/v1/%(tenant_id)s"
+    adminurl: "http://{{ internal_vip.ip }}:8776/v1/%(tenant_id)s"
 
   - name: cinderv2
     type: volumev2
     region: RegionOne
     description: "OpenStack Block Storage v2"
-    publicurl: "http://{{ public_vip.ip }}:8776/v2/%\\(tenant_id\\)s"
-    internalurl: "http://{{ internal_vip.ip }}:8776/v2/%\\(tenant_id\\)s"
-    adminurl: "http://{{ internal_vip.ip }}:8776/v2/%\\(tenant_id\\)s"
+    publicurl: "http://{{ public_vip.ip }}:8776/v2/%(tenant_id)s"
+    internalurl: "http://{{ internal_vip.ip }}:8776/v2/%(tenant_id)s"
+    adminurl: "http://{{ internal_vip.ip }}:8776/v2/%(tenant_id)s"
 
   - name: heat
     type: orchestration
     region: RegionOne
     description: "OpenStack Orchestration"
-    publicurl: "http://{{ public_vip.ip }}:8004/v1/%\\(tenant_id\\)s"
-    internalurl: "http://{{ internal_vip.ip }}:8004/v1/%\\(tenant_id\\)s"
-    adminurl: "http://{{ internal_vip.ip }}:8004/v1/%\\(tenant_id\\)s"
+    publicurl: "http://{{ public_vip.ip }}:8004/v1/%(tenant_id)s"
+    internalurl: "http://{{ internal_vip.ip }}:8004/v1/%(tenant_id)s"
+    adminurl: "http://{{ internal_vip.ip }}:8004/v1/%(tenant_id)s"
 
   - name: heat-cfn
     type: cloudformation
@@ -104,9 +104,9 @@ os_services:
 #    type: object-store
 #    region: RegionOne
 #    description: "OpenStack Object Storage"
-#    publicurl: "http://{{ public_vip.ip }}:8080/v1/AUTH_%\\(tenant_id\\)s"
-#    internalurl: "http://{{ internal_vip.ip }}:8080/v1/AUTH_%\\(tenant_id\\)s"
-#    adminurl: "http://{{ internal_vip.ip }}:8080/v1/AUTH_%\\(tenant_id\\)s"
+#    publicurl: "http://{{ public_vip.ip }}:8080/v1/AUTH_%(tenant_id)s"
+#    internalurl: "http://{{ internal_vip.ip }}:8080/v1/AUTH_%(tenant_id)s"
+#    adminurl: "http://{{ internal_vip.ip }}:8080/v1/AUTH_%(tenant_id)s"
 
 os_users:
   - user: admin
index f3c4687..6be41aa 100644 (file)
@@ -14,7 +14,7 @@
     - restart nova service
 
 - name: nova db sync
-  nova_manage: action=dbsync
+  shell: su -s /bin/sh -c "nova-manage db sync" nova
   notify:
     - restart nova service
 
index 84b1260..882f488 100644 (file)
@@ -7,20 +7,14 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 ---
-
 - name: create openstack flavors
-  shell: |
-    . /opt/admin-openrc.sh;
-    openstack flavor show m1.nano || openstack flavor create \
-        --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano
-    openstack flavor show m1.tiny || openstack flavor create \
-        --id 1 --vcpus 1 --ram 512 --disk 1 m1.tiny
-    openstack flavor show m1.small || openstack flavor create \
-        --id 2 --vcpus 1 --ram 2048 --disk 20 m1.small
-    openstack flavor show m1.medium || openstack flavor create \
-        --id 3 --vcpus 2 --ram 4096 --disk 40 m1.medium
-    openstack flavor show m1.large || openstack flavor create \
-        --id 4 --vcpus 4 --ram 8192 --disk 80 m1.large
-    openstack flavor show m1.xlarge || openstack flavor create \
-        --id 5 --vcpus 8 --ram 16384 --disk 160 m1.xlarge
+  os_nova_flavor:
+    cloud: opnfv
+    state: present
+    flavorid: "{{ item.id }}"
+    name: "{{ item.name }}"
+    vcpus: "{{ item.vcpus }}"
+    ram: "{{ item.ram }}"
+    disk: "{{ item.disk }}"
+  with_items: "{{ flavors }}"
   when: inventory_hostname == groups['controller'][0]
diff --git a/deploy/adapters/ansible/roles/openstack-post/vars/main.yml b/deploy/adapters/ansible/roles/openstack-post/vars/main.yml
new file mode 100644 (file)
index 0000000..d9c36d4
--- /dev/null
@@ -0,0 +1,45 @@
+##############################################################################
+# Copyright (c) 2017 HUAWEI TECHNOLOGIES CO.,LTD and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+---
+flavors:
+  - id: 0
+    name: m1.nano
+    vcpus: 1
+    ram: 64
+    disk: 1
+
+  - id: 1
+    name: m1.tiny
+    vcpus: 1
+    ram: 512
+    disk: 1
+
+  - id: 2
+    name: m1.small
+    vcpus: 1
+    ram: 2048
+    disk: 20
+
+  - id: 3
+    name: m1.medium
+    vcpus: 2
+    ram: 4096
+    disk: 40
+
+  - id: 4
+    name: m1.large
+    vcpus: 4
+    ram: 8192
+    disk: 80
+
+  - id: 5
+    name: m1.xlarge
+    vcpus: 8
+    ram: 16384
+    disk: 160
index 42cdee9..a1ad702 100755 (executable)
@@ -4,7 +4,7 @@ log_path = /var/ansible/run/openstack_newton-$cluster_name/ansible.log
 host_key_checking = False
 callback_whitelist = playbook_done, status_callback
 callback_plugins = /opt/compass/bin/ansible_callbacks
-library = /opt/openstack-ansible-modules
+library = /opt/ansible-modules
 forks=100
 
 [ssh_connection]
index afc3bbe..bf27b31 100755 (executable)
@@ -18,6 +18,8 @@ function deploy_host(){
     ssh $ssh_args root@${MGMT_IP} mkdir -p /opt/compass/bin/ansible_callbacks
     scp $ssh_args -r ${COMPASS_DIR}/deploy/status_callback.py root@${MGMT_IP}:/opt/compass/bin/ansible_callbacks/status_callback.py
     scp $ssh_args -r ${COMPASS_DIR}/deploy/playbook_done.py root@${MGMT_IP}:/opt/compass/bin/ansible_callbacks/playbook_done.py
+    ssh $ssh_args root@${MGMT_IP} mkdir -p /opt/ansible-modules
+    scp $ssh_args -r ${COMPASS_DIR}/deploy/adapters/ansible/ansible_modules/* root@${MGMT_IP}:/opt/ansible-modules
 
     # avoid nodes reboot to fast, cobbler can not give response
     (sleep $AYNC_TIMEOUT; rename_nics; reboot_hosts) &
index a13c130..6d70d56 100644 (file)
@@ -2,3 +2,4 @@
 # download format tar.gz
 
 networking-odl==3.2.0
+pymongo==3.0.3
index 5cdc646..50a64fc 100644 (file)
@@ -9,3 +9,4 @@ yang2tosca==0.13
 python-keyczar==0.715
 crudini==0.7
 pexpect==3.3
+shade==1.14.1